Ignore:
Timestamp:
Oct 15, 2018, 11:42:44 AM (7 years ago)
Author:
[email protected]
Message:

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

"this regressed JetStream 2 by 6% on iOS" (Requested by
saamyjoon on #webkit).

Reverted changeset:

"[JSC] JSC should have "parseFunction" to optimize Function
constructor"
https://bugs.webkit.org/show_bug.cgi?id=190340
https://trac.webkit.org/changeset/237054

File:
1 edited

Legend:

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

    r237096 r237128  
    860860};
    861861
    862 enum class ArgumentType { Normal, Spread };
    863 enum class ParsingContext { Program, FunctionConstructor, Eval };
     862enum class ArgumentType {
     863    Normal,
     864    Spread
     865};
    864866
    865867template <typename LexerType>
     
    873875
    874876    template <class ParsedNode>
    875     std::unique_ptr<ParsedNode> parse(ParserError&, const Identifier&, SourceParseMode, ParsingContext, std::optional<int> functionConstructorParametersEndPosition = std::nullopt);
     877    std::unique_ptr<ParsedNode> parse(ParserError&, const Identifier&, SourceParseMode);
    876878
    877879    JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); }
     
    13111313
    13121314    Parser();
    1313 
    1314     String parseInner(const Identifier&, SourceParseMode, ParsingContext, std::optional<int> functionConstructorParametersEndPosition = std::nullopt);
     1315    String parseInner(const Identifier&, SourceParseMode);
    13151316
    13161317    void didFinishParsing(SourceElements*, DeclarationStacks::FunctionStack&&, VariableEnvironment&, UniquedStringImplPtrSet&&, CodeFeatures, int);
     
    15241525    template <class TreeBuilder> TreeSourceElements parseAsyncFunctionSourceElements(TreeBuilder&, SourceParseMode, bool isArrowFunctionBodyExpression, SourceElementsMode);
    15251526    template <class TreeBuilder> TreeSourceElements parseAsyncGeneratorFunctionSourceElements(TreeBuilder&, SourceParseMode, bool isArrowFunctionBodyExpression, SourceElementsMode);
    1526     template <class TreeBuilder> TreeSourceElements parseSingleFunction(TreeBuilder&, std::optional<int> functionConstructorParametersEndPosition);
    15271527    template <class TreeBuilder> TreeStatement parseStatementListItem(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength);
    15281528    template <class TreeBuilder> TreeStatement parseStatement(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength = 0);
    15291529    enum class ExportType { Exported, NotExported };
    15301530    template <class TreeBuilder> TreeStatement parseClassDeclaration(TreeBuilder&, ExportType = ExportType::NotExported, DeclarationDefaultContext = DeclarationDefaultContext::Standard);
    1531     template <class TreeBuilder> TreeStatement parseFunctionDeclaration(TreeBuilder&, ExportType = ExportType::NotExported, DeclarationDefaultContext = DeclarationDefaultContext::Standard, std::optional<int> functionConstructorParametersEndPosition = std::nullopt);
     1531    template <class TreeBuilder> TreeStatement parseFunctionDeclaration(TreeBuilder&, ExportType = ExportType::NotExported, DeclarationDefaultContext = DeclarationDefaultContext::Standard);
    15321532    template <class TreeBuilder> TreeStatement parseFunctionDeclarationStatement(TreeBuilder&, bool isAsync, bool parentAllowsFunctionDeclarationAsStatement);
    1533     template <class TreeBuilder> TreeStatement parseAsyncFunctionDeclaration(TreeBuilder&, ExportType = ExportType::NotExported, DeclarationDefaultContext = DeclarationDefaultContext::Standard, std::optional<int> functionConstructorParametersEndPosition = std::nullopt);
     1533    template <class TreeBuilder> TreeStatement parseAsyncFunctionDeclaration(TreeBuilder&, ExportType = ExportType::NotExported, DeclarationDefaultContext = DeclarationDefaultContext::Standard);
    15341534    template <class TreeBuilder> NEVER_INLINE bool maybeParseAsyncFunctionDeclarationStatement(TreeBuilder& context, TreeStatement& result, bool parentAllowsFunctionDeclarationAsStatement);
    15351535    template <class TreeBuilder> TreeStatement parseVariableDeclaration(TreeBuilder&, DeclarationType, ExportType = ExportType::NotExported);
     
    16001600
    16011601    enum class FunctionDefinitionType { Expression, Declaration, Method };
    1602     template <class TreeBuilder> NEVER_INLINE bool parseFunctionInfo(TreeBuilder&, FunctionNameRequirements, SourceParseMode, bool nameIsInContainingScope, ConstructorKind, SuperBinding, int functionKeywordStart, ParserFunctionInfo<TreeBuilder>&, FunctionDefinitionType, std::optional<int> functionConstructorParametersEndPosition = std::nullopt);
     1602    template <class TreeBuilder> NEVER_INLINE bool parseFunctionInfo(TreeBuilder&, FunctionNameRequirements, SourceParseMode, bool nameIsInContainingScope, ConstructorKind, SuperBinding, int functionKeywordStart, ParserFunctionInfo<TreeBuilder>&, FunctionDefinitionType);
    16031603   
    16041604    ALWAYS_INLINE bool isArrowFunctionParameters();
     
    18481848template <typename LexerType>
    18491849template <class ParsedNode>
    1850 std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, const Identifier& calleeName, SourceParseMode parseMode, ParsingContext parsingContext, std::optional<int> functionConstructorParametersEndPosition)
     1850std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, const Identifier& calleeName, SourceParseMode parseMode)
    18511851{
    18521852    int errLine;
     
    18651865    unsigned startColumn = m_source->startColumn().zeroBasedInt();
    18661866
    1867     String parseError = parseInner(calleeName, parseMode, parsingContext, functionConstructorParametersEndPosition);
     1867    String parseError = parseInner(calleeName, parseMode);
    18681868
    18691869    int lineNumber = m_lexer->lineNumber();
     
    19601960    if (source.provider()->source().is8Bit()) {
    19611961        Parser<Lexer<LChar>> parser(vm, source, builtinMode, strictMode, scriptMode, parseMode, superBinding, defaultConstructorKind, derivedContextType, isEvalNode<ParsedNode>(), evalContextType, debuggerParseData);
    1962         result = parser.parse<ParsedNode>(error, name, parseMode, isEvalNode<ParsedNode>() ? ParsingContext::Eval : ParsingContext::Program);
     1962        result = parser.parse<ParsedNode>(error, name, parseMode);
    19631963        if (positionBeforeLastNewline)
    19641964            *positionBeforeLastNewline = parser.positionBeforeLastNewline();
     
    19731973        ASSERT_WITH_MESSAGE(defaultConstructorKind == ConstructorKind::None, "BuiltinExecutables::createDefaultConstructor should always use a 8-bit string");
    19741974        Parser<Lexer<UChar>> parser(vm, source, builtinMode, strictMode, scriptMode, parseMode, superBinding, defaultConstructorKind, derivedContextType, isEvalNode<ParsedNode>(), evalContextType, debuggerParseData);
    1975         result = parser.parse<ParsedNode>(error, name, parseMode, isEvalNode<ParsedNode>() ? ParsingContext::Eval : ParsingContext::Program);
     1975        result = parser.parse<ParsedNode>(error, name, parseMode);
    19761976        if (positionBeforeLastNewline)
    19771977            *positionBeforeLastNewline = parser.positionBeforeLastNewline();
     
    19871987}
    19881988
    1989 inline std::unique_ptr<ProgramNode> parseFunctionForFunctionConstructor(VM& vm, const SourceCode& source, ParserError& error, JSTextPosition* positionBeforeLastNewline, std::optional<int> functionConstructorParametersEndPosition)
    1990 {
    1991     ASSERT(!source.provider()->source().isNull());
    1992 
    1993     MonotonicTime before;
    1994     if (UNLIKELY(Options::reportParseTimes()))
    1995         before = MonotonicTime::now();
    1996 
    1997     Identifier name;
    1998     bool isEvalNode = false;
    1999     std::unique_ptr<ProgramNode> result;
    2000     if (source.provider()->source().is8Bit()) {
    2001         Parser<Lexer<LChar>> parser(&vm, source, JSParserBuiltinMode::NotBuiltin, JSParserStrictMode::NotStrict, JSParserScriptMode::Classic, SourceParseMode::ProgramMode, SuperBinding::NotNeeded, ConstructorKind::None, DerivedContextType::None, isEvalNode, EvalContextType::None, nullptr);
    2002         result = parser.parse<ProgramNode>(error, name, SourceParseMode::ProgramMode, ParsingContext::FunctionConstructor, functionConstructorParametersEndPosition);
    2003         if (positionBeforeLastNewline)
    2004             *positionBeforeLastNewline = parser.positionBeforeLastNewline();
    2005     } else {
    2006         Parser<Lexer<UChar>> parser(&vm, source, JSParserBuiltinMode::NotBuiltin, JSParserStrictMode::NotStrict, JSParserScriptMode::Classic, SourceParseMode::ProgramMode, SuperBinding::NotNeeded, ConstructorKind::None, DerivedContextType::None, isEvalNode, EvalContextType::None, nullptr);
    2007         result = parser.parse<ProgramNode>(error, name, SourceParseMode::ProgramMode, ParsingContext::FunctionConstructor, functionConstructorParametersEndPosition);
    2008         if (positionBeforeLastNewline)
    2009             *positionBeforeLastNewline = parser.positionBeforeLastNewline();
    2010     }
    2011 
    2012     if (UNLIKELY(Options::reportParseTimes())) {
    2013         MonotonicTime after = MonotonicTime::now();
    2014         ParseHash hash(source);
    2015         dataLogLn(result ? "Parsed #" : "Failed to parse #", hash.hashForCall(), "/#", hash.hashForConstruct(), " in ", (after - before).milliseconds(), " ms.");
    2016     }
    2017 
    2018     return result;
    2019 }
    2020 
    2021 
    20221989} // namespace
Note: See TracChangeset for help on using the changeset viewer.