@@ -2545,7 +2545,7 @@ FuncInfo* PreVisitFunction(ParseNode* pnode, ByteCodeGenerator* byteCodeGenerato
2545
2545
}
2546
2546
PreVisitBlock (pnode->sxFnc .pnodeScopes , byteCodeGenerator);
2547
2547
// If we have arguments, we are going to need locations if the function is in strict mode or we have a non-simple parameter list. This is because we will not create a scope object.
2548
- bool assignLocationForFormals = !ByteCodeGenerator:: NeedScopeObjectForArguments (funcInfo, funcInfo->root );
2548
+ bool assignLocationForFormals = !byteCodeGenerator-> NeedScopeObjectForArguments (funcInfo, funcInfo->root );
2549
2549
AddArgsToScope (pnode, byteCodeGenerator, assignLocationForFormals);
2550
2550
2551
2551
return funcInfo;
@@ -2605,7 +2605,7 @@ void AssignFuncSymRegister(ParseNode * pnode, ByteCodeGenerator * byteCodeGenera
2605
2605
Symbol * functionScopeVarSym = sym->GetFuncScopeVarSym ();
2606
2606
if (functionScopeVarSym &&
2607
2607
!functionScopeVarSym->GetIsGlobal () &&
2608
- !functionScopeVarSym->IsInSlot (sym->GetScope ()->GetFunc ()))
2608
+ !functionScopeVarSym->IsInSlot (byteCodeGenerator, sym->GetScope ()->GetFunc ()))
2609
2609
{
2610
2610
byteCodeGenerator->AssignRegister (functionScopeVarSym);
2611
2611
}
@@ -2780,7 +2780,7 @@ FuncInfo* PostVisitFunction(ParseNode* pnode, ByteCodeGenerator* byteCodeGenerat
2780
2780
{
2781
2781
if (top->GetCallsEval () ||
2782
2782
top->GetChildCallsEval () ||
2783
- (top->GetHasArguments () && ByteCodeGenerator:: NeedScopeObjectForArguments (top, pnode)) ||
2783
+ (top->GetHasArguments () && byteCodeGenerator-> NeedScopeObjectForArguments (top, pnode)) ||
2784
2784
top->GetHasLocalInClosure () ||
2785
2785
(top->funcExprScope && top->funcExprScope ->GetMustInstantiate ()) ||
2786
2786
// When we have split scope normally either eval will be present or the GetHasLocalInClosure will be true as one of the formal is
@@ -2849,10 +2849,10 @@ FuncInfo* PostVisitFunction(ParseNode* pnode, ByteCodeGenerator* byteCodeGenerat
2849
2849
};
2850
2850
2851
2851
// We need to include the rest as well -as it will get slot assigned.
2852
- if (ByteCodeGenerator:: NeedScopeObjectForArguments (top, pnode))
2852
+ if (byteCodeGenerator-> NeedScopeObjectForArguments (top, pnode))
2853
2853
{
2854
2854
MapFormals (pnode, setArgScopeSlot);
2855
- if (argSym->NeedsSlotAlloc (top))
2855
+ if (argSym->NeedsSlotAlloc (byteCodeGenerator, top))
2856
2856
{
2857
2857
Assert (argSym->GetScopeSlot () == Js::Constants::NoProperty);
2858
2858
argSym->SetScopeSlot (i++);
@@ -2863,7 +2863,7 @@ FuncInfo* PostVisitFunction(ParseNode* pnode, ByteCodeGenerator* byteCodeGenerat
2863
2863
top->paramScope ->SetScopeSlotCount (i);
2864
2864
2865
2865
Assert (top->GetHasHeapArguments ());
2866
- if (ByteCodeGenerator:: NeedScopeObjectForArguments (top, pnode)
2866
+ if (byteCodeGenerator-> NeedScopeObjectForArguments (top, pnode)
2867
2867
&& !pnode->sxFnc .HasNonSimpleParameterList ())
2868
2868
{
2869
2869
top->byteCodeFunction ->SetHasImplicitArgIns (false );
@@ -3068,7 +3068,7 @@ void ByteCodeGenerator::ProcessCapturedSym(Symbol *sym)
3068
3068
FuncInfo *funcHome = sym->GetScope ()->GetFunc ();
3069
3069
FuncInfo *funcChild = funcHome->GetCurrentChildFunction ();
3070
3070
3071
- Assert (sym->NeedsSlotAlloc (funcHome) || sym->GetIsGlobal () || sym->GetIsModuleImport () || sym->GetIsModuleExportStorage ());
3071
+ Assert (sym->NeedsSlotAlloc (this , funcHome) || sym->GetIsGlobal () || sym->GetIsModuleImport () || sym->GetIsModuleExportStorage ());
3072
3072
3073
3073
// If this is not a local property, or not all its references can be tracked, or
3074
3074
// it's not scoped to the function, or we're in debug mode, disable the delayed capture optimization.
@@ -4953,11 +4953,11 @@ void AssignRegisters(ParseNode *pnode, ByteCodeGenerator *byteCodeGenerator)
4953
4953
}
4954
4954
// Don't give the declared var a register if it's in a closure, because the closure slot
4955
4955
// is its true "home". (Need to check IsGlobal again as the sym may have changed above.)
4956
- if (!sym->GetIsGlobal () && !sym->IsInSlot (funcInfo))
4956
+ if (!sym->GetIsGlobal () && !sym->IsInSlot (byteCodeGenerator, funcInfo))
4957
4957
{
4958
4958
if (PHASE_TRACE (Js::DelayCapturePhase, funcInfo->byteCodeFunction ))
4959
4959
{
4960
- if (sym->NeedsSlotAlloc (byteCodeGenerator->TopFuncInfo ()))
4960
+ if (sym->NeedsSlotAlloc (byteCodeGenerator, byteCodeGenerator ->TopFuncInfo ()))
4961
4961
{
4962
4962
Output::Print (_u (" --- DelayCapture: Delayed capturing symbol '%s' during initialization.\n " ),
4963
4963
sym->GetName ().GetBuffer ());
@@ -5011,12 +5011,12 @@ void AssignRegisters(ParseNode *pnode, ByteCodeGenerator *byteCodeGenerator)
5011
5011
if (!sym->GetIsGlobal () &&
5012
5012
!sym->GetIsMember () &&
5013
5013
byteCodeGenerator->TopFuncInfo () == sym->GetScope ()->GetEnclosingFunc () &&
5014
- !sym->IsInSlot (byteCodeGenerator->TopFuncInfo ()) &&
5014
+ !sym->IsInSlot (byteCodeGenerator, byteCodeGenerator ->TopFuncInfo ()) &&
5015
5015
!sym->HasVisitedCapturingFunc ())
5016
5016
{
5017
5017
if (PHASE_TRACE (Js::DelayCapturePhase, byteCodeGenerator->TopFuncInfo ()->byteCodeFunction ))
5018
5018
{
5019
- if (sym->NeedsSlotAlloc (byteCodeGenerator->TopFuncInfo ()))
5019
+ if (sym->NeedsSlotAlloc (byteCodeGenerator, byteCodeGenerator ->TopFuncInfo ()))
5020
5020
{
5021
5021
Output::Print (_u (" --- DelayCapture: Delayed capturing symbol '%s'.\n " ),
5022
5022
sym->GetName ().GetBuffer ());
@@ -5177,8 +5177,7 @@ Js::FunctionBody * ByteCodeGenerator::MakeGlobalFunctionBody(ParseNode *pnode)
5177
5177
return func;
5178
5178
}
5179
5179
5180
- /* static */
5181
- bool ByteCodeGenerator::NeedScopeObjectForArguments (FuncInfo *funcInfo, ParseNode *pnodeFnc)
5180
+ bool ByteCodeGenerator::NeedScopeObjectForArguments (FuncInfo *funcInfo, ParseNode *pnodeFnc) const
5182
5181
{
5183
5182
// We can avoid creating a scope object with arguments present if:
5184
5183
bool dontNeedScopeObject =
@@ -5187,6 +5186,8 @@ bool ByteCodeGenerator::NeedScopeObjectForArguments(FuncInfo *funcInfo, ParseNod
5187
5186
// Either we are in strict mode, or have strict mode formal semantics from a non-simple parameter list, and
5188
5187
&& (funcInfo->GetIsStrictMode ()
5189
5188
|| pnodeFnc->sxFnc .HasNonSimpleParameterList ())
5189
+ // We're not in eval or event handler, which will force the scope(s) to be objects
5190
+ && !(this ->flags & (fscrEval | fscrImplicitThis | fscrImplicitParents))
5190
5191
// Neither of the scopes are objects
5191
5192
&& !funcInfo->paramScope ->GetIsObject ()
5192
5193
&& !funcInfo->bodyScope ->GetIsObject ();
0 commit comments