@@ -5405,10 +5405,7 @@ void Parser::ParseFncDeclHelper(ParseNodeFnc * pnodeFnc, LPCOLESTR pNameHint, us
5405
5405
m_reparsingLambdaParams = true ;
5406
5406
}
5407
5407
5408
- DeferredFunctionStub* savedDeferredStub = m_currDeferredStub;
5409
- m_currDeferredStub = nullptr ;
5410
5408
this ->ParseFncFormals <buildAST>(pnodeFnc, pnodeFncParent, flags, isTopLevelDeferredFunc);
5411
- m_currDeferredStub = savedDeferredStub;
5412
5409
5413
5410
m_reparsingLambdaParams = fLambdaParamsSave ;
5414
5411
}
@@ -5822,7 +5819,7 @@ void Parser::ParseTopLevelDeferredFunc(ParseNodeFnc * pnodeFnc, ParseNodeFnc * p
5822
5819
{
5823
5820
ParseExpressionLambdaBody<false >(pnodeFnc, fAllowIn );
5824
5821
}
5825
- else if (pnodeFncParent != nullptr && m_currDeferredStub != nullptr && !pnodeFncParent-> HasDefaultArguments () )
5822
+ else if (pnodeFncParent != nullptr && m_currDeferredStub != nullptr )
5826
5823
{
5827
5824
// We've already parsed this function body for syntax errors on the initial parse of the script.
5828
5825
// We have information that allows us to skip it, so do so.
@@ -13953,43 +13950,13 @@ bool Parser::IsCreatingStateCache()
13953
13950
&& CONFIG_FLAG (ParserStateCache));
13954
13951
}
13955
13952
13956
- DeferredFunctionStub * Parser::BuildDeferredStubTree (ParseNodeFnc *pnodeFnc , Recycler *recycler)
13953
+ uint Parser::BuildDeferredStubTreeHelper (ParseNodeBlock* pnodeBlock, DeferredFunctionStub* deferredStubs, uint currentStubIndex, uint deferredStubCount , Recycler *recycler)
13957
13954
{
13958
- Assert (CONFIG_FLAG (ParserStateCache));
13959
-
13960
- uint nestedCount = pnodeFnc->nestedCount ;
13961
- if (nestedCount == 0 )
13962
- {
13963
- return nullptr ;
13964
- }
13955
+ Assert (pnodeBlock != nullptr
13956
+ && (pnodeBlock->blockType == PnodeBlockType::Function
13957
+ || pnodeBlock->blockType == PnodeBlockType::Parameter));
13965
13958
13966
- if (pnodeFnc->deferredStub )
13967
- {
13968
- return pnodeFnc->deferredStub ;
13969
- }
13970
-
13971
- DeferredFunctionStub* deferredStubs = RecyclerNewArray (recycler, DeferredFunctionStub, nestedCount);
13972
- uint i = 0 ;
13973
- ParseNodeBlock* pnodeBlock = pnodeFnc->pnodeBodyScope ;
13974
- ParseNodePtr pnodeChild = nullptr ;
13975
-
13976
- if (pnodeFnc->nop == knopProg)
13977
- {
13978
- Assert (pnodeFnc->pnodeBodyScope == nullptr
13979
- && pnodeFnc->pnodeScopes != nullptr
13980
- && pnodeFnc->pnodeScopes ->blockType == PnodeBlockType::Global);
13981
-
13982
- pnodeBlock = pnodeFnc->pnodeScopes ;
13983
- pnodeChild = pnodeFnc->pnodeScopes ->pnodeScopes ;
13984
- }
13985
- else
13986
- {
13987
- Assert (pnodeBlock != nullptr
13988
- && (pnodeBlock->blockType == PnodeBlockType::Function
13989
- || pnodeBlock->blockType == PnodeBlockType::Parameter));
13990
-
13991
- pnodeChild = pnodeBlock->pnodeScopes ;
13992
- }
13959
+ ParseNodePtr pnodeChild = pnodeBlock->pnodeScopes ;
13993
13960
13994
13961
while (pnodeChild != nullptr )
13995
13962
{
@@ -14004,37 +13971,56 @@ DeferredFunctionStub * Parser::BuildDeferredStubTree(ParseNodeFnc *pnodeFnc, Rec
14004
13971
}
14005
13972
14006
13973
ParseNodeFnc* pnodeFncChild = pnodeChild->AsParseNodeFnc ();
14007
- AnalysisAssertOrFailFast (i < nestedCount);
14008
-
14009
- if (pnodeFncChild->pnodeBody != nullptr )
14010
- {
14011
- // Anomalous case of a non-deferred function nested within a deferred one.
14012
- // Work around by discarding the stub tree.
14013
- return nullptr ;
14014
- }
13974
+ AnalysisAssertOrFailFast (currentStubIndex < deferredStubCount);
13975
+ Assert (pnodeFncChild->pnodeBody == nullptr );
14015
13976
14016
13977
if (pnodeFncChild->IsGeneratedDefault ())
14017
13978
{
14018
- ++i ;
13979
+ ++currentStubIndex ;
14019
13980
pnodeChild = pnodeFncChild->pnodeNext ;
14020
13981
continue ;
14021
13982
}
14022
13983
14023
- deferredStubs[i ].fncFlags = pnodeFncChild->fncFlags ;
14024
- deferredStubs[i ].nestedCount = pnodeFncChild->nestedCount ;
14025
- deferredStubs[i ].restorePoint = *pnodeFncChild->pRestorePoint ;
14026
- deferredStubs[i ].deferredStubs = BuildDeferredStubTree (pnodeFncChild, recycler);
14027
- deferredStubs[i ].ichMin = pnodeChild->ichMin ;
13984
+ deferredStubs[currentStubIndex ].fncFlags = pnodeFncChild->fncFlags ;
13985
+ deferredStubs[currentStubIndex ].nestedCount = pnodeFncChild->nestedCount ;
13986
+ deferredStubs[currentStubIndex ].restorePoint = *pnodeFncChild->pRestorePoint ;
13987
+ deferredStubs[currentStubIndex ].deferredStubs = BuildDeferredStubTree (pnodeFncChild, recycler);
13988
+ deferredStubs[currentStubIndex ].ichMin = pnodeChild->ichMin ;
14028
13989
14029
13990
// Save the set of captured names onto the deferred stub.
14030
13991
// Since this set is allocated in the Parser arena, we'll have to convert these
14031
13992
// into indices in a string table which will survive when the parser goes away.
14032
- deferredStubs[i ].capturedNamePointers = pnodeFncChild->GetCapturedNames ();
13993
+ deferredStubs[currentStubIndex ].capturedNamePointers = pnodeFncChild->GetCapturedNames ();
14033
13994
14034
- ++i ;
13995
+ ++currentStubIndex ;
14035
13996
pnodeChild = pnodeFncChild->pnodeNext ;
14036
13997
}
14037
13998
13999
+ return currentStubIndex;
14000
+ }
14001
+
14002
+ DeferredFunctionStub * Parser::BuildDeferredStubTree (ParseNodeFnc *pnodeFnc, Recycler *recycler)
14003
+ {
14004
+ Assert (CONFIG_FLAG (ParserStateCache));
14005
+
14006
+ uint nestedCount = pnodeFnc->nestedCount ;
14007
+ if (nestedCount == 0 )
14008
+ {
14009
+ return nullptr ;
14010
+ }
14011
+
14012
+ if (pnodeFnc->deferredStub )
14013
+ {
14014
+ return pnodeFnc->deferredStub ;
14015
+ }
14016
+
14017
+ DeferredFunctionStub* deferredStubs = RecyclerNewArray (recycler, DeferredFunctionStub, nestedCount);
14018
+
14019
+ uint currentStubIndex = BuildDeferredStubTreeHelper (pnodeFnc->pnodeScopes , deferredStubs, 0 , nestedCount, recycler);
14020
+ currentStubIndex = BuildDeferredStubTreeHelper (pnodeFnc->pnodeBodyScope , deferredStubs, currentStubIndex, nestedCount, recycler);
14021
+
14022
+ Assert (currentStubIndex == nestedCount);
14023
+
14038
14024
pnodeFnc->deferredStub = deferredStubs;
14039
14025
return deferredStubs;
14040
14026
}
0 commit comments