Ignore:
Timestamp:
Apr 29, 2014, 3:23:17 PM (11 years ago)
Author:
[email protected]
Message:

Source/JavaScriptCore: Don't hold on to parameterBindingNodes forever
https://bugs.webkit.org/show_bug.cgi?id=132360

Reviewed by Geoffrey Garen.

Don't keep the parameter nodes anymore. Instead we store the
original parameter string and reparse whenever we actually
need them. Because we only actually need them for compilation
this only results in a single extra parse.

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::generateFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):
(JSC::UnlinkedFunctionExecutable::visitChildren):
(JSC::UnlinkedFunctionExecutable::finishCreation):
(JSC::UnlinkedFunctionExecutable::paramString):
(JSC::UnlinkedFunctionExecutable::parameters):
(JSC::UnlinkedFunctionExecutable::parameterCount): Deleted.

  • bytecode/UnlinkedCodeBlock.h:

(JSC::UnlinkedFunctionExecutable::create):
(JSC::UnlinkedFunctionExecutable::parameterCount):
(JSC::UnlinkedFunctionExecutable::parameters): Deleted.
(JSC::UnlinkedFunctionExecutable::finishCreation): Deleted.

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::ASTBuilder):
(JSC::ASTBuilder::setFunctionBodyParameters):

  • parser/Nodes.h:

(JSC::FunctionBodyNode::parametersStartOffset):
(JSC::FunctionBodyNode::parametersEndOffset):
(JSC::FunctionBodyNode::setParameterLocation):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseFunctionInfo):
(JSC::parseParameters):

  • parser/Parser.h:

(JSC::parse):

  • parser/SourceCode.h:

(JSC::SourceCode::subExpression):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::setFunctionBodyParameters):

LayoutTests: Don't hold on to parameter BindingNodes forever
https://bugs.webkit.org/show_bug.cgi?id=132360

Reviewed by Geoffrey Garen.

We don't regenerate the parameter string anymore, so these tests now
match the original input.

  • js/destructuring-assignment-expected.txt:
File:
1 edited

Legend:

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

    r167313 r167964  
    12491249        return false;
    12501250    }
     1251    JSTokenLocation openParen = tokenLocation();
    12511252    if (!consume(OPENPAREN)) {
    12521253        semanticFailureDueToKeyword(stringForFunctionMode(mode), " name");
     
    12571258        failIfFalse(parameters, "Cannot parse parameters for this ", stringForFunctionMode(mode));
    12581259    }
     1260    JSTokenLocation endParen = m_token.m_location;
    12591261    consumeOrFail(CLOSEPAREN, "Expected a ')' or a ',' after a parameter declaration");
    12601262    matchOrFail(OPENBRACE, "Expected an opening '{' at the start of a ", stringForFunctionMode(mode), " body");
     
    12821284
    12831285        body = context.createFunctionBody(startLocation, endLocation, bodyStartColumn, bodyEndColumn, cachedInfo->strictMode);
    1284        
     1286        context.setFunctionBodyParameters(body, openParen, endParen);
    12851287        functionScope->restoreFromSourceProviderCache(cachedInfo);
    12861288        failIfFalse(popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo), "Parser error");
     
    13021304    restoreState(oldState);
    13031305    failIfFalse(body, "Cannot parse the body of this ", stringForFunctionMode(mode));
     1306    context.setFunctionBodyParameters(body, openParen, endParen);
    13041307    if (functionScope->strictMode() && name) {
    13051308        RELEASE_ASSERT(mode == FunctionMode);
     
    24052408}
    24062409
     2410PassRefPtr<FunctionParameters> parseParameters(VM* vm, const SourceCode& source, JSParserStrictness strictness)
     2411{
     2412    SamplingRegion samplingRegion("Parsing parameters");
     2413    ParameterNode* parameters = 0;
     2414    ASSERT(!source.provider()->source().isNull());
     2415    if (source.provider()->source().is8Bit()) {
     2416        Parser<Lexer<LChar>> parser(vm, source, 0, Identifier(), strictness, JSParseFunctionCode);
     2417        ASTBuilder builder(vm, &source);
     2418        parameters = parser.parseFormalParameters(builder);
     2419    } else {
     2420        Parser<Lexer<UChar>> parser(vm, source, 0, Identifier(), strictness, JSParseFunctionCode);
     2421        ASTBuilder builder(vm, &source);
     2422        parameters = parser.parseFormalParameters(builder);
     2423    }
     2424    if (!parameters)
     2425        return nullptr;
     2426    return FunctionParameters::create(parameters);
     2427}
     2428
    24072429// Instantiate the two flavors of Parser we need instead of putting most of this file in Parser.h
    24082430template class Parser<Lexer<LChar>>;
Note: See TracChangeset for help on using the changeset viewer.