Ignore:
Timestamp:
Dec 1, 2015, 5:37:19 PM (10 years ago)
Author:
[email protected]
Message:

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

JSC tests for this change are failing on 32 and 64-bit bots
(Requested by ryanhaddad on #webkit).

Reverted changeset:

"[ES6] Implement LLInt/Baseline Support for ES6 Generators and
enable this feature"
https://bugs.webkit.org/show_bug.cgi?id=150792
http://trac.webkit.org/changeset/192914

File:
1 edited

Legend:

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

    r192919 r192935  
    195195Parser<LexerType>::Parser(
    196196    VM* vm, const SourceCode& source, JSParserBuiltinMode builtinMode,
    197     JSParserStrictMode strictMode, SourceParseMode parseMode, SuperBinding superBinding,
     197    JSParserStrictMode strictMode, SourceParseMode parseMode,
    198198    ConstructorKind defaultConstructorKind, ThisTDZMode thisTDZMode)
    199199    : m_vm(vm)
     
    211211    , m_sourceElements(0)
    212212    , m_parsingBuiltin(builtinMode == JSParserBuiltinMode::Builtin)
    213     , m_superBinding(superBinding)
    214213    , m_defaultConstructorKind(defaultConstructorKind)
    215214    , m_thisTDZMode(thisTDZMode)
     
    251250    if (m_lexer->isReparsingFunction()) {
    252251        ParserFunctionInfo<ASTBuilder> functionInfo;
    253         if (parseMode == SourceParseMode::GeneratorBodyMode)
    254             functionInfo.parameters = createGeneratorParameters(context);
    255         else
    256             parseFunctionParameters(context, parseMode, functionInfo);
     252        parseFunctionParameters(context, parseMode, functionInfo);
    257253        m_parameters = functionInfo.parameters;
    258254
     
    278274        else if (isModuleParseMode(parseMode))
    279275            sourceElements = parseModuleSourceElements(context, parseMode);
    280         else {
    281             if (parseMode == SourceParseMode::GeneratorWrapperFunctionMode)
    282                 sourceElements = parseGeneratorFunctionSourceElements(context, CheckForStrictMode);
    283             else
    284                 sourceElements = parseSourceElements(context, CheckForStrictMode);
    285         }
     276        else
     277            sourceElements = parseSourceElements(context, CheckForStrictMode);
    286278    }
    287279
     
    310302    for (auto& entry : capturedVariables)
    311303        varDeclarations.markVariableAsCaptured(entry);
    312 
    313     IdentifierSet usedVariables;
    314     scope->getUsedVariables(usedVariables);
    315     if (parseMode == SourceParseMode::GeneratorWrapperFunctionMode) {
    316         if (usedVariables.contains(m_vm->propertyNames->arguments.impl()))
    317             context.propagateArgumentsUse();
    318     }
    319 
     304   
    320305    CodeFeatures features = context.features();
    321306    if (scope->strictMode())
     
    327312    if (modifiedArguments)
    328313        features |= ModifiedArgumentsFeature;
    329 
    330314    Vector<RefPtr<UniquedStringImpl>> closedVariables;
    331315    if (m_parsingBuiltin) {
     316        IdentifierSet usedVariables;
     317        scope->getUsedVariables(usedVariables);
    332318        // FIXME: This needs to be changed if we want to allow builtins to use lexical declarations.
    333319        for (const auto& variable : usedVariables) {
     
    468454        semanticFail("Exported binding '", uid.get(), "' needs to refer to a top-level declared variable");
    469455    }
    470 
    471     return sourceElements;
    472 }
    473 
    474 template <typename LexerType>
    475 template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseGeneratorFunctionSourceElements(TreeBuilder& context, SourceElementsMode mode)
    476 {
    477     auto sourceElements = context.createSourceElements();
    478 
    479     unsigned functionKeywordStart = tokenStart();
    480     JSTokenLocation startLocation(tokenLocation());
    481     JSTextPosition start = tokenStartPosition();
    482     unsigned startColumn = tokenColumn();
    483     int functionNameStart = m_token.m_location.startOffset;
    484     int parametersStart = m_token.m_location.startOffset;
    485 
    486     ParserFunctionInfo<TreeBuilder> info;
    487     info.name = &m_vm->propertyNames->nullIdentifier;
    488     info.parameters = createGeneratorParameters(context);
    489     info.startOffset = parametersStart;
    490     info.startLine = tokenLine();
    491     info.parameterCount = 4; // generator, state, value, resume mode
    492 
    493     {
    494         AutoPopScopeRef generatorBodyScope(this, pushScope());
    495         generatorBodyScope->setSourceParseMode(SourceParseMode::GeneratorBodyMode);
    496         SyntaxChecker generatorFunctionContext(const_cast<VM*>(m_vm), m_lexer.get());
    497         failIfFalse(parseSourceElements(generatorFunctionContext, mode), "Cannot parse the body of a generator");
    498         popScope(generatorBodyScope, TreeBuilder::NeedsFreeVariableInfo);
    499     }
    500     info.body = context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, tokenColumn(), functionKeywordStart, functionNameStart, parametersStart, strictMode(), ConstructorKind::None, m_superBinding, info.parameterCount, SourceParseMode::GeneratorBodyMode, false);
    501 
    502     info.endLine = tokenLine();
    503     info.endOffset = m_token.m_data.offset;
    504     info.bodyStartColumn = startColumn;
    505 
    506     auto functionExpr = context.createFunctionExpr(startLocation, info);
    507     auto statement = context.createExprStatement(startLocation, functionExpr, start, m_lastTokenEndPosition.line);
    508     context.appendStatement(sourceElements, statement);
    509456
    510457    return sourceElements;
     
    16541601template <class TreeBuilder> TreeFunctionBody Parser<LexerType>::parseFunctionBody(
    16551602    TreeBuilder& context, const JSTokenLocation& startLocation, int startColumn, int functionKeywordStart, int functionNameStart, int parametersStart,
    1656     ConstructorKind constructorKind, SuperBinding superBinding, FunctionBodyType bodyType, unsigned parameterCount, SourceParseMode parseMode)
    1657 {
     1603    ConstructorKind constructorKind, FunctionBodyType bodyType, unsigned parameterCount, SourceParseMode parseMode)
     1604{
     1605    bool isArrowFunction = FunctionBodyType::StandardFunctionBodyBlock != bodyType;
    16581606    bool isArrowFunctionBodyExpression = bodyType == ArrowFunctionBodyExpression;
    16591607    if (!isArrowFunctionBodyExpression) {
     
    16611609        if (match(CLOSEBRACE)) {
    16621610            unsigned endColumn = tokenColumn();
    1663             return context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind, superBinding, parameterCount, parseMode, isArrowFunctionBodyExpression);
     1611            return context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind, parameterCount, parseMode, isArrowFunction, isArrowFunctionBodyExpression);
    16641612        }
    16651613    }
     
    16731621        failIfFalse(parseSourceElements(syntaxChecker, CheckForStrictMode), bodyType == StandardFunctionBodyBlock ? "Cannot parse body of this function" : "Cannot parse body of this arrow function");
    16741622    unsigned endColumn = tokenColumn();
    1675     return context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind, superBinding, parameterCount, parseMode, isArrowFunctionBodyExpression);
     1623    return context.createFunctionMetadata(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind, parameterCount, parseMode, isArrowFunction, isArrowFunctionBodyExpression);
    16761624}
    16771625
     
    16871635    case SourceParseMode::MethodMode:
    16881636        return "method";
    1689     case SourceParseMode::GeneratorBodyMode:
     1637    case SourceParseMode::GeneratorMode:
    16901638        return "generator";
    1691     case SourceParseMode::GeneratorWrapperFunctionMode:
    1692         return "generator function";
    16931639    case SourceParseMode::ArrowFunctionMode:
    16941640        return "arrow function";
     
    17691715
    17701716template <typename LexerType>
    1771 template <class TreeBuilder> typename TreeBuilder::FormalParameterList Parser<LexerType>::createGeneratorParameters(TreeBuilder& context)
    1772 {
    1773     auto parameters = context.createFormalParameterList();
    1774 
    1775     JSTokenLocation location(tokenLocation());
    1776     JSTextPosition position = tokenStartPosition();
    1777 
    1778     // @generator
    1779     declareParameter(&m_vm->propertyNames->generatorPrivateName);
    1780     auto generator = context.createBindingLocation(location, m_vm->propertyNames->generatorPrivateName, position, position, AssignmentContext::DeclarationStatement);
    1781     context.appendParameter(parameters, generator, 0);
    1782 
    1783     // @generatorState
    1784     declareParameter(&m_vm->propertyNames->generatorStatePrivateName);
    1785     auto generatorState = context.createBindingLocation(location, m_vm->propertyNames->generatorStatePrivateName, position, position, AssignmentContext::DeclarationStatement);
    1786     context.appendParameter(parameters, generatorState, 0);
    1787 
    1788     // @generatorValue
    1789     declareParameter(&m_vm->propertyNames->generatorValuePrivateName);
    1790     auto generatorValue = context.createBindingLocation(location, m_vm->propertyNames->generatorValuePrivateName, position, position, AssignmentContext::DeclarationStatement);
    1791     context.appendParameter(parameters, generatorValue, 0);
    1792 
    1793     // @generatorResumeMode
    1794     declareParameter(&m_vm->propertyNames->generatorResumeModePrivateName);
    1795     auto generatorResumeMode = context.createBindingLocation(location, m_vm->propertyNames->generatorResumeModePrivateName, position, position, AssignmentContext::DeclarationStatement);
    1796     context.appendParameter(parameters, generatorResumeMode, 0);
    1797 
    1798     return parameters;
    1799 }
    1800 
    1801 template <typename LexerType>
    18021717template <class TreeBuilder> bool Parser<LexerType>::parseFunctionInfo(TreeBuilder& context, FunctionRequirements requirements, SourceParseMode mode, bool nameIsInContainingScope, ConstructorKind constructorKind, SuperBinding expectedSuperBinding, int functionKeywordStart, ParserFunctionInfo<TreeBuilder>& functionInfo, FunctionDefinitionType functionDefinitionType)
    18031718{
     
    19101825        unsigned currentLineStartOffset = m_token.m_location.lineStartOffset;
    19111826       
     1827        bool isArrowFunction = mode == SourceParseMode::ArrowFunctionMode;
     1828       
    19121829        functionInfo.body = context.createFunctionMetadata(
    19131830            startLocation, endLocation, functionInfo.bodyStartColumn, bodyEndColumn,
    19141831            functionKeywordStart, functionNameStart, parametersStart,
    1915             cachedInfo->strictMode, constructorKind, expectedSuperBinding, cachedInfo->parameterCount, mode, functionBodyType == ArrowFunctionBodyExpression);
     1832            cachedInfo->strictMode, constructorKind, cachedInfo->parameterCount, mode, isArrowFunction, functionBodyType == ArrowFunctionBodyExpression);
    19161833       
    19171834        functionScope->restoreFromSourceProviderCache(cachedInfo);
     
    19271844        functionInfo.endOffset = cachedInfo->endFunctionOffset;
    19281845
    1929         if (mode == SourceParseMode::ArrowFunctionMode)
     1846        if (isArrowFunction)
    19301847            functionBodyType = cachedInfo->isBodyArrowExpression ?  ArrowFunctionBodyExpression : ArrowFunctionBodyBlock;
    19311848        else
     
    19491866    m_lastFunctionName = lastFunctionName;
    19501867    ParserState oldState = saveState();
    1951 
    1952     auto performParsingFunctionBody = [&] {
    1953         return parseFunctionBody(context, startLocation, startColumn, functionKeywordStart, functionNameStart, parametersStart, constructorKind, expectedSuperBinding, functionBodyType, functionInfo.parameterCount, mode);
    1954     };
    1955 
    1956     if (mode == SourceParseMode::GeneratorWrapperFunctionMode) {
    1957         AutoPopScopeRef generatorBodyScope(this, pushScope());
    1958         generatorBodyScope->setSourceParseMode(SourceParseMode::GeneratorBodyMode);
    1959         functionInfo.body = performParsingFunctionBody();
    1960 
    1961         // When a generator has a "use strict" directive, a generator function wrapping it should be strict mode.
    1962         if  (generatorBodyScope->strictMode())
    1963             functionScope->setStrictMode();
    1964 
    1965         semanticFailIfTrue(generatorBodyScope->hasDirectSuper(), "Cannot call super() outside of a class constructor");
    1966         if (generatorBodyScope->needsSuperBinding())
    1967             semanticFailIfTrue(expectedSuperBinding == SuperBinding::NotNeeded, "super can only be used in a method of a derived class");
    1968 
    1969         popScope(generatorBodyScope, TreeBuilder::NeedsFreeVariableInfo);
    1970     } else
    1971         functionInfo.body = performParsingFunctionBody();
     1868   
     1869    functionInfo.body = parseFunctionBody(context, startLocation, startColumn, functionKeywordStart, functionNameStart, parametersStart, constructorKind, functionBodyType, functionInfo.parameterCount, mode);
    19721870   
    19731871    restoreState(oldState);
     
    19751873    context.setEndOffset(functionInfo.body, m_lexer->currentOffset());
    19761874    if (functionScope->strictMode() && functionInfo.name) {
    1977         RELEASE_ASSERT(mode == SourceParseMode::NormalFunctionMode || mode == SourceParseMode::MethodMode || mode == SourceParseMode::ArrowFunctionMode || mode == SourceParseMode::GeneratorBodyMode || mode == SourceParseMode::GeneratorWrapperFunctionMode);
     1875        RELEASE_ASSERT(mode == SourceParseMode::NormalFunctionMode || mode == SourceParseMode::MethodMode || mode == SourceParseMode::ArrowFunctionMode || mode == SourceParseMode::GeneratorMode);
    19781876        semanticFailIfTrue(m_vm->propertyNames->arguments == *functionInfo.name, "'", functionInfo.name->impl(), "' is not a valid function name in strict mode");
    19791877        semanticFailIfTrue(m_vm->propertyNames->eval == *functionInfo.name, "'", functionInfo.name->impl(), "' is not a valid function name in strict mode");
     
    20431941#if ENABLE(ES6_GENERATORS)
    20441942    if (consume(TIMES))
    2045         parseMode = SourceParseMode::GeneratorWrapperFunctionMode;
     1943        parseMode = SourceParseMode::GeneratorMode;
    20461944#endif
    20471945    failIfFalse((parseFunctionInfo(context, FunctionNeedsName, parseMode, true, ConstructorKind::None, SuperBinding::NotNeeded, functionKeywordStart, functionInfo, FunctionDefinitionType::Declaration)), "Cannot parse this function");
     
    21942092            if (isGenerator) {
    21952093                isConstructor = false;
    2196                 parseMode = SourceParseMode::GeneratorWrapperFunctionMode;
     2094                parseMode = SourceParseMode::GeneratorMode;
    21972095                semanticFailIfTrue(*ident == m_vm->propertyNames->prototype, "Cannot declare a generator named 'prototype'");
    21982096                semanticFailIfTrue(*ident == m_vm->propertyNames->constructor, "Cannot declare a generator named 'constructor'");
     
    28602758
    28612759#if ENABLE(ES6_GENERATORS)
    2862     if (match(YIELD) && !isYIELDMaskedAsIDENT(currentScope()->isGenerator()))
     2760    if (match(YIELD))
    28632761        return parseYieldExpression(context);
    28642762#endif
     
    29652863
    29662864    JSTokenLocation location(tokenLocation());
    2967     JSTextPosition divotStart = tokenStartPosition();
    29682865    ASSERT(match(YIELD));
    29692866    SavePoint savePoint = createSavePoint();
     
    29732870
    29742871    bool delegate = consume(TIMES);
    2975     JSTextPosition argumentStart = tokenStartPosition();
    29762872    TreeExpression argument = parseAssignmentExpression(context);
    29772873    if (!argument) {
     
    29802876        return context.createYield(location);
    29812877    }
    2982     return context.createYield(location, argument, delegate, divotStart, argumentStart, lastTokenEndPosition());
     2878    return context.createYield(location, argument, delegate);
    29832879}
    29842880
     
    31723068    unsigned methodStart = tokenStart();
    31733069    ParserFunctionInfo<TreeBuilder> methodInfo;
    3174     SourceParseMode parseMode = isGenerator ? SourceParseMode::GeneratorWrapperFunctionMode : SourceParseMode::MethodMode;
     3070    SourceParseMode parseMode = isGenerator ? SourceParseMode::GeneratorMode : SourceParseMode::MethodMode;
    31753071    failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, parseMode, false, ConstructorKind::None, SuperBinding::NotNeeded, methodStart, methodInfo, FunctionDefinitionType::Method)), "Cannot parse this method");
    31763072    methodInfo.name = methodName;
     
    34253321#if ENABLE(ES6_GENERATORS)
    34263322    if (consume(TIMES))
    3427         parseMode = SourceParseMode::GeneratorWrapperFunctionMode;
     3323        parseMode = SourceParseMode::GeneratorMode;
    34283324#endif
    34293325    failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, parseMode, false, ConstructorKind::None, SuperBinding::NotNeeded, functionKeywordStart, functionInfo, FunctionDefinitionType::Expression)), "Cannot parse function expression");
Note: See TracChangeset for help on using the changeset viewer.