Changeset 186997 in webkit


Ignore:
Timestamp:
Jul 18, 2015, 2:21:48 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r186996.
https://bugs.webkit.org/show_bug.cgi?id=147070

Broke JSC tests (Requested by smfr on #webkit).

Reverted changeset:

"lexical scoping is broken with respect to "break" and
"continue""
https://bugs.webkit.org/show_bug.cgi?id=147063
http://trac.webkit.org/changeset/186996

Location:
trunk/Source/JavaScriptCore
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r186996 r186997  
     12015-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
    1152015-07-18  Saam barati  <saambarati1@gmail.com>
    216
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r186996 r186997  
    523523    }
    524524
    525     if (m_lexicalEnvironmentRegister)
    526         pushScopedControlFlowContext();
    527525    m_symbolTableStack.append(SymbolTableStackEntry{ Strong<SymbolTable>(*m_vm, m_symbolTable), m_lexicalEnvironmentRegister, false, symbolTableConstantIndex });
    528526    m_TDZStack.append(std::make_pair(*parentScopeTDZVariables, false));
     
    630628
    631629    // 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.
    633631    m_labelScopes.append(scope);
    634632    return LabelScopePtr(m_labelScopes, m_labelScopes.size() - 1);
     
    12131211    emitOpcode(op_profile_type);
    12141212    instructions().append(registerToProfile->index());
    1215     instructions().append(localScopeDepth());
     1213    instructions().append(currentScopeDepth());
    12161214    instructions().append(flag);
    12171215    instructions().append(identifier ? addConstant(*identifier) : 0);
     
    13211319
    13221320        emitMove(scopeRegister(), newScope);
    1323 
    1324         pushScopedControlFlowContext();
    13251321    }
    13261322
     
    13701366    if (hasCapturedVariables) {
    13711367        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());
    13741370        stackEntry.m_scope->deref();
    13751371    }
     
    14281424    // the assumption that the scope's register index is constant even
    14291425    // 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());
    14311427    emitMove(scopeRegister(), parentScope.get());
    14321428
     
    15771573ResolveType BytecodeGenerator::resolveType()
    15781574{
    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;
    15841577    if (m_symbolTable && m_symbolTable->usesNonStrictEval())
    15851578        return GlobalPropertyWithVarInjectionChecks;
     
    16401633        instructions().append(addConstant(variable.ident()));
    16411634        instructions().append(resolveType());
    1642         instructions().append(localScopeDepth());
     1635        instructions().append(currentScopeDepth());
    16431636        instructions().append(0);
    16441637        return dst;
     
    16741667        instructions().append(addConstant(variable.ident()));
    16751668        instructions().append(ResolveModeAndType(resolveMode, variable.offset().isScope() ? LocalClosureVar : resolveType()).operand());
    1676         instructions().append(localScopeDepth());
     1669        instructions().append(currentScopeDepth());
    16771670        instructions().append(variable.offset().isScope() ? variable.offset().scopeOffset().offset() : 0);
    16781671        instructions().append(profile);
     
    17141707            ASSERT(resolveType() != LocalClosureVar);
    17151708            instructions().append(ResolveModeAndType(resolveMode, resolveType()).operand());
    1716             instructions().append(localScopeDepth());
     1709            instructions().append(currentScopeDepth());
    17171710        }
    17181711        instructions().append(!!offset ? offset.offset() : 0);
     
    24822475RegisterID* BytecodeGenerator::emitPushWithScope(RegisterID* dst, RegisterID* scope)
    24832476{
    2484     pushScopedControlFlowContext();
     2477    ControlFlowContext context;
     2478    context.isFinallyBlock = false;
     2479    m_scopeContextStack.append(context);
     2480    m_localScopeDepth++;
    24852481
    24862482    RegisterID* result = emitUnaryOp(op_push_with_scope, dst, scope);
     
    24972493}
    24982494
    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();
     2495void 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--;
    25092505    SymbolTableStackEntry stackEntry = m_symbolTableStack.takeLast();
    25102506    RELEASE_ASSERT(stackEntry.m_isWithOrCatch);
     
    28202816void BytecodeGenerator::emitPopScopes(RegisterID* scope, int targetScopeDepth)
    28212817{
    2822     ASSERT(labelScopeDepth() - targetScopeDepth >= 0);
    2823 
    2824     size_t scopeDelta = labelScopeDepth() - targetScopeDepth;
     2818    ASSERT(scopeDepth() - targetScopeDepth >= 0);
     2819
     2820    size_t scopeDelta = scopeDepth() - targetScopeDepth;
    28252821    ASSERT(scopeDelta <= m_scopeContextStack.size());
    28262822    if (!scopeDelta)
     
    28812877int BytecodeGenerator::calculateTargetScopeDepthForExceptionHandler() const
    28822878{
    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    }
    28842886
    28852887    // 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 
    28872889    // be able to calculate the exact depth here and let the exception handler not worry if there is a base
    28882890    // activation or not.
     
    28942896}
    28952897
    2896 int BytecodeGenerator::localScopeDepth() const
    2897 {
    2898     return m_localScopeDepth;
    2899 }
    2900 
    2901 int BytecodeGenerator::labelScopeDepth() const
    2902 {
    2903     return localScopeDepth() + m_finallyDepth;
     2898int 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;
    29042908}
    29052909
     
    29272931}
    29282932
    2929 void BytecodeGenerator::pushScopedControlFlowContext()
     2933void BytecodeGenerator::emitPushCatchScope(RegisterID* dst, const Identifier& property, RegisterID* value, unsigned attributes)
    29302934{
    29312935    ControlFlowContext context;
     
    29332937    m_scopeContextStack.append(context);
    29342938    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();
    29482939
    29492940    emitOpcode(op_push_name_scope);
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r186996 r186997  
    586586        void emitGetScope();
    587587        RegisterID* emitPushWithScope(RegisterID* dst, RegisterID* scope);
    588         void emitPopScope(RegisterID* dst, RegisterID* scope);
    589         void emitPopWithOrCatchScope(RegisterID* srcDst);
     588        void emitPopScope(RegisterID* srcDst);
    590589        RegisterID* emitGetParentScope(RegisterID* dst, RegisterID* scope);
    591590
    592591        void emitDebugHook(DebugHookID, unsigned line, unsigned charOffset, unsigned lineStart);
    593592
     593        int scopeDepth() { return m_localScopeDepth + m_finallyDepth; }
    594594        bool hasFinaliser() { return m_finallyDepth != 0; }
    595595
     
    625625        void popLexicalScope(VariableEnvironmentNode*);
    626626        void prepareLexicalScopeForNextForLoopIteration(VariableEnvironmentNode*, RegisterID* loopSymbolTable);
    627         int labelScopeDepth() const;
    628627
    629628    private:
     
    763762
    764763        int calculateTargetScopeDepthForExceptionHandler() const;
    765         int localScopeDepth() const;
    766         void pushScopedControlFlowContext();
    767         void popScopedControlFlowContext();
     764        int currentScopeDepth() const;
    768765
    769766        Vector<ControlFlowContext, 0, UnsafeVectorOverflow> m_scopeContextStack;
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r186996 r186997  
    26282628    ASSERT(scope);
    26292629
    2630     if (generator.labelScopeDepth() != scope->scopeDepth())
     2630    if (generator.scopeDepth() != scope->scopeDepth())
    26312631        return 0;
    26322632
     
    26572657    ASSERT(scope);
    26582658
    2659     if (generator.labelScopeDepth() != scope->scopeDepth())
     2659    if (generator.scopeDepth() != scope->scopeDepth())
    26602660        return 0;
    26612661
     
    26912691        generator.emitTypeProfilerExpressionInfo(divotStart(), divotEnd());
    26922692    }
    2693     if (generator.labelScopeDepth()) {
     2693    if (generator.scopeDepth()) {
    26942694        returnRegister = generator.emitMove(generator.newTemporary(), returnRegister.get());
    26952695        generator.emitPopScopes(generator.scopeRegister(), 0);
     
    27152715    generator.emitPushWithScope(generator.scopeRegister(), scope.get());
    27162716    generator.emitNode(dst, m_statement);
    2717     generator.emitPopWithOrCatchScope(generator.scopeRegister());
     2717    generator.emitPopScope(generator.scopeRegister());
    27182718}
    27192719
     
    29682968        generator.emitProfileControlFlow(m_tryBlock->endOffset() + 1);
    29692969        generator.emitNode(dst, m_catchBlock);
    2970         generator.emitPopWithOrCatchScope(generator.scopeRegister());
     2970        generator.emitPopScope(generator.scopeRegister());
    29712971        generator.emitLabel(catchEndLabel.get());
    29722972    }
Note: See TracChangeset for help on using the changeset viewer.