Ignore:
Timestamp:
Aug 24, 2009, 7:53:51 PM (16 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=28691
Do not retain ScopeNodes outside of parsing

Reviewed by Oliver Adler & Darin Hunt.

There is now no need for these to exist outside of parsing - their use in the runtime is replaced by Executable types.

  • bytecode/EvalCodeCache.h:

(JSC::EvalCodeCache::get):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::emitNewFunction):
(JSC::BytecodeGenerator::emitNewFunctionExpression):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::makeFunction):

  • debugger/Debugger.cpp:

(JSC::Debugger::recompileAllJSFunctions):
(JSC::evaluateInGlobalCallFrame):

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::evaluate):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::execute):
(JSC::Interpreter::prepareForRepeatCall):
(JSC::Interpreter::privateExecute):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • parser/Nodes.cpp:

(JSC::ScopeNodeData::ScopeNodeData):
(JSC::ProgramNode::create):
(JSC::EvalNode::create):
(JSC::FunctionBodyNode::create):

  • parser/Nodes.h:

(JSC::ScopeNode::adoptData):
(JSC::FunctionBodyNode::parameterCount):

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

(JSC::Parser::arena):
(JSC::Parser::Parser):
(JSC::Parser::parse):

  • runtime/ArrayPrototype.cpp:

(JSC::isNumericCompareFunction):
(JSC::arrayProtoFuncSort):

  • runtime/Completion.cpp:

(JSC::checkSyntax):
(JSC::evaluate):

  • runtime/Executable.cpp:

(JSC::FunctionExecutable::~FunctionExecutable):
(JSC::EvalExecutable::compile):
(JSC::ProgramExecutable::checkSyntax):
(JSC::ProgramExecutable::compile):
(JSC::FunctionExecutable::compile):
(JSC::EvalExecutable::generateJITCode):
(JSC::ProgramExecutable::generateJITCode):
(JSC::FunctionExecutable::generateJITCode):
(JSC::FunctionExecutable::reparseExceptionInfo):
(JSC::EvalExecutable::reparseExceptionInfo):
(JSC::FunctionExecutable::recompile):
(JSC::FunctionExecutable::fromGlobalCode):
(JSC::FunctionExecutable::copyParameters):
(JSC::FunctionExecutable::paramString):

  • runtime/Executable.h:

(JSC::ScriptExecutable::ScriptExecutable):
(JSC::ScriptExecutable::sourceID):
(JSC::ScriptExecutable::sourceURL):
(JSC::ScriptExecutable::lineNo):
(JSC::ScriptExecutable::lastLine):
(JSC::ScriptExecutable::usesEval):
(JSC::ScriptExecutable::usesArguments):
(JSC::ScriptExecutable::needsActivation):
(JSC::ScriptExecutable::recordParse):
(JSC::EvalExecutable::bytecode):
(JSC::EvalExecutable::jitCode):
(JSC::ProgramExecutable::bytecode):
(JSC::ProgramExecutable::reparseExceptionInfo):
(JSC::ProgramExecutable::jitCode):
(JSC::FunctionExecutable::FunctionExecutable):
(JSC::FunctionExecutable::make):
(JSC::FunctionExecutable::bytecode):
(JSC::FunctionExecutable::isGenerated):
(JSC::FunctionExecutable::name):
(JSC::FunctionExecutable::parameterCount):
(JSC::FunctionExecutable::jitCode):

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunction):

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::numericCompareFunction):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEval):

File:
1 edited

