Ignore:
Timestamp:
Feb 16, 2011, 11:31:16 AM (14 years ago)
Author:
[email protected]
Message:

2011-02-16 Oliver Hunt <[email protected]>

Reviewed by Geoff Garen.

Incorrect handling of global writes in dynamic contexts
https://bugs.webkit.org/show_bug.cgi?id=49383

Add a few tests to ensure that global writes are actually
allowed inside dynamic scopes.

  • fast/js/basic-strict-mode-expected.txt:
  • fast/js/script-tests/basic-strict-mode.js:

2011-02-16 Oliver Hunt <[email protected]>

Reviewed by Geoff Garen.

Incorrect handling of global writes in dynamic contexts
https://bugs.webkit.org/show_bug.cgi?id=49383

  • interpreter/Interpreter.cpp: (JSC::Interpreter::privateExecute): Can't use the existing callframe to return an uncaught exception as by definition that callframe has already been torn down.
  • parser/ASTBuilder.h: (JSC::ASTBuilder::ASTBuilder): (JSC::ASTBuilder::varDeclarations): (JSC::ASTBuilder::funcDeclarations): (JSC::ASTBuilder::features): (JSC::ASTBuilder::numConstants): (JSC::ASTBuilder::createFuncDeclStatement): (JSC::ASTBuilder::addVar): (JSC::ASTBuilder::incConstants): (JSC::ASTBuilder::usesThis): (JSC::ASTBuilder::usesCatch): (JSC::ASTBuilder::usesClosures): (JSC::ASTBuilder::usesArguments): (JSC::ASTBuilder::usesAssignment): (JSC::ASTBuilder::usesWith): (JSC::ASTBuilder::usesEval): Don't need a vector of scopes in the ASTBuilder
  • runtime/Operations.h: (JSC::resolveBase): In strict mode the optimisation that we use to skip a lookup on the global object is incorrect and lead to us always disallowing global writes when we needed to do a dynamic slot lookup. Now the strict mode path actually checks for the property.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r76177 r78727  
    7777        : m_globalData(globalData)
    7878        , m_lexer(lexer)
     79        , m_scope(globalData)
    7980        , m_evalCount(0)
    8081    {
    81         m_scopes.append(Scope(globalData));
    8282    }
    8383   
     
    116116    JSC::SourceElements* createSourceElements() { return new (m_globalData) JSC::SourceElements(m_globalData); }
    117117
    118     ParserArenaData<DeclarationStacks::VarStack>* varDeclarations() { return m_scopes.last().m_varDeclarations; }
    119     ParserArenaData<DeclarationStacks::FunctionStack>* funcDeclarations() { return m_scopes.last().m_funcDeclarations; }
    120     int features() const { return m_scopes.last().m_features; }
    121     int numConstants() const { return m_scopes.last().m_numConstants; }
     118    ParserArenaData<DeclarationStacks::VarStack>* varDeclarations() { return m_scope.m_varDeclarations; }
     119    ParserArenaData<DeclarationStacks::FunctionStack>* funcDeclarations() { return m_scope.m_funcDeclarations; }
     120    int features() const { return m_scope.m_features; }
     121    int numConstants() const { return m_scope.m_numConstants; }
    122122
    123123    void appendToComma(CommaNode* commaNode, ExpressionNode* expr) { commaNode->append(expr); }
     
    301301        if (*name == m_globalData->propertyNames->arguments)
    302302            usesArguments();
    303         m_scopes.last().m_funcDeclarations->data.append(decl->body());
     303        m_scope.m_funcDeclarations->data.append(decl->body());
    304304        body->setLoc(bodyStartLine, bodyEndLine);
    305305        return decl;
     
    495495        if (m_globalData->propertyNames->arguments == *ident)
    496496            usesArguments();
    497         m_scopes.last().m_varDeclarations->data.append(std::make_pair(ident, attrs));
     497        m_scope.m_varDeclarations->data.append(std::make_pair(ident, attrs));
    498498    }
    499499
     
    612612    }
    613613
    614     void incConstants() { m_scopes.last().m_numConstants++; }
    615     void usesThis() { m_scopes.last().m_features |= ThisFeature; }
    616     void usesCatch() { m_scopes.last().m_features |= CatchFeature; }
    617     void usesClosures() { m_scopes.last().m_features |= ClosureFeature; }
    618     void usesArguments() { m_scopes.last().m_features |= ArgumentsFeature; }
    619     void usesAssignment() { m_scopes.last().m_features |= AssignFeature; }
    620     void usesWith() { m_scopes.last().m_features |= WithFeature; }
     614    void incConstants() { m_scope.m_numConstants++; }
     615    void usesThis() { m_scope.m_features |= ThisFeature; }
     616    void usesCatch() { m_scope.m_features |= CatchFeature; }
     617    void usesClosures() { m_scope.m_features |= ClosureFeature; }
     618    void usesArguments() { m_scope.m_features |= ArgumentsFeature; }
     619    void usesAssignment() { m_scope.m_features |= AssignFeature; }
     620    void usesWith() { m_scope.m_features |= WithFeature; }
    621621    void usesEval()
    622622    {
    623623        m_evalCount++;
    624         m_scopes.last().m_features |= EvalFeature;
     624        m_scope.m_features |= EvalFeature;
    625625    }
    626626    ExpressionNode* createNumber(double d)
     
    631631    JSGlobalData* m_globalData;
    632632    Lexer* m_lexer;
    633     Vector<Scope> m_scopes;
     633    Scope m_scope;
    634634    Vector<BinaryOperand, 10> m_binaryOperandStack;
    635635    Vector<AssignmentInfo, 10> m_assignmentInfoStack;
Note: See TracChangeset for help on using the changeset viewer.