⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 237445 in webkit


Ignore:
Timestamp:
Oct 25, 2018, 9:51:59 PM (8 years ago)
Author:
yusukesuzuki@slowstart.org
Message:

Unreviewed, partial rolling in r237254
​https://bugs.webkit.org/show_bug.cgi?id=190340

We do not use the added function right now to investigate what is the reason of the regression.
If it causes the regression, it seems that Parser.cpp's inlining decision seems culprit.

  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::UnlinkedFunctionExecutable::fromGlobalCode):

  • bytecode/UnlinkedFunctionExecutable.h:
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseInner):
(JSC::Parser<LexerType>::parseSingleFunction):
(JSC::Parser<LexerType>::parseFunctionInfo):
(JSC::Parser<LexerType>::parseFunctionDeclaration):
(JSC::Parser<LexerType>::parseAsyncFunctionDeclaration):

  • parser/Parser.h:

(JSC::Parser<LexerType>::parse):
(JSC::parse):
(JSC::parseFunctionForFunctionConstructor):

  • parser/ParserModes.h:
  • parser/ParserTokens.h:

(JSC::JSTextPosition::JSTextPosition):
(JSC::JSTokenLocation::JSTokenLocation): Deleted.

  • parser/SourceCodeKey.h:

(JSC::SourceCodeKey::SourceCodeKey):
(JSC::SourceCodeKey::operator== const):

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getUnlinkedGlobalCodeBlock):
(JSC::CodeCache::getUnlinkedGlobalFunctionExecutable):

  • runtime/CodeCache.h:
  • runtime/FunctionConstructor.cpp:

(JSC::constructFunctionSkippingEvalEnabledCheck):

  • runtime/FunctionExecutable.cpp:

(JSC::FunctionExecutable::fromGlobalCode):

  • runtime/FunctionExecutable.h:
