Skip to content

Commit 9515daf

Browse files
committed
Remove redundant fscrImplicitParents from parser flags
1 parent 7eb83c2 commit 9515daf

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

lib/Parser/Parse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1568,7 +1568,7 @@ void Parser::CreateSpecialSymbolDeclarations(ParseNodeFnc * pnodeFnc)
15681568
return;
15691569
}
15701570

1571-
bool isTopLevelEventHandler = (this->m_grfscr & fscrImplicitThis || this->m_grfscr & fscrImplicitParents) && !pnodeFnc->IsNested();
1571+
bool isTopLevelEventHandler = (this->m_grfscr & fscrImplicitThis) && !pnodeFnc->IsNested();
15721572

15731573
// Create a 'this' symbol for non-lambda functions with references to 'this', and all class constructors and top level event hanlders.
15741574
ParseNodePtr varDeclNode = CreateSpecialVarDeclIfNeeded(pnodeFnc, wellKnownPropertyPids._this, pnodeFnc->IsClassConstructor() || isTopLevelEventHandler);

lib/Parser/ParseFlags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ enum
1111
// Unused = 1 << 0,
1212
fscrReturnExpression = 1 << 1, // call should return the last expression
1313
fscrImplicitThis = 1 << 2, // 'this.' is optional (for Call)
14-
fscrImplicitParents = 1 << 3, // the parents of 'this' are implicit
14+
// Unused = 1 << 3,
1515
// Unused = 1 << 4,
1616
fscrDynamicCode = 1 << 5, // The code is being generated dynamically (eval, new Function, etc.)
1717
// Unused = 1 << 6,

lib/Runtime/ByteCode/ByteCodeEmitter.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3507,7 +3507,7 @@ void ByteCodeGenerator::StartEmitFunction(ParseNodeFnc *pnodeFnc)
35073507