Legend:

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

    r47664 r47738  
    2727#include "Executable.h"
    2828#include "JSGlobalObject.h"
     29#include "Lexer.h"
    2930#include "Nodes.h"
    3031#include "ParserArena.h"
     
    4647    public:
    4748        template <class ParsedNode>
    48         PassRefPtr<ParsedNode> parse(ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0);
    49         template <class ParsedNode>
    50         PassRefPtr<ParsedNode> reparse(JSGlobalData*, ParsedNode*);
    51         void reparseInPlace(JSGlobalData*, FunctionBodyNode*);
    52         PassRefPtr<FunctionBodyNode> parseFunctionFromGlobalCode(ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0);
     49        PassRefPtr<ParsedNode> parse(JSGlobalData* globalData, Debugger*, ExecState*, const SourceCode& source, int* errLine = 0, UString* errMsg = 0);
    5350
    5451        void didFinishParsing(SourceElements*, ParserArenaData<DeclarationStacks::VarStack>*,
     
    7168
    7269    template <class ParsedNode>
    73     PassRefPtr<ParsedNode> Parser::parse(ExecState* exec, Debugger* debugger, const SourceCode& source, int* errLine, UString* errMsg)
     70    PassRefPtr<ParsedNode> Parser::parse(JSGlobalData* globalData, Debugger* debugger, ExecState* debuggerExecState, const SourceCode& source, int* errLine, UString* errMsg)
    7471    {
    7572        m_source = &source;
    76         parse(&exec->globalData(), errLine, errMsg);
     73        if (FunctionBodyNode::scopeIsFunction)
     74            globalData->lexer->setIsReparsing();
     75        parse(globalData, errLine, errMsg);
     76
    7777        RefPtr<ParsedNode> result;
    7878        if (m_sourceElements) {
    79             result = ParsedNode::create(&exec->globalData(),
    80                                          m_sourceElements,
    81                                          m_varDeclarations ? &m_varDeclarations->data : 0,
    82                                          m_funcDeclarations ? &m_funcDeclarations->data : 0,
    83                                          *m_source,
    84                                          m_features,
    85                                          m_numConstants);
     79            result = ParsedNode::create(globalData,
     80            m_sourceElements,
     81            m_varDeclarations ? &m_varDeclarations->data : 0,
     82            m_funcDeclarations ? &m_funcDeclarations->data : 0,
     83            source,
     84            m_features,
     85            m_numConstants);
    8686            result->setLoc(m_source->firstLine(), m_lastLine);
    8787        }
     
    9090
    9191        m_source = 0;
     92        m_sourceElements = 0;
    9293        m_varDeclarations = 0;
    9394        m_funcDeclarations = 0;
    9495
    95         if (debugger)
    96             debugger->sourceParsed(exec, source, *errLine, *errMsg);
     96        if (debugger && !FunctionBodyNode::scopeIsFunction)
     97            debugger->sourceParsed(debuggerExecState, source, *errLine, *errMsg);
    9798        return result.release();
    98     }
    99 
    100     template <class ParsedNode>
    101     PassRefPtr<ParsedNode> Parser::reparse(JSGlobalData* globalData, ParsedNode* oldParsedNode)
    102     {
    103         m_source = &oldParsedNode->source();
    104         parse(globalData, 0, 0);
    105         RefPtr<ParsedNode> result;
    106         if (m_sourceElements) {
    107             result = ParsedNode::create(globalData,
    108                                         m_sourceElements,
    109                                         m_varDeclarations ? &m_varDeclarations->data : 0,
    110                                         m_funcDeclarations ? &m_funcDeclarations->data : 0,
    111                                         *m_source,
    112                                         oldParsedNode->features(),
    113                                         m_numConstants);
    114             result->setLoc(m_source->firstLine(), m_lastLine);
    115         }
    116 
    117         m_arena.reset();
    118 
    119         m_source = 0;
    120         m_varDeclarations = 0;
    121         m_funcDeclarations = 0;
    122 
    123         return result.release();
    124     }
    125 
    126     inline PassRefPtr<FunctionBodyNode> Parser::parseFunctionFromGlobalCode(ExecState* exec, Debugger* debugger, const SourceCode& source, int* errLine, UString* errMsg)
    127     {
    128         RefPtr<ProgramNode> program = parse<ProgramNode>(exec, debugger, source, errLine, errMsg);
    129         if (!program)
    130             return 0;
    131 
    132         StatementNode* exprStatement = program->singleStatement();
    133         ASSERT(exprStatement);
    134         ASSERT(exprStatement->isExprStatement());
    135         if (!exprStatement || !exprStatement->isExprStatement())
    136             return 0;
    137 
    138         ExpressionNode* funcExpr = static_cast<ExprStatementNode*>(exprStatement)->expr();
    139         ASSERT(funcExpr);
    140         ASSERT(funcExpr->isFuncExprNode());
    141         if (!funcExpr || !funcExpr->isFuncExprNode())
    142             return 0;
    143 
    144         FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body();
    145         ASSERT(body);
    146         return body;
    147     }
    148 
    149     inline JSObject* EvalExecutable::parse(ExecState* exec, bool allowDebug)
    150     {
    151         int errLine;
    152         UString errMsg;
    153         m_node = exec->globalData().parser->parse<EvalNode>(exec, allowDebug ? exec->dynamicGlobalObject()->debugger() : 0, m_source, &errLine, &errMsg);
    154         if (!m_node)
    155             return Error::create(exec, SyntaxError, errMsg, errLine, m_source.provider()->asID(), m_source.provider()->url());
    156         return 0;
    157     }
    158 
    159     inline JSObject* ProgramExecutable::parse(ExecState* exec, bool allowDebug)
    160     {
    161         int errLine;
    162         UString errMsg;
    163         m_node = exec->globalData().parser->parse<ProgramNode>(exec, allowDebug ? exec->dynamicGlobalObject()->debugger() : 0, m_source, &errLine, &errMsg);
    164         if (!m_node)
    165             return Error::create(exec, SyntaxError, errMsg, errLine, m_source.provider()->asID(), m_source.provider()->url());
    166         return 0;
    16799    }
    168100
Note: See TracChangeset for help on using the changeset viewer.