Changeset 279447 in webkit for trunk/Source/JavaScriptCore/parser/Parser.h
- Timestamp:
- Jun 30, 2021, 7:03:55 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/parser/Parser.h
r278588 r279447 24 24 25 25 #include "ExecutableInfo.h" 26 #include "IterationStatus.h" 26 27 #include "Lexer.h" 27 28 #include "ModuleScopeData.h" … … 320 321 VariableEnvironment& declaredVariables() { return m_declaredVariables; } 321 322 VariableEnvironment& lexicalVariables() { return m_lexicalVariables; } 322 VariableEnvironment& finalizeLexicalEnvironment()323 { 323 void finalizeLexicalEnvironment() 324 { 324 325 if (m_usesEval || m_needsFullActivation) 325 326 m_lexicalVariables.markAllVariablesAsCaptured(); 326 327 else 327 328 computeLexicallyCapturedVariablesAndPurgeCandidates(); 328 329 return m_lexicalVariables; 330 } 329 } 330 331 VariableEnvironment takeLexicalEnvironment() { return WTFMove(m_lexicalVariables); } 332 VariableEnvironment takeDeclaredVariables() { return WTFMove(m_declaredVariables); } 331 333 332 334 void computeLexicallyCapturedVariablesAndPurgeCandidates() … … 422 424 m_functionDeclarations.append(node); 423 425 } 424 DeclarationStacks::FunctionStack &&takeFunctionDeclarations() { return WTFMove(m_functionDeclarations); }426 DeclarationStacks::FunctionStack takeFunctionDeclarations() { return WTFMove(m_functionDeclarations); } 425 427 426 428 … … 479 481 { 480 482 return m_lexicalVariables.hasPrivateName(ident); 481 }482 483 void copyUndeclaredPrivateNamesTo(Scope& other)484 {485 m_lexicalVariables.copyUndeclaredPrivateNamesTo(other.m_lexicalVariables);486 }487 488 bool hasUsedButUndeclaredPrivateNames() const489 {490 if (m_lexicalVariables.privateNamesSize() > 0) {491 for (auto entry : m_lexicalVariables.privateNames()) {492 if (entry.value.isUsed() && !entry.value.isDeclared())493 return true;494 }495 }496 return false;497 }498 499 void usePrivateName(const Identifier& ident)500 {501 ASSERT(m_allowsLexicalDeclarations);502 m_lexicalVariables.usePrivateName(ident);503 483 } 504 484 … … 612 592 { 613 593 for (const UniquedStringImplPtrSet& set : m_usedVariables) { 614 for (UniquedStringImpl* impl : set) 615 func(impl); 594 for (UniquedStringImpl* impl : set) { 595 if (func(impl) == IterationStatus::Done) 596 return; 597 } 616 598 } 617 599 } … … 625 607 m_usedVariables.last().add(impl); 626 608 } 609 void usePrivateName(const Identifier& ident) 610 { 611 ASSERT(m_allowsLexicalDeclarations); 612 useVariable(&ident, false); 613 } 627 614 628 615 void pushUsedVariableSet() { m_usedVariables.append(UniquedStringImplPtrSet()); } 629 616 size_t currentUsedVariablesSize() { return m_usedVariables.size(); } 630 631 617 void revertToPreviousUsedVariables(size_t size) { m_usedVariables.resize(size); } 632 618 … … 1281 1267 } 1282 1268 1283 ScopeRef privateNameScope()1284 {1285 ASSERT(m_scopeStack.size());1286 unsigned i = m_scopeStack.size() - 1;1287 while (i && !m_scopeStack[i].isPrivateNameScope())1288 i--;1289 1290 ASSERT(m_scopeStack[i].isPrivateNameScope());1291 return ScopeRef(&m_scopeStack, i);1292 }1293 1294 bool copyUndeclaredPrivateNamesToOuterScope()1295 {1296 ScopeRef current = privateNameScope();1297 unsigned i = current.index() - 1;1298 while (i && !m_scopeStack[i].isPrivateNameScope())1299 i--;1300 1301 if (!i)1302 return !current->hasUsedButUndeclaredPrivateNames();1303 1304 current->copyUndeclaredPrivateNamesTo(m_scopeStack[i]);1305 return true;1306 }1307 1308 1269 ScopeRef closestParentOrdinaryFunctionNonLexicalScope() 1309 1270 { … … 1343 1304 } 1344 1305 1345 voidpopScopeInternal(ScopeRef& scope, bool shouldTrackClosedVariables)1306 std::tuple<VariableEnvironment, DeclarationStacks::FunctionStack> popScopeInternal(ScopeRef& scope, bool shouldTrackClosedVariables) 1346 1307 { 1347 1308 EXCEPTION_ASSERT_UNUSED(scope, scope.index() == m_scopeStack.size() - 1); 1348 1309 ASSERT(m_scopeStack.size() > 1); 1349 m_scopeStack[m_scopeStack.size() - 2].collectFreeVariables(&m_scopeStack.last(), shouldTrackClosedVariables); 1310 Scope& lastScope = m_scopeStack.last(); 1311 1312 // Finalize lexical variables. 1313 lastScope.finalizeLexicalEnvironment(); 1314 m_scopeStack[m_scopeStack.size() - 2].collectFreeVariables(&lastScope, shouldTrackClosedVariables); 1350 1315 1351 if ( m_scopeStack.last().isArrowFunction())1352 m_scopeStack.last().setInnerArrowFunctionUsesEvalAndUseArgumentsIfNeeded();1316 if (lastScope.isArrowFunction()) 1317 lastScope.setInnerArrowFunctionUsesEvalAndUseArgumentsIfNeeded(); 1353 1318 1354 if (!( m_scopeStack.last().isFunctionBoundary() && !m_scopeStack.last().isArrowFunctionBoundary()))1355 m_scopeStack[m_scopeStack.size() - 2].mergeInnerArrowFunctionFeatures( m_scopeStack.last().innerArrowFunctionFeatures());1356 1357 if (! m_scopeStack.last().isFunctionBoundary() && m_scopeStack.last().needsFullActivation())1319 if (!(lastScope.isFunctionBoundary() && !lastScope.isArrowFunctionBoundary())) 1320 m_scopeStack[m_scopeStack.size() - 2].mergeInnerArrowFunctionFeatures(lastScope.innerArrowFunctionFeatures()); 1321 1322 if (!lastScope.isFunctionBoundary() && lastScope.needsFullActivation()) 1358 1323 m_scopeStack[m_scopeStack.size() - 2].setNeedsFullActivation(); 1324 std::tuple result { lastScope.takeLexicalEnvironment(), lastScope.takeFunctionDeclarations() }; 1359 1325 m_scopeStack.removeLast(); 1360 } 1361 1362 ALWAYS_INLINE void popScope(ScopeRef& scope, bool shouldTrackClosedVariables) 1363 { 1364 popScopeInternal(scope, shouldTrackClosedVariables); 1365 } 1366 1367 ALWAYS_INLINE void popScope(AutoPopScopeRef& scope, bool shouldTrackClosedVariables) 1326 return result; 1327 } 1328 1329 ALWAYS_INLINE std::tuple<VariableEnvironment, DeclarationStacks::FunctionStack> popScope(ScopeRef& scope, bool shouldTrackClosedVariables) 1330 { 1331 return popScopeInternal(scope, shouldTrackClosedVariables); 1332 } 1333 1334 ALWAYS_INLINE std::tuple<VariableEnvironment, DeclarationStacks::FunctionStack> popScope(AutoPopScopeRef& scope, bool shouldTrackClosedVariables) 1368 1335 { 1369 1336 scope.setPopped(); 1370 popScopeInternal(scope, shouldTrackClosedVariables);1371 } 1372 1373 ALWAYS_INLINE voidpopScope(AutoCleanupLexicalScope& cleanupScope, bool shouldTrackClosedVariables)1337 return popScopeInternal(scope, shouldTrackClosedVariables); 1338 } 1339 1340 ALWAYS_INLINE std::tuple<VariableEnvironment, DeclarationStacks::FunctionStack> popScope(AutoCleanupLexicalScope& cleanupScope, bool shouldTrackClosedVariables) 1374 1341 { 1375 1342 RELEASE_ASSERT(cleanupScope.isValid()); 1376 1343 ScopeRef& scope = cleanupScope.scope(); 1377 1344 cleanupScope.setPopped(); 1378 popScopeInternal(scope, shouldTrackClosedVariables);1345 return popScopeInternal(scope, shouldTrackClosedVariables); 1379 1346 } 1380 1347 … … 1510 1477 DeclarationStacks::FunctionStack functionDeclarations; 1511 1478 VariableEnvironment varDeclarations; 1479 VariableEnvironment lexicalVariables; 1512 1480 UniquedStringImplPtrSet sloppyModeHoistedFunctions; 1513 1481 CodeFeatures features; … … 1840 1808 template <class TreeBuilder> ALWAYS_INLINE bool isSimpleAssignmentTarget(TreeBuilder&, TreeExpression); 1841 1809 1842 ALWAYS_INLINE bool usePrivateName(const Identifier*);1843 1844 1810 ALWAYS_INLINE int isBinaryOperator(JSTokenType); 1845 1811 bool allowAutomaticSemicolon(); … … 2124 2090 DebuggerParseData* m_debuggerParseData; 2125 2091 CallOrApplyDepthScope* m_callOrApplyDepthScope { nullptr }; 2126 bool m_seenTaggedTemplate { false };2127 2092 bool m_isInsideOrdinaryFunction; 2093 bool m_seenTaggedTemplateInNonReparsingFunctionMode { false }; 2094 bool m_seenPrivateNameUseInNonReparsingFunctionMode { false }; 2128 2095 }; 2129 2096 … … 2173 2140 endColumn, 2174 2141 parseResult.value().sourceElements, 2175 parseResult.value().varDeclarations,2142 WTFMove(parseResult.value().varDeclarations), 2176 2143 WTFMove(parseResult.value().functionDeclarations), 2177 currentScope()->finalizeLexicalEnvironment(),2144 WTFMove(parseResult.value().lexicalVariables), 2178 2145 WTFMove(parseResult.value().sloppyModeHoistedFunctions), 2179 2146 parseResult.value().parameters,
Note:
See TracChangeset
for help on using the changeset viewer.