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.cpp

    r67583 r67769  
    3636namespace JSC {
    3737
    38 void Parser::parse(JSGlobalData* globalData, int* errLine, UString* errMsg)
     38void Parser::parse(JSGlobalData* globalData, FunctionParameters* parameters, int* errLine, UString* errMsg)
    3939{
    4040    m_sourceElements = 0;
     
    5454    lexer.setCode(*m_source, m_arena);
    5555
    56     int parseError = jsParse(globalData, m_source);
     56    int parseError = jsParse(globalData, parameters, m_source);
    5757    int lineNumber = lexer.lineNumber();
    5858    bool lexError = lexer.sawError();
Note: See TracChangeset for help on using the changeset viewer.