Ignore:
Timestamp:
Sep 17, 2010, 6:06:59 PM (15 years ago)
Author:
[email protected]
Message:

2010-09-17 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

Imprecise tracking of variable capture leads to overly pessimistic creation of activations
https://bugs.webkit.org/show_bug.cgi?id=46020

The old logic for track free and captured variables would cause us
to decide we needed an activation in every function along the scope
chain between a variable capture and its declaration. We now track
captured variables precisely which requires a bit of additional work

The most substantial change is that the parsing routine needs to
be passed the list of function parameters when reparsing a function
as when reparsing we don't parse the function declaration itself only
its body.

  • JavaScriptCore.exp:
  • parser/JSParser.cpp: (JSC::JSParser::Scope::Scope): (JSC::JSParser::Scope::needsFullActivation):

We need to distinguish between use of a feature that requires
an activation and eval so we now get this additional flag.

(JSC::JSParser::Scope::collectFreeVariables):
(JSC::JSParser::Scope::getCapturedVariables):

We can't simply return the list of "capturedVariables" now as
is insufficiently precise, so we compute them instead.

(JSC::JSParser::popScope):
(JSC::jsParse):
(JSC::JSParser::JSParser):
(JSC::JSParser::parseProgram):
(JSC::JSParser::parseWithStatement):
(JSC::JSParser::parseTryStatement):
(JSC::JSParser::parseFunctionInfo):
(JSC::JSParser::parseFunctionDeclaration):
(JSC::JSParser::parseProperty):
(JSC::JSParser::parseMemberExpression):

  • parser/JSParser.h:
  • parser/Parser.cpp: (JSC::Parser::parse):
  • parser/Parser.h: (JSC::Parser::parse):
  • runtime/Executable.cpp: (JSC::EvalExecutable::compileInternal): (JSC::ProgramExecutable::checkSyntax): (JSC::ProgramExecutable::compileInternal): (JSC::FunctionExecutable::compileForCallInternal): (JSC::FunctionExecutable::compileForConstructInternal): (JSC::FunctionExecutable::reparseExceptionInfo): (JSC::EvalExecutable::reparseExceptionInfo): (JSC::FunctionExecutable::fromGlobalCode):

Pass function parameters (if available) to the parser.

File:
1 edited

Legend:

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

    r67583 r67769  
    4949    public:
    5050        template <class ParsedNode>
    51         PassRefPtr<ParsedNode> parse(JSGlobalData* globalData, JSGlobalObject* lexicalGlobalObject, Debugger*, ExecState*, const SourceCode& source, JSObject** exception);
     51        PassRefPtr<ParsedNode> parse(JSGlobalData* globalData, JSGlobalObject* lexicalGlobalObject, Debugger*, ExecState*, const SourceCode& source, FunctionParameters*, JSObject** exception);
    5252
    5353        void didFinishParsing(SourceElements*, ParserArenaData<DeclarationStacks::VarStack>*,
     
    5858
    5959    private:
    60         void parse(JSGlobalData*, int* errLine, UString* errMsg);
     60        void parse(JSGlobalData*, FunctionParameters*, int* errLine, UString* errMsg);
    6161
    6262        // Used to determine type of error to report.
     
    7676
    7777    template <class ParsedNode>
    78     PassRefPtr<ParsedNode> Parser::parse(JSGlobalData* globalData, JSGlobalObject* lexicalGlobalObject, Debugger* debugger, ExecState* debuggerExecState, const SourceCode& source, JSObject** exception)
     78    PassRefPtr<ParsedNode> Parser::parse(JSGlobalData* globalData, JSGlobalObject* lexicalGlobalObject, Debugger* debugger, ExecState* debuggerExecState, const SourceCode& source, FunctionParameters* parameters, JSObject** exception)
    7979    {
    8080        ASSERT(exception && !*exception);
     
    8585        if (ParsedNode::scopeIsFunction)
    8686            globalData->lexer->setIsReparsing();
    87         parse(globalData, &errLine, &errMsg);
     87        parse(globalData, parameters, &errLine, &errMsg);
    8888
    8989        RefPtr<ParsedNode> result;
Note: See TracChangeset for help on using the changeset viewer.