Ignore:
Timestamp:
Aug 14, 2009, 6:14:00 PM (16 years ago)
Author:
[email protected]
Message:

Remove AST nodes from use within the Runtime (outside of parsing), stage 1
https://bugs.webkit.org/show_bug.cgi?id=28330

Reviewed by Oliver Hunt.

Remove the EvalNode and ProgramNode from use in the runtime. They still exist
after this patch, but are hidden behind EvalExecutable and FunctionExecutable,
and are also still reachable behind CodeBlock::m_ownerNode.

The next step will be to beat back FunctionBodyNode in the same fashion.
Then remove the usage via CodeBlock, then only construct these nodes only on
demand during bytecode generation.

(JSC::GlobalCodeBlock::GlobalCodeBlock):
(JSC::GlobalCodeBlock::~GlobalCodeBlock):
(JSC::ProgramCodeBlock::ProgramCodeBlock):
(JSC::EvalCodeBlock::EvalCodeBlock):
(JSC::FunctionCodeBlock::FunctionCodeBlock):
(JSC::NativeCodeBlock::NativeCodeBlock):

  • bytecode/EvalCodeCache.h:

(JSC::EvalCodeCache::get):

  • debugger/Debugger.cpp:

(JSC::evaluateInGlobalCallFrame):

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::evaluate):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::callEval):
(JSC::Interpreter::execute):

  • interpreter/Interpreter.h:
  • parser/Nodes.cpp:

(JSC::FunctionBodyNode::createNativeThunk):
(JSC::FunctionBodyNode::generateBytecode):
(JSC::FunctionBodyNode::bytecodeForExceptionInfoReparse):

  • parser/Parser.h:

(JSC::Parser::parse):
(JSC::Parser::reparse):
(JSC::Parser::parseFunctionFromGlobalCode):
(JSC::::parse):

  • runtime/Completion.cpp:

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

  • runtime/Error.cpp:

(JSC::throwError):

  • runtime/Error.h:
  • runtime/Executable.h: Added.

(JSC::TemplateExecutable::TemplateExecutable):
(JSC::TemplateExecutable::markAggregate):
(JSC::TemplateExecutable::sourceURL):
(JSC::TemplateExecutable::lineNo):
(JSC::TemplateExecutable::bytecode):
(JSC::TemplateExecutable::jitCode):
(JSC::EvalExecutable::EvalExecutable):
(JSC::ProgramExecutable::ProgramExecutable):

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunction):

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

(JSC::JSGlobalData::numericCompareFunction):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::~JSGlobalObject):
(JSC::JSGlobalObject::markChildren):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::codeBlocks):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEval):

File:
1 edited

Legend:

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

    r45891 r47304  
    2525
    2626#include "Debugger.h"
     27#include "Executable.h"
    2728#include "Nodes.h"
    2829#include "SourceProvider.h"
     
    4243    class Parser : public Noncopyable {
    4344    public:
    44         template <class ParsedNode> PassRefPtr<ParsedNode> parse(ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0);
    45         template <class ParsedNode> PassRefPtr<ParsedNode> reparse(JSGlobalData*, ParsedNode*);
     45        template <class ParsedNode>
     46        PassRefPtr<ParsedNode> parse(ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0);
     47        template <class ParsedNode>
     48        PassRefPtr<ParsedNode> reparse(JSGlobalData*, ParsedNode*);
    4649        void reparseInPlace(JSGlobalData*, FunctionBodyNode*);
     50        PassRefPtr<FunctionBodyNode> parseFunctionFromGlobalCode(ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0);
    4751
    4852        void didFinishParsing(SourceElements*, ParserArenaData<DeclarationStacks::VarStack>*,
     
    6468    };
    6569
    66     template <class ParsedNode> PassRefPtr<ParsedNode> Parser::parse(ExecState* exec, Debugger* debugger, const SourceCode& source, int* errLine, UString* errMsg)
     70    template <class ParsedNode>
     71    PassRefPtr<ParsedNode> Parser::parse(ExecState* exec, Debugger* debugger, const SourceCode& source, int* errLine, UString* errMsg)
    6772    {
    6873        m_source = &source;
     
    9196    }
    9297
    93     template <class ParsedNode> PassRefPtr<ParsedNode> Parser::reparse(JSGlobalData* globalData, ParsedNode* oldParsedNode)
     98    template <class ParsedNode>
     99    PassRefPtr<ParsedNode> Parser::reparse(JSGlobalData* globalData, ParsedNode* oldParsedNode)
    94100    {
    95101        m_source = &oldParsedNode->source();
     
    116122    }
    117123
     124    inline PassRefPtr<FunctionBodyNode> Parser::parseFunctionFromGlobalCode(ExecState* exec, Debugger* debugger, const SourceCode& source, int* errLine, UString* errMsg)
     125    {
     126        RefPtr<ProgramNode> program = parse<ProgramNode>(exec, debugger, source, errLine, errMsg);
     127
     128        if (!program)
     129            return 0;
     130
     131        StatementVector& children = program->children();
     132        if (children.size() != 1)
     133            return 0;
     134
     135        StatementNode* exprStatement = children[0];
     136        ASSERT(exprStatement);
     137        ASSERT(exprStatement->isExprStatement());
     138        if (!exprStatement || !exprStatement->isExprStatement())
     139            return 0;
     140
     141        ExpressionNode* funcExpr = static_cast<ExprStatementNode*>(exprStatement)->expr();
     142        ASSERT(funcExpr);
     143        ASSERT(funcExpr->isFuncExprNode());
     144        if (!funcExpr || !funcExpr->isFuncExprNode())
     145            return 0;
     146
     147        RefPtr<FunctionBodyNode> body = static_cast<FuncExprNode*>(funcExpr)->body();
     148        ASSERT(body);
     149        return body.release();
     150    }
     151
     152    template<class ASTNodeType, class CodeBlockType>
     153    inline JSObject* TemplateExecutable<ASTNodeType, CodeBlockType>::parse(ExecState* exec, bool allowDebug)
     154    {
     155        int errLine;
     156        UString errMsg;
     157        m_node = exec->globalData().parser->parse<ASTNodeType>(exec, allowDebug ? exec->dynamicGlobalObject()->debugger() : 0, m_source, &errLine, &errMsg);
     158
     159        if (!m_node)
     160            return Error::create(exec, SyntaxError, errMsg, errLine, m_source.provider()->asID(), m_source.provider()->url());
     161        return 0;
     162    }
     163
    118164} // namespace JSC
    119165
Note: See TracChangeset for help on using the changeset viewer.