35083508
if (funcInfo->byteCodeFunction->IsFunctionParsed() && funcInfo->root->pnodeBody != nullptr)
35093509
{
3510-
if (funcInfo->GetParsedFunctionBody()->GetByteCode() == nullptr && !(flags & (fscrEval | fscrImplicitThis | fscrImplicitParents)))
3510+
if (funcInfo->GetParsedFunctionBody()->GetByteCode() == nullptr && !(flags & (fscrEval | fscrImplicitThis)))
35113511
{
35123512
// Only set the environment depth if it's truly known (i.e., not in eval or event handler).
35133513
funcInfo->GetParsedFunctionBody()->SetEnvDepth(this->envDepth);
@@ -3993,7 +3993,7 @@ void ByteCodeGenerator::StartEmitCatch(ParseNodeCatch *pnodeCatch)
39933993
FuncInfo *funcInfo = scope->GetFunc();
39943994

39953995
// Catch scope is a dynamic object if it can be passed to a scoped lookup helper (i.e., eval is present or we're in an event handler).
3996-
if (funcInfo->GetCallsEval() || funcInfo->GetChildCallsEval() || (this->flags & (fscrEval | fscrImplicitThis | fscrImplicitParents)))
3996+
if (funcInfo->GetCallsEval() || funcInfo->GetChildCallsEval() || (this->flags & (fscrEval | fscrImplicitThis)))
39973997
{
39983998
scope->SetIsObject();
39993999
}
@@ -4069,7 +4069,7 @@ void ByteCodeGenerator::StartEmitBlock(ParseNodeBlock *pnodeBlock)
40694069
PushBlock(pnodeBlock);
40704070

40714071
Scope *scope = pnodeBlock->scope;
4072-
if (pnodeBlock->GetCallsEval() || pnodeBlock->GetChildCallsEval() || (this->flags & (fscrEval | fscrImplicitThis | fscrImplicitParents)))
4072+
if (pnodeBlock->GetCallsEval() || pnodeBlock->GetChildCallsEval() || (this->flags & (fscrEval | fscrImplicitThis)))
40734073
{
40744074
Assert(scope->GetIsObject());
40754075
}
@@ -4301,7 +4301,7 @@ void ByteCodeGenerator::EmitLoadInstance(Symbol *sym, IdentPtr pid, Js::RegSlot
43014301

43024302
if (sym == nullptr || sym->GetIsGlobal())
43034303
{
4304-
if (this->flags & (fscrEval | fscrImplicitThis | fscrImplicitParents))
4304+
if (this->flags & (fscrEval | fscrImplicitThis))
43054305
{
43064306
// Load of a symbol with unknown scope from within eval.
43074307
// Get it from the closure environment.
@@ -4731,11 +4731,11 @@ void ByteCodeGenerator::EmitPropStore(Js::RegSlot rhsLocation, Symbol *sym, Iden
47314731
this->m_writer.ElementP(GetScopedStFldOpCode(funcInfo, isConsoleScopeLetConst), rhsLocation, cacheId);
47324732
}
47334733
}
4734-
else if (this->flags & (fscrImplicitThis | fscrImplicitParents))
4734+
else if (this->flags & fscrImplicitThis)
47354735
{
47364736
uint cacheId = funcInfo->FindOrAddInlineCacheId(funcInfo->GetEnvRegister(), propertyId, false, true);
47374737

4738-
// In "eval", store to a symbol with unknown scope goes through the closure environment.
4738+
// In HTML event handler, store to a symbol with unknown scope goes through the closure environment.
47394739
this->m_writer.ElementP(GetScopedStFldOpCode(funcInfo, isConsoleScopeLetConst), rhsLocation, cacheId);
47404740
}
47414741
else
@@ -5106,11 +5106,11 @@ void ByteCodeGenerator::EmitPropLoad(Js::RegSlot lhsLocation, Symbol *sym, Ident
51065106
this->m_writer.ElementP(Js::OpCode::ScopedLdFld, lhsLocation, cacheId);
51075107
}
51085108
}
5109-
else if (this->flags & (fscrImplicitThis | fscrImplicitParents))
5109+
else if (this->flags & fscrImplicitThis)
51105110
{
51115111
uint cacheId = funcInfo->FindOrAddInlineCacheId(funcInfo->GetEnvRegister(), propertyId, false, false);
51125112

5113-
// Load of a symbol with unknown scope from within eval or event handler.
5113+
// Load of a symbol with unknown scope from within event handler.
51145114
// Get it from the closure environment.
51155115
this->m_writer.ElementP(Js::OpCode::ScopedLdFld, lhsLocation, cacheId);
51165116
}
@@ -5323,7 +5323,7 @@ void ByteCodeGenerator::EmitPropDelete(Js::RegSlot lhsLocation, Symbol *sym, Ide
53235323
if (sym == nullptr || sym->GetIsGlobal())
53245324
{
53255325
Js::PropertyId propertyId = sym ? sym->EnsurePosition(this) : pid->GetPropertyId();
5326-
if (this->flags & (fscrEval | fscrImplicitThis | fscrImplicitParents))
5326+
if (this->flags & (fscrEval | fscrImplicitThis))
53275327
{
53285328
this->m_writer.ScopedProperty(Js::OpCode::ScopedDeleteFld, lhsLocation,
53295329
funcInfo->FindOrAddReferencedPropertyId(propertyId));
@@ -5511,7 +5511,7 @@ void ByteCodeGenerator::EmitPropTypeof(Js::RegSlot lhsLocation, Symbol *sym, Ide
55115511
this->EmitTypeOfFld(funcInfo, propertyId, lhsLocation, funcInfo->GetEnvRegister(), Js::OpCode::ScopedLdFldForTypeOf);
55125512
}
55135513
}
5514-
else if (this->flags & (fscrImplicitThis | fscrImplicitParents))
5514+
else if (this->flags & fscrImplicitThis)
55155515
{
55165516
this->EmitTypeOfFld(funcInfo, propertyId, lhsLocation, funcInfo->GetEnvRegister(), Js::OpCode::ScopedLdFldForTypeOf);
55175517
}

lib/Runtime/ByteCode/ByteCodeGenerator.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void BeginVisitCatch(ParseNode *pnode, ByteCodeGenerator *byteCodeGenerator)
140140
FuncInfo *func = scope->GetFunc();
141141

142142
if (func->GetCallsEval() || func->GetChildCallsEval() ||
143-
(byteCodeGenerator->GetFlags() & (fscrEval | fscrImplicitThis | fscrImplicitParents)))
143+
(byteCodeGenerator->GetFlags() & (fscrEval | fscrImplicitThis)))
144144
{
145145
scope->SetIsObject();
146146
}
@@ -810,7 +810,7 @@ void ByteCodeGenerator::SetRootFuncInfo(FuncInfo* func)
810810
{
811811
Assert(pRootFunc == nullptr || pRootFunc == func->byteCodeFunction || !IsInNonDebugMode());
812812

813-
if ((this->flags & (fscrImplicitThis | fscrImplicitParents)) && !this->HasParentScopeInfo())
813+
if ((this->flags & fscrImplicitThis) && !this->HasParentScopeInfo())
814814
{
815815
// Mark a top-level event handler, since it will need to construct the "this" pointer's
816816
// namespace hierarchy to access globals.
@@ -1892,7 +1892,7 @@ bool ByteCodeGenerator::NeedObjectAsFunctionScope(FuncInfo * funcInfo, ParseNode
18921892
return funcInfo->GetCallsEval()
18931893
|| funcInfo->GetChildCallsEval()
18941894
|| NeedScopeObjectForArguments(funcInfo, pnodeFnc)
1895-
|| (this->flags & (fscrEval | fscrImplicitThis | fscrImplicitParents));
1895+
|| (this->flags & (fscrEval | fscrImplicitThis));
18961896
}
18971897

18981898
Scope * ByteCodeGenerator::FindScopeForSym(Scope *symScope, Scope *scope, Js::PropertyId *envIndex, FuncInfo *funcInfo) const
@@ -2766,7 +2766,7 @@ FuncInfo* PostVisitFunction(ParseNodeFnc* pnodeFnc, ByteCodeGenerator* byteCodeG
27662766
top->GetCallsEval() ||
27672767
top->GetHasClosureReference() ||
27682768
byteCodeGenerator->InDynamicScope() ||
2769-
(byteCodeGenerator->GetFlags() & (fscrImplicitThis | fscrImplicitParents | fscrEval)))
2769+
(byteCodeGenerator->GetFlags() & (fscrImplicitThis | fscrEval)))
27702770
{
27712771
byteCodeGenerator->SetNeedEnvRegister();
27722772
}
@@ -3577,7 +3577,7 @@ void PostVisitBlock(ParseNodeBlock *pnodeBlock, ByteCodeGenerator *byteCodeGener
35773577

35783578
Scope *scope = pnodeBlock->scope;
35793579

3580-
if (pnodeBlock->GetCallsEval() || pnodeBlock->GetChildCallsEval() || (byteCodeGenerator->GetFlags() & (fscrEval | fscrImplicitThis | fscrImplicitParents)))
3580+
if (pnodeBlock->GetCallsEval() || pnodeBlock->GetChildCallsEval() || (byteCodeGenerator->GetFlags() & (fscrEval | fscrImplicitThis)))
35813581
{
35823582
bool scopeIsEmpty = scope->IsEmpty();
35833583
scope->SetIsObject();
@@ -5188,7 +5188,7 @@ bool ByteCodeGenerator::NeedScopeObjectForArguments(FuncInfo *funcInfo, ParseNod
51885188
&& (funcInfo->GetIsStrictMode()
51895189
|| pnodeFnc->HasNonSimpleParameterList())
51905190
// We're not in eval or event handler, which will force the scope(s) to be objects
5191-
&& !(this->flags & (fscrEval | fscrImplicitThis | fscrImplicitParents))
5191+
&& !(this->flags & (fscrEval | fscrImplicitThis))
51925192
// Neither of the scopes are objects
51935193
&& !funcInfo->paramScope->GetIsObject()
51945194
&& !funcInfo->bodyScope->GetIsObject();

0 commit comments

Comments
 (0)