Location:
trunk/Source/JavaScriptCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r237440 r237445  
     12018-10-25  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
     2
     3        Unreviewed, partial rolling in r237254
     4        https://bugs.webkit.org/show_bug.cgi?id=190340
     5
     6        We do not use the added function right now to investigate what is the reason of the regression.
     7        If it causes the regression, it seems that Parser.cpp's inlining decision seems culprit.
     8
     9        * bytecode/UnlinkedFunctionExecutable.cpp:
     10        (JSC::UnlinkedFunctionExecutable::fromGlobalCode):
     11        * bytecode/UnlinkedFunctionExecutable.h:
     12        * parser/Parser.cpp:
     13        (JSC::Parser<LexerType>::parseInner):
     14        (JSC::Parser<LexerType>::parseSingleFunction):
     15        (JSC::Parser<LexerType>::parseFunctionInfo):
     16        (JSC::Parser<LexerType>::parseFunctionDeclaration):
     17        (JSC::Parser<LexerType>::parseAsyncFunctionDeclaration):
     18        * parser/Parser.h:
     19        (JSC::Parser<LexerType>::parse):
     20        (JSC::parse):
     21        (JSC::parseFunctionForFunctionConstructor):
     22        * parser/ParserModes.h:
     23        * parser/ParserTokens.h:
     24        (JSC::JSTextPosition::JSTextPosition):
     25        (JSC::JSTokenLocation::JSTokenLocation): Deleted.
     26        * parser/SourceCodeKey.h:
     27        (JSC::SourceCodeKey::SourceCodeKey):
     28        (JSC::SourceCodeKey::operator== const):
     29        * runtime/CodeCache.cpp:
     30        (JSC::CodeCache::getUnlinkedGlobalCodeBlock):
     31        (JSC::CodeCache::getUnlinkedGlobalFunctionExecutable):
     32        * runtime/CodeCache.h:
     33        * runtime/FunctionConstructor.cpp:
     34        (JSC::constructFunctionSkippingEvalEnabledCheck):
     35        * runtime/FunctionExecutable.cpp:
     36        (JSC::FunctionExecutable::fromGlobalCode):
     37        * runtime/FunctionExecutable.h:
     38
    1392018-10-25  Brent Fulgham  <bfulgham@apple.com>
    240
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp

    r237299 r237445  
    175175UnlinkedFunctionExecutable* UnlinkedFunctionExecutable::fromGlobalCode(
    176176    const Identifier& name, ExecState& exec, const SourceCode& source,
    177     JSObject*& exception, int overrideLineNumber)
     177    JSObject*& exception, int overrideLineNumber, std::optional<int> functionConstructorParametersEndPosition)
    178178{
    179179    ParserError error;
    … …  
    182182    CodeCache* codeCache = vm.codeCache();
    183183    DebuggerMode debuggerMode = globalObject.hasInteractiveDebugger() ? DebuggerOn : DebuggerOff;
    184     UnlinkedFunctionExecutable* executable = codeCache->getUnlinkedGlobalFunctionExecutable(vm, name, source, debuggerMode, error);
     184    UnlinkedFunctionExecutable* executable = codeCache->getUnlinkedGlobalFunctionExecutable(vm, name, source, debuggerMode, functionConstructorParametersEndPosition, error);
    185185
    186186    if (globalObject.hasDebugger())
  • trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h

    r237299 r237445  
    108108    static UnlinkedFunctionExecutable* fromGlobalCode(
    109109        const Identifier&, ExecState&, const SourceCode&, JSObject*& exception,
    110         int overrideLineNumber);
     110        int overrideLineNumber, std::optional<int> functionConstructorParametersEndPosition);
    111111
    112112    JS_EXPORT_PRIVATE FunctionExecutable* link(VM&, const SourceCode& parentSource, std::optional<int> overrideLineNumber = std::nullopt, Intrinsic = NoIntrinsic);
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r237299 r237445  
    195195
    196196template <typename LexerType>
    197 String Parser<LexerType>::parseInner(const Identifier& calleeName, SourceParseMode parseMode)
     197String Parser<LexerType>::parseInner(const Identifier& calleeName, SourceParseMode parseMode, ParsingContext parsingContext, std::optional<int> functionConstructorParametersEndPosition)
    198198{
    199199    String parseError = String();
    … …  
    239239        else if (isAsyncGeneratorWrapperParseMode(parseMode))
    240240            sourceElements = parseAsyncGeneratorFunctionSourceElements(context, parseMode, isArrowFunctionBodyExpression, CheckForStrictMode);
     241        else if (parsingContext == ParsingContext::FunctionConstructor)
     242            sourceElements = parseSingleFunction(context, functionConstructorParametersEndPosition);
    241243        else
    242244            sourceElements = parseSourceElements(context, CheckForStrictMode);
    … …  
    611613    return sourceElements;
    612614}
     615
     616template <typename LexerType>
     617template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseSingleFunction(TreeBuilder& context, std::optional<int> functionConstructorParametersEndPosition)
     618{
     619    TreeSourceElements sourceElements = context.createSourceElements();
     620    TreeStatement statement = 0;
     621    switch (m_token.m_type) {
     622    case FUNCTION:
     623        statement = parseFunctionDeclaration(context, ExportType::NotExported, DeclarationDefaultContext::Standard, functionConstructorParametersEndPosition);
     624        break;
     625    case IDENT:
     626        if (*m_token.m_data.ident == m_vm->propertyNames->async && !m_token.m_data.escaped) {
     627            next();
     628            failIfFalse(match(FUNCTION) && !m_lexer->prevTerminator(), "Cannot parse the async function");
     629            statement = parseAsyncFunctionDeclaration(context, ExportType::NotExported, DeclarationDefaultContext::Standard, functionConstructorParametersEndPosition);
     630            break;
     631        }
     632        FALLTHROUGH;
     633    default:
     634        failDueToUnexpectedToken();
     635        break;
     636    }
     637
     638    if (statement) {
     639        context.setEndOffset(statement, m_lastTokenEndPosition.offset);
     640        context.appendStatement(sourceElements, statement);
     641    }
     642
     643    propagateError();
     644    return sourceElements;
     645}
     646
    613647   
    614648template <typename LexerType>
    … …  
    22642298
    22652299template <typename LexerType>
    2266 template <class TreeBuilder> bool Parser<LexerType>::parseFunctionInfo(TreeBuilder& context, FunctionNameRequirements requirements, SourceParseMode mode, bool nameIsInContainingScope, ConstructorKind constructorKind, SuperBinding expectedSuperBinding, int functionKeywordStart, ParserFunctionInfo<TreeBuilder>& functionInfo, FunctionDefinitionType functionDefinitionType)
     2300template <class TreeBuilder> bool Parser<LexerType>::parseFunctionInfo(TreeBuilder& context, FunctionNameRequirements requirements, SourceParseMode mode, bool nameIsInContainingScope, ConstructorKind constructorKind, SuperBinding expectedSuperBinding, int functionKeywordStart, ParserFunctionInfo<TreeBuilder>& functionInfo, FunctionDefinitionType functionDefinitionType, std::optional<int> functionConstructorParametersEndPosition)
    22672301{
    22682302    RELEASE_ASSERT(isFunctionParseMode(mode));
    … …  
    24602494       
    24612495        matchOrFail(OPENBRACE, "Expected an opening '{' at the start of a ", stringForFunctionMode(mode), " body");
     2496
     2497        // If the code is invoked from function constructor, we need to ensure that parameters are only composed by the string offered as parameters.
     2498        if (UNLIKELY(functionConstructorParametersEndPosition))
     2499            semanticFailIfFalse(lastTokenEndPosition().offset == *functionConstructorParametersEndPosition, "Parameters should match arguments offered as parameters in Function constructor");
    24622500       
    24632501        // BytecodeGenerator emits code to throw TypeError when a class constructor is "call"ed.
    … …  
    25942632
    25952633template <typename LexerType>
    2596 template <class TreeBuilder> TreeStatement Parser<LexerType>::parseFunctionDeclaration(TreeBuilder& context, ExportType exportType, DeclarationDefaultContext declarationDefaultContext)
     2634template <class TreeBuilder> TreeStatement Parser<LexerType>::parseFunctionDeclaration(TreeBuilder& context, ExportType exportType, DeclarationDefaultContext declarationDefaultContext, std::optional<int> functionConstructorParametersEndPosition)
    25972635{
    25982636    ASSERT(match(FUNCTION));
    … …  
    26312669    }
    26322670
    2633     failIfFalse((parseFunctionInfo(context, requirements, parseMode, true, ConstructorKind::None, SuperBinding::NotNeeded, functionKeywordStart, functionInfo, FunctionDefinitionType::Declaration)), "Cannot parse this function");
     2671    failIfFalse((parseFunctionInfo(context, requirements, parseMode, true, ConstructorKind::None, SuperBinding::NotNeeded, functionKeywordStart, functionInfo, FunctionDefinitionType::Declaration, functionConstructorParametersEndPosition)), "Cannot parse this function");
    26342672    ASSERT(functionInfo.name);
    26352673
    … …  
    26522690
    26532691template <typename LexerType>
    2654 template <class TreeBuilder> TreeStatement Parser<LexerType>::parseAsyncFunctionDeclaration(TreeBuilder& context, ExportType exportType, DeclarationDefaultContext declarationDefaultContext)
     2692template <class TreeBuilder> TreeStatement Parser<LexerType>::parseAsyncFunctionDeclaration(TreeBuilder& context, ExportType exportType, DeclarationDefaultContext declarationDefaultContext, std::optional<int> functionConstructorParametersEndPosition)
    26552693{
    26562694    ASSERT(match(FUNCTION));
    … …  
    26892727    }
    26902728
    2691     failIfFalse((parseFunctionInfo(context, requirements, parseMode, true, ConstructorKind::None, SuperBinding::NotNeeded, functionKeywordStart, functionInfo, FunctionDefinitionType::Declaration)), "Cannot parse this async function");
     2729    failIfFalse((parseFunctionInfo(context, requirements, parseMode, true, ConstructorKind::None, SuperBinding::NotNeeded, functionKeywordStart, functionInfo, FunctionDefinitionType::Declaration, functionConstructorParametersEndPosition)), "Cannot parse this async function");
    26922730    failIfFalse(functionInfo.name, "Async function statements must have a name");
    26932731
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r237299 r237445  
    860860};
    861861
    862 enum class ArgumentType {
    863     Normal,
    864     Spread
    865 };
     862enum class ArgumentType { Normal, Spread };
     863enum class ParsingContext { Program, FunctionConstructor, Eval };
    866864
    867865template <typename LexerType>
    … …  
    875873
    876874    template <class ParsedNode>
    877     std::unique_ptr<ParsedNode> parse(ParserError&, const Identifier&, SourceParseMode);
     875    std::unique_ptr<ParsedNode> parse(ParserError&, const Identifier&, SourceParseMode, ParsingContext, std::optional<int> functionConstructorParametersEndPosition = std::nullopt);
    878876
    879877    JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); }
    … …  
    13131311
    13141312    Parser();
    1315     String parseInner(const Identifier&, SourceParseMode);
     1313
     1314    String parseInner(const Identifier&, SourceParseMode, ParsingContext, std::optional<int> functionConstructorParametersEndPosition = std::nullopt);
    13161315
    13171316    void didFinishParsing(SourceElements*, DeclarationStacks::FunctionStack&&, VariableEnvironment&, UniquedStringImplPtrSet&&, CodeFeatures, int);
    … …  
    15251524    template <class TreeBuilder> TreeSourceElements parseAsyncFunctionSourceElements(TreeBuilder&, SourceParseMode, bool isArrowFunctionBodyExpression, SourceElementsMode);
    15261525    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);
     1531    template <class TreeBuilder> TreeStatement parseFunctionDeclaration(TreeBuilder&, ExportType = ExportType::NotExported, DeclarationDefaultContext = DeclarationDefaultContext::Standard, std::optional<int> functionConstructorParametersEndPosition = std::nullopt);
    15321532    template <class TreeBuilder> TreeStatement parseFunctionDeclarationStatement(TreeBuilder&, bool isAsync, bool parentAllowsFunctionDeclarationAsStatement);
    1533     template <class TreeBuilder> TreeStatement parseAsyncFunctionDeclaration(TreeBuilder&, ExportType = ExportType::NotExported, DeclarationDefaultContext = DeclarationDefaultContext::Standard);
     1533    template <class TreeBuilder> TreeStatement parseAsyncFunctionDeclaration(TreeBuilder&, ExportType = ExportType::NotExported, DeclarationDefaultContext = DeclarationDefaultContext::Standard, std::optional<int> functionConstructorParametersEndPosition = std::nullopt);
    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);
     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);
    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)
     1850std::unique_ptr<ParsedNode> Parser<LexerType>::parse(ParserError& error, const Identifier& calleeName, SourceParseMode parseMode, ParsingContext parsingContext, std::optional<int> functionConstructorParametersEndPosition)
    18511851{
    18521852    int errLine;
    … …  
    18651865    unsigned startColumn = m_source->startColumn().zeroBasedInt();
    18661866
    1867     String parseError = parseInner(calleeName, parseMode);
     1867    String parseError = parseInner(calleeName, parseMode, parsingContext, functionConstructorParametersEndPosition);
    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);
     1962        result = parser.parse<ParsedNode>(error, name, parseMode, isEvalNode<ParsedNode>() ? ParsingContext::Eval : ParsingContext::Program);
    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);
     1975        result = parser.parse<ParsedNode>(error, name, parseMode, isEvalNode<ParsedNode>() ? ParsingContext::Eval : ParsingContext::Program);
    19761976        if (positionBeforeLastNewline)
    19771977            *positionBeforeLastNewline = parser.positionBeforeLastNewline();
    … …  
    19871987}
    19881988
     1989inline 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
    19892022} // namespace
  • trunk/Source/JavaScriptCore/parser/ParserModes.h

    r237299 r237445  
    3434enum class JSParserBuiltinMode { NotBuiltin, Builtin };
    3535enum class JSParserScriptMode { Classic, Module };
    36 enum class JSParserCodeType { Program, Function, Module };
    3736
    3837enum class ConstructorKind { None, Base, Extends };
  • trunk/Source/JavaScriptCore/parser/ParserTokens.h

    r237299 r237445  
    194194    JSTextPosition() = default;
    195195    JSTextPosition(int _line, int _offset, int _lineStartOffset) : line(_line), offset(_offset), lineStartOffset(_lineStartOffset) { }
    196     JSTextPosition(const JSTextPosition& other) : line(other.line), offset(other.offset), lineStartOffset(other.lineStartOffset) { }
    197196
    198197    JSTextPosition operator+(int adjustment) const { return JSTextPosition(line, offset + adjustment, lineStartOffset); }
    … …  
    247246struct JSTokenLocation {
    248247    JSTokenLocation() = default;
    249     JSTokenLocation(const JSTokenLocation& location)
    250     {
    251         line = location.line;
    252         lineStartOffset = location.lineStartOffset;
    253         startOffset = location.startOffset;
    254         endOffset = location.endOffset;
    255     }
    256248
    257249    int line { 0 };
  • trunk/Source/JavaScriptCore/parser/SourceCodeKey.h

    r237299 r237445  
    3030#include "UnlinkedSourceCode.h"
    3131#include <wtf/HashTraits.h>
     32#include <wtf/Hasher.h>
    3233
    3334namespace JSC {
    … …  
    7273class SourceCodeKey {
    7374public:
    74     SourceCodeKey()
    75     {
    76     }
     75    SourceCodeKey() = default;
    7776
    7877    SourceCodeKey(
    7978        const UnlinkedSourceCode& sourceCode, const String& name, SourceCodeType codeType, JSParserStrictMode strictMode,
    8079        JSParserScriptMode scriptMode, DerivedContextType derivedContextType, EvalContextType evalContextType, bool isArrowFunctionContext,
    81         DebuggerMode debuggerMode, TypeProfilerEnabled typeProfilerEnabled, ControlFlowProfilerEnabled controlFlowProfilerEnabled)
     80        DebuggerMode debuggerMode, TypeProfilerEnabled typeProfilerEnabled, ControlFlowProfilerEnabled controlFlowProfilerEnabled, std::optional<int> functionConstructorParametersEndPosition)
    8281            : m_sourceCode(sourceCode)
    8382            , m_name(name)
    8483            , m_flags(codeType, strictMode, scriptMode, derivedContextType, evalContextType, isArrowFunctionContext, debuggerMode, typeProfilerEnabled, controlFlowProfilerEnabled)
    85             , m_hash(sourceCode.hash() ^ m_flags.bits())
     84            , m_functionConstructorParametersEndPosition(functionConstructorParametersEndPosition.value_or(-1))
     85            , m_hash(sourceCode.hash() ^ computeHash(m_flags.bits(), m_functionConstructorParametersEndPosition))
    8686    {
    8787    }
    … …  
    109109            && length() == other.length()
    110110            && m_flags == other.m_flags
     111            && m_functionConstructorParametersEndPosition == other.m_functionConstructorParametersEndPosition
    111112            && m_name == other.m_name
    112113            && string() == other.string();
    … …  
    128129    String m_name;
    129130    SourceCodeFlags m_flags;
    130     unsigned m_hash;
     131    int m_functionConstructorParametersEndPosition { -1 };
     132    unsigned m_hash { 0 };
    131133};
    132134
  • trunk/Source/JavaScriptCore/runtime/CodeCache.cpp

    r237299 r237445  
    5858        derivedContextType, evalContextType, isArrowFunctionContext, debuggerMode,
    5959        vm.typeProfiler() ? TypeProfilerEnabled::Yes : TypeProfilerEnabled::No,
    60         vm.controlFlowProfiler() ? ControlFlowProfilerEnabled::Yes : ControlFlowProfilerEnabled::No);
     60        vm.controlFlowProfiler() ? ControlFlowProfilerEnabled::Yes : ControlFlowProfilerEnabled::No,
     61        std::nullopt);
    6162    SourceCodeValue* cache = m_sourceCode.findCacheAndUpdateAge(key);
    6263    if (cache && Options::useCodeCache()) {
    … …  
    9697}
    9798
    98 UnlinkedFunctionExecutable* CodeCache::getUnlinkedGlobalFunctionExecutable(VM& vm, const Identifier& name, const SourceCode& source, DebuggerMode debuggerMode, ParserError& error)
     99UnlinkedFunctionExecutable* CodeCache::getUnlinkedGlobalFunctionExecutable(VM& vm, const Identifier& name, const SourceCode& source, DebuggerMode debuggerMode, std::optional<int> functionConstructorParametersEndPosition, ParserError& error)
    99100{
    100101    bool isArrowFunctionContext = false;
    … …  
    108109        debuggerMode,
    109110        vm.typeProfiler() ? TypeProfilerEnabled::Yes : TypeProfilerEnabled::No,
    110         vm.controlFlowProfiler() ? ControlFlowProfilerEnabled::Yes : ControlFlowProfilerEnabled::No);
     111        vm.controlFlowProfiler() ? ControlFlowProfilerEnabled::Yes : ControlFlowProfilerEnabled::No,
     112        functionConstructorParametersEndPosition);
    111113    SourceCodeValue* cache = m_sourceCode.findCacheAndUpdateAge(key);
    112114    if (cache && Options::useCodeCache()) {
  • trunk/Source/JavaScriptCore/runtime/CodeCache.h

    r237299 r237445  
    195195    UnlinkedEvalCodeBlock* getUnlinkedEvalCodeBlock(VM&, IndirectEvalExecutable*, const SourceCode&, JSParserStrictMode, DebuggerMode, ParserError&, EvalContextType);
    196196    UnlinkedModuleProgramCodeBlock* getUnlinkedModuleProgramCodeBlock(VM&, ModuleProgramExecutable*, const SourceCode&, DebuggerMode, ParserError&);
    197     UnlinkedFunctionExecutable* getUnlinkedGlobalFunctionExecutable(VM&, const Identifier&, const SourceCode&, DebuggerMode, ParserError&);
     197    UnlinkedFunctionExecutable* getUnlinkedGlobalFunctionExecutable(VM&, const Identifier&, const SourceCode&, DebuggerMode, std::optional<int> functionConstructorParametersEndPosition, ParserError&);
    198198
    199199    void clear() { m_sourceCode.clear(); }
  • trunk/Source/JavaScriptCore/runtime/FunctionConstructor.cpp

    r237299 r237445  
    170170    SourceCode source = makeSource(program, sourceOrigin, sourceURL, position);
    171171    JSObject* exception = nullptr;
    172     FunctionExecutable* function = FunctionExecutable::fromGlobalCode(functionName, *exec, source, exception, overrideLineNumber);
     172    FunctionExecutable* function = FunctionExecutable::fromGlobalCode(functionName, *exec, source, exception, overrideLineNumber, std::nullopt);
    173173    if (!function) {
    174174        ASSERT(exception);
  • trunk/Source/JavaScriptCore/runtime/FunctionExecutable.cpp

    r237299 r237445  
    9595FunctionExecutable* FunctionExecutable::fromGlobalCode(
    9696    const Identifier& name, ExecState& exec, const SourceCode& source,
    97     JSObject*& exception, int overrideLineNumber)
     97    JSObject*& exception, int overrideLineNumber, std::optional<int> functionConstructorParametersEndPosition)
    9898{
    9999    UnlinkedFunctionExecutable* unlinkedExecutable =
    100100        UnlinkedFunctionExecutable::fromGlobalCode(
    101             name, exec, source, exception, overrideLineNumber);
     101            name, exec, source, exception, overrideLineNumber, functionConstructorParametersEndPosition);
    102102    if (!unlinkedExecutable)
    103103        return nullptr;
  • trunk/Source/JavaScriptCore/runtime/FunctionExecutable.h

    r237299 r237445  
    5656    static FunctionExecutable* fromGlobalCode(
    5757        const Identifier& name, ExecState&, const SourceCode&,
    58         JSObject*& exception, int overrideLineNumber);
     58        JSObject*& exception, int overrideLineNumber, std::optional<int> functionConstructorParametersEndPosition);
    5959
    6060    static void destroy(JSCell*);
Note: See TracChangeset for help on using the changeset viewer.