Ignore:
Timestamp:
May 7, 2012, 4:35:52 PM (13 years ago)
Author:
[email protected]
Message:

2012-05-07 Oliver Hunt <[email protected]>

Rolling out r110287

RS=Filip Pizlo

r110287 was meant to be refactoring only, but changed behavior
enough to break some websites, including qq.com.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r113270 r116372  
    6363
    6464    m_functionCache = source.provider()->cache();
    65     ScopeFlags scopeFlags = NoScopeFlags;
     65    ScopeRef scope = pushScope();
     66    if (parserMode == JSParseFunctionCode)
     67        scope->setIsFunction();
    6668    if (strictness == JSParseStrict)
    67         scopeFlags |= StrictModeFlag;
    68     if (parserMode == JSParseFunctionCode)
    69         scopeFlags |= FunctionModeFlag;
    70     ScopeRef scope = pushScope(scopeFlags);
     69        scope->setStrictMode();
    7170    if (parameters) {
    7271        for (unsigned i = 0; i < parameters->size(); i++)
     
    9897    IdentifierSet capturedVariables;
    9998    scope->getCapturedVariables(capturedVariables);
    100     ScopeFlags scopeFlags = scope->modeFlags() | scope->usesFlags();
     99    CodeFeatures features = context.features();
     100    if (scope->strictMode())
     101        features |= StrictModeFeature;
     102    if (scope->shadowsArguments())
     103        features |= ShadowsArgumentsFeature;
    101104    unsigned functionCacheSize = m_functionCache ? m_functionCache->byteSize() : 0;
    102105    if (functionCacheSize != oldFunctionCacheSize)
    103106        m_lexer->sourceProvider()->notifyCacheSizeChanged(functionCacheSize - oldFunctionCacheSize);
    104107
    105     didFinishParsing(sourceElements, context.varDeclarations(), context.funcDeclarations(), scopeFlags,
     108    didFinishParsing(sourceElements, context.varDeclarations(), context.funcDeclarations(), features,
    106109                     m_lastLine, context.numConstants(), capturedVariables);
    107110
     
    111114template <typename LexerType>
    112115void Parser<LexerType>::didFinishParsing(SourceElements* sourceElements, ParserArenaData<DeclarationStacks::VarStack>* varStack,
    113                               ParserArenaData<DeclarationStacks::FunctionStack>* funcStack, ScopeFlags scopeFlags, int lastLine, int numConstants, IdentifierSet& capturedVars)
     116                              ParserArenaData<DeclarationStacks::FunctionStack>* funcStack, CodeFeatures features, int lastLine, int numConstants, IdentifierSet& capturedVars)
    114117{
    115118    m_sourceElements = sourceElements;
     
    117120    m_funcDeclarations = funcStack;
    118121    m_capturedVariables.swap(capturedVars);
    119     m_scopeFlags = scopeFlags;
     122    m_features = features;
    120123    m_lastLine = lastLine;
    121124    m_numConstants = numConstants;
     
    145148                // "use strict" must be the exact literal without escape sequences or line continuation.
    146149                if (!hasSetStrict && directiveLiteralLength == lengthOfUseStrictLiteral && m_globalData->propertyNames->useStrictIdentifier == *directive) {
    147                     currentScope()->setFlags(StrictModeFlag);
     150                    setStrictMode();
    148151                    hasSetStrict = true;
    149152                    failIfFalse(isValidStrictMode());
     
    253256        bool hasInitializer = match(EQUAL);
    254257        failIfFalseIfStrictWithNameAndMessage(declareVariable(name), "Cannot declare a variable named", name->impl(), "in strict mode.");
    255         if (m_globalData->propertyNames->arguments == *name)
    256             currentScope()->setFlags(UsesArgumentsFlag);
    257258        context.addVar(name, (hasInitializer || (!m_allowsIn && match(INTOKEN))) ? DeclarationStacks::HasInitializer : 0);
    258259        if (hasInitializer) {
     
    289290        bool hasInitializer = match(EQUAL);
    290291        declareVariable(name);
    291         if (m_globalData->propertyNames->arguments == *name)
    292             currentScope()->setFlags(UsesArgumentsFlag);
    293292        context.addVar(name, DeclarationStacks::IsConstant | (hasInitializer ? DeclarationStacks::HasInitializer : 0));
    294293        TreeExpression initializer = 0;
     
    513512    ASSERT(match(WITH));
    514513    failIfTrueWithMessage(strictMode(), "'with' statements are not valid in strict mode");
    515     currentScope()->setFlags(UsesWithFlag);
     514    currentScope()->setNeedsFullActivation();
    516515    int startLine = tokenLine();
    517516    next();
     
    528527    failIfFalse(statement);
    529528   
    530     currentScope()->setFlags(UsesWithFlag);
    531529    return context.createWithStatement(m_lexer->lastLineNumber(), expr, statement, start, end, startLine, endLine);
    532530}
     
    617615   
    618616    if (match(CATCH)) {
    619         currentScope()->setFlags(UsesCatchFlag);
     617        currentScope()->setNeedsFullActivation();
    620618        next();
    621619        consumeOrFail(OPENPAREN);
     
    623621        ident = m_token.m_data.ident;
    624622        next();
    625         AutoPopScopeRef catchScope(this, pushScope(currentScope()->modeFlags()));
     623        AutoPopScopeRef catchScope(this, pushScope());
    626624        failIfFalseIfStrictWithNameAndMessage(declareVariable(ident), "Cannot declare a variable named", ident->impl(), "in strict mode");
    627         currentScope()->setFlags(BlockScopeFlag | UsesCatchFlag);
     625        catchScope->preventNewDecls();
    628626        consumeOrFail(CLOSEPAREN);
    629627        matchOrFail(OPENBRACE);
     
    762760{
    763761    if (match(CLOSEBRACE))
    764         return context.createFunctionBody(m_lexer->lastLineNumber(), currentScope()->modeFlags());
     762        return context.createFunctionBody(m_lexer->lastLineNumber(), strictMode());
    765763    DepthManager statementDepth(&m_statementDepth);
    766764    m_statementDepth = 0;
     
    773771template <FunctionRequirements requirements, bool nameIsInContainingScope, class TreeBuilder> bool Parser<LexerType>::parseFunctionInfo(TreeBuilder& context, const Identifier*& name, TreeFormalParameterList& parameters, TreeFunctionBody& body, int& openBracePos, int& closeBracePos, int& bodyStartLine)
    774772{
    775     AutoPopScopeRef functionScope(this, pushScope(currentScope()->modeFlags() | FunctionModeFlag));
     773    AutoPopScopeRef functionScope(this, pushScope());
     774    functionScope->setIsFunction();
    776775    if (match(IDENT)) {
    777776        name = m_token.m_data.ident;
     
    795794    if (const SourceProviderCacheItem* cachedInfo = TreeBuilder::CanUseFunctionCache ? findCachedFunctionInfo(openBracePos) : 0) {
    796795        // If we're in a strict context, the cached function info must say it was strict too.
    797         ASSERT(!strictMode() || (cachedInfo->scopeFlags & StrictModeFlag));
    798         body = context.createFunctionBody(m_lexer->lastLineNumber(), cachedInfo->scopeFlags);
     796        ASSERT(!strictMode() || cachedInfo->strictMode);
     797        body = context.createFunctionBody(m_lexer->lastLineNumber(), cachedInfo->strictMode);
    799798       
    800799        functionScope->restoreFunctionInfo(cachedInfo);
     
    856855    failIfFalse(name);
    857856    failIfFalseIfStrict(declareVariable(name));
    858     if (*name == m_globalData->propertyNames->arguments)
    859         currentScope()->setFlags(UsesArgumentsFlag);
    860857    return context.createFuncDeclStatement(m_lexer->lastLineNumber(), name, body, parameters, openBracePos, closeBracePos, bodyStartLine, m_lastLine);
    861858}
     
    14171414    case THISTOKEN: {
    14181415        next();
    1419         currentScope()->setFlags(UsesThisFlag);
    14201416        return context.thisExpr(m_lexer->lastLineNumber());
    14211417    }
     
    14241420        const Identifier* ident = m_token.m_data.ident;
    14251421        next();
    1426         if (m_globalData->propertyNames->eval == *ident)
    1427             currentScope()->setFlags(UsesEvalFlag);
    1428         else if (m_globalData->propertyNames->arguments == *ident)
    1429             currentScope()->setFlags(UsesArgumentsFlag);
    1430         currentScope()->useVariable(ident);
     1422        currentScope()->useVariable(ident, m_globalData->propertyNames->eval == *ident);
    14311423        m_lastIdentifier = ident;
    14321424        return context.createResolve(m_lexer->lastLineNumber(), ident, start);
Note: See TracChangeset for help on using the changeset viewer.