Changeset 186997 in webkit
- Timestamp:
- Jul 18, 2015, 2:21:48 PM (10 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r186996 r186997 1 2015-07-18 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r186996. 4 https://bugs.webkit.org/show_bug.cgi?id=147070 5 6 Broke JSC tests (Requested by smfr on #webkit). 7 8 Reverted changeset: 9 10 "lexical scoping is broken with respect to "break" and 11 "continue"" 12 https://bugs.webkit.org/show_bug.cgi?id=147063 13 http://trac.webkit.org/changeset/186996 14 1 15 2015-07-18 Saam barati <saambarati1@gmail.com> 2 16 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r186996 r186997 523 523 } 524 524 525 if (m_lexicalEnvironmentRegister)526 pushScopedControlFlowContext();527 525 m_symbolTableStack.append(SymbolTableStackEntry{ Strong<SymbolTable>(*m_vm, m_symbolTable), m_lexicalEnvironmentRegister, false, symbolTableConstantIndex }); 528 526 m_TDZStack.append(std::make_pair(*parentScopeTDZVariables, false)); … … 630 628 631 629 // Allocate new label scope. 632 LabelScope scope(type, name, labelScopeDepth(), newLabel(), type == LabelScope::Loop ? newLabel() : PassRefPtr<Label>()); // Only loops have continue targets.630 LabelScope scope(type, name, scopeDepth(), newLabel(), type == LabelScope::Loop ? newLabel() : PassRefPtr<Label>()); // Only loops have continue targets. 633 631 m_labelScopes.append(scope); 634 632 return LabelScopePtr(m_labelScopes, m_labelScopes.size() - 1); … … 1213 1211 emitOpcode(op_profile_type); 1214 1212 instructions().append(registerToProfile->index()); 1215 instructions().append( localScopeDepth());1213 instructions().append(currentScopeDepth()); 1216 1214 instructions().append(flag); 1217 1215 instructions().append(identifier ? addConstant(*identifier) : 0); … … 1321 1319 1322 1320 emitMove(scopeRegister(), newScope); 1323 1324 pushScopedControlFlowContext();1325 1321 } 1326 1322 … … 1370 1366 if (hasCapturedVariables) { 1371 1367 RELEASE_ASSERT(stackEntry.m_scope); 1372 emitPopScope(scopeRegister(), stackEntry.m_scope);1373 popScopedControlFlowContext();1368 RefPtr<RegisterID> parentScope = emitGetParentScope(newTemporary(), scopeRegister()); 1369 emitMove(scopeRegister(), parentScope.get()); 1374 1370 stackEntry.m_scope->deref(); 1375 1371 } … … 1428 1424 // the assumption that the scope's register index is constant even 1429 1425 // though the value in that register will change on each loop iteration. 1430 RefPtr<RegisterID> parentScope = emitGetParentScope(newTemporary(), loopScope);1426 RefPtr<RegisterID> parentScope = emitGetParentScope(newTemporary(), scopeRegister()); 1431 1427 emitMove(scopeRegister(), parentScope.get()); 1432 1428 … … 1577 1573 ResolveType BytecodeGenerator::resolveType() 1578 1574 { 1579 for (unsigned i = m_symbolTableStack.size(); i--; ) { 1580 if (m_symbolTableStack[i].m_isWithOrCatch) 1581 return Dynamic; 1582 } 1583 1575 if (m_localScopeDepth) 1576 return Dynamic; 1584 1577 if (m_symbolTable && m_symbolTable->usesNonStrictEval()) 1585 1578 return GlobalPropertyWithVarInjectionChecks; … … 1640 1633 instructions().append(addConstant(variable.ident())); 1641 1634 instructions().append(resolveType()); 1642 instructions().append( localScopeDepth());1635 instructions().append(currentScopeDepth()); 1643 1636 instructions().append(0); 1644 1637 return dst; … … 1674 1667 instructions().append(addConstant(variable.ident())); 1675 1668 instructions().append(ResolveModeAndType(resolveMode, variable.offset().isScope() ? LocalClosureVar : resolveType()).operand()); 1676 instructions().append( localScopeDepth());1669 instructions().append(currentScopeDepth()); 1677 1670 instructions().append(variable.offset().isScope() ? variable.offset().scopeOffset().offset() : 0); 1678 1671 instructions().append(profile); … … 1714 1707 ASSERT(resolveType() != LocalClosureVar); 1715 1708 instructions().append(ResolveModeAndType(resolveMode, resolveType()).operand()); 1716 instructions().append( localScopeDepth());1709 instructions().append(currentScopeDepth()); 1717 1710 } 1718 1711 instructions().append(!!offset ? offset.offset() : 0); … … 2482 2475 RegisterID* BytecodeGenerator::emitPushWithScope(RegisterID* dst, RegisterID* scope) 2483 2476 { 2484 pushScopedControlFlowContext(); 2477 ControlFlowContext context; 2478 context.isFinallyBlock = false; 2479 m_scopeContextStack.append(context); 2480 m_localScopeDepth++; 2485 2481 2486 2482 RegisterID* result = emitUnaryOp(op_push_with_scope, dst, scope); … … 2497 2493 } 2498 2494 2499 void BytecodeGenerator::emitPopScope(RegisterID* dst, RegisterID* scope)2500 { 2501 RefPtr<RegisterID> parentScope = emitGetParentScope(newTemporary(), scope);2502 emitMove(dst, parentScope.get());2503 } 2504 2505 void BytecodeGenerator::emitPopWithOrCatchScope(RegisterID* srcDst) 2506 { 2507 emitPopScope(srcDst, srcDst);2508 popScopedControlFlowContext();2495 void BytecodeGenerator::emitPopScope(RegisterID* srcDst) 2496 { 2497 ASSERT(m_scopeContextStack.size()); 2498 ASSERT(!m_scopeContextStack.last().isFinallyBlock); 2499 2500 RefPtr<RegisterID> parentScope = emitGetParentScope(newTemporary(), srcDst); 2501 emitMove(srcDst, parentScope.get()); 2502 2503 m_scopeContextStack.removeLast(); 2504 m_localScopeDepth--; 2509 2505 SymbolTableStackEntry stackEntry = m_symbolTableStack.takeLast(); 2510 2506 RELEASE_ASSERT(stackEntry.m_isWithOrCatch); … … 2820 2816 void BytecodeGenerator::emitPopScopes(RegisterID* scope, int targetScopeDepth) 2821 2817 { 2822 ASSERT( labelScopeDepth() - targetScopeDepth >= 0);2823 2824 size_t scopeDelta = labelScopeDepth() - targetScopeDepth;2818 ASSERT(scopeDepth() - targetScopeDepth >= 0); 2819 2820 size_t scopeDelta = scopeDepth() - targetScopeDepth; 2825 2821 ASSERT(scopeDelta <= m_scopeContextStack.size()); 2826 2822 if (!scopeDelta) … … 2881 2877 int BytecodeGenerator::calculateTargetScopeDepthForExceptionHandler() const 2882 2878 { 2883 int depth = localScopeDepth(); 2879 int depth = m_localScopeDepth; 2880 2881 for (unsigned i = m_symbolTableStack.size(); i--; ) { 2882 RegisterID* scope = m_symbolTableStack[i].m_scope; 2883 if (scope) 2884 depth++; 2885 } 2884 2886 2885 2887 // Currently, we're maintaing compatibility with how things are done and letting the exception handling 2886 // code take into consideration the base activation of the function. There is no reason we shouldn't 2888 // code take into consideration the base activation of the function. There is no reason we shouldn't 2887 2889 // be able to calculate the exact depth here and let the exception handler not worry if there is a base 2888 2890 // activation or not. … … 2894 2896 } 2895 2897 2896 int BytecodeGenerator::localScopeDepth() const 2897 { 2898 return m_localScopeDepth; 2899 } 2900 2901 int BytecodeGenerator::labelScopeDepth() const 2902 { 2903 return localScopeDepth() + m_finallyDepth; 2898 int BytecodeGenerator::currentScopeDepth() const 2899 { 2900 // This is the current number of JSScope descendents that would be allocated 2901 // in this function/program if this code were running. 2902 int depth = 0; 2903 for (unsigned i = m_symbolTableStack.size(); i--; ) { 2904 if (m_symbolTableStack[i].m_scope || m_symbolTableStack[i].m_isWithOrCatch) 2905 depth++; 2906 } 2907 return depth; 2904 2908 } 2905 2909 … … 2927 2931 } 2928 2932 2929 void BytecodeGenerator:: pushScopedControlFlowContext()2933 void BytecodeGenerator::emitPushCatchScope(RegisterID* dst, const Identifier& property, RegisterID* value, unsigned attributes) 2930 2934 { 2931 2935 ControlFlowContext context; … … 2933 2937 m_scopeContextStack.append(context); 2934 2938 m_localScopeDepth++; 2935 }2936 2937 void BytecodeGenerator::popScopedControlFlowContext()2938 {2939 ASSERT(m_scopeContextStack.size());2940 ASSERT(!m_scopeContextStack.last().isFinallyBlock);2941 m_scopeContextStack.removeLast();2942 m_localScopeDepth--;2943 }2944 2945 void BytecodeGenerator::emitPushCatchScope(RegisterID* dst, const Identifier& property, RegisterID* value, unsigned attributes)2946 {2947 pushScopedControlFlowContext();2948 2939 2949 2940 emitOpcode(op_push_name_scope); -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r186996 r186997 586 586 void emitGetScope(); 587 587 RegisterID* emitPushWithScope(RegisterID* dst, RegisterID* scope); 588 void emitPopScope(RegisterID* dst, RegisterID* scope); 589 void emitPopWithOrCatchScope(RegisterID* srcDst); 588 void emitPopScope(RegisterID* srcDst); 590 589 RegisterID* emitGetParentScope(RegisterID* dst, RegisterID* scope); 591 590 592 591 void emitDebugHook(DebugHookID, unsigned line, unsigned charOffset, unsigned lineStart); 593 592 593 int scopeDepth() { return m_localScopeDepth + m_finallyDepth; } 594 594 bool hasFinaliser() { return m_finallyDepth != 0; } 595 595 … … 625 625 void popLexicalScope(VariableEnvironmentNode*); 626 626 void prepareLexicalScopeForNextForLoopIteration(VariableEnvironmentNode*, RegisterID* loopSymbolTable); 627 int labelScopeDepth() const;628 627 629 628 private: … … 763 762 764 763 int calculateTargetScopeDepthForExceptionHandler() const; 765 int localScopeDepth() const; 766 void pushScopedControlFlowContext(); 767 void popScopedControlFlowContext(); 764 int currentScopeDepth() const; 768 765 769 766 Vector<ControlFlowContext, 0, UnsafeVectorOverflow> m_scopeContextStack; -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r186996 r186997 2628 2628 ASSERT(scope); 2629 2629 2630 if (generator. labelScopeDepth() != scope->scopeDepth())2630 if (generator.scopeDepth() != scope->scopeDepth()) 2631 2631 return 0; 2632 2632 … … 2657 2657 ASSERT(scope); 2658 2658 2659 if (generator. labelScopeDepth() != scope->scopeDepth())2659 if (generator.scopeDepth() != scope->scopeDepth()) 2660 2660 return 0; 2661 2661 … … 2691 2691 generator.emitTypeProfilerExpressionInfo(divotStart(), divotEnd()); 2692 2692 } 2693 if (generator. labelScopeDepth()) {2693 if (generator.scopeDepth()) { 2694 2694 returnRegister = generator.emitMove(generator.newTemporary(), returnRegister.get()); 2695 2695 generator.emitPopScopes(generator.scopeRegister(), 0); … … 2715 2715 generator.emitPushWithScope(generator.scopeRegister(), scope.get()); 2716 2716 generator.emitNode(dst, m_statement); 2717 generator.emitPop WithOrCatchScope(generator.scopeRegister());2717 generator.emitPopScope(generator.scopeRegister()); 2718 2718 } 2719 2719 … … 2968 2968 generator.emitProfileControlFlow(m_tryBlock->endOffset() + 1); 2969 2969 generator.emitNode(dst, m_catchBlock); 2970 generator.emitPop WithOrCatchScope(generator.scopeRegister());2970 generator.emitPopScope(generator.scopeRegister()); 2971 2971 generator.emitLabel(catchEndLabel.get()); 2972 2972 }
Note:
See TracChangeset
for help on using the changeset viewer.