Changeset 47304 in webkit for trunk/JavaScriptCore/bytecode


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):

Location:
trunk/JavaScriptCore/bytecode
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/bytecode/CodeBlock.h

    r47089 r47304  
    251251    class CodeBlock : public FastAllocBase {
    252252        friend class JIT;
    253     public:
     253    protected:
    254254        CodeBlock(ScopeNode* ownerNode);
    255255        CodeBlock(ScopeNode* ownerNode, CodeType, PassRefPtr<SourceProvider>, unsigned sourceOffset);
     256    public:
    256257        ~CodeBlock();
    257258
     
    551552    // responsible for marking it.
    552553
    553     class ProgramCodeBlock : public CodeBlock {
     554    class GlobalCodeBlock : public CodeBlock {
     555    public:
     556        GlobalCodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset, JSGlobalObject* globalObject)
     557            : CodeBlock(ownerNode, codeType, sourceProvider, sourceOffset)
     558            , m_globalObject(globalObject)
     559        {
     560            m_globalObject->codeBlocks().add(this);
     561        }
     562
     563        ~GlobalCodeBlock()
     564        {
     565            if (m_globalObject)
     566                m_globalObject->codeBlocks().remove(this);
     567        }
     568
     569        void clearGlobalObject() { m_globalObject = 0; }
     570
     571    private:
     572        JSGlobalObject* m_globalObject; // For program and eval nodes, the global object that marks the constant pool.
     573    };
     574
     575    class ProgramCodeBlock : public GlobalCodeBlock {
    554576    public:
    555577        ProgramCodeBlock(ScopeNode* ownerNode, CodeType codeType, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider)
    556             : CodeBlock(ownerNode, codeType, sourceProvider, 0)
    557             , m_globalObject(globalObject)
    558         {
    559             m_globalObject->codeBlocks().add(this);
    560         }
    561 
    562         ~ProgramCodeBlock()
    563         {
    564             if (m_globalObject)
    565                 m_globalObject->codeBlocks().remove(this);
    566         }
    567 
    568         void clearGlobalObject() { m_globalObject = 0; }
    569 
    570     private:
    571         JSGlobalObject* m_globalObject; // For program and eval nodes, the global object that marks the constant pool.
    572     };
    573 
    574     class EvalCodeBlock : public ProgramCodeBlock {
     578            : GlobalCodeBlock(ownerNode, codeType, sourceProvider, 0, globalObject)
     579        {
     580        }
     581    };
     582
     583    class EvalCodeBlock : public GlobalCodeBlock {
    575584    public:
    576585        EvalCodeBlock(ScopeNode* ownerNode, JSGlobalObject* globalObject, PassRefPtr<SourceProvider> sourceProvider, int baseScopeDepth)
    577             : ProgramCodeBlock(ownerNode, EvalCode, globalObject, sourceProvider)
     586            : GlobalCodeBlock(ownerNode, EvalCode, sourceProvider, 0, globalObject)
    578587            , m_baseScopeDepth(baseScopeDepth)
    579588        {
     
    584593    private:
    585594        int m_baseScopeDepth;
     595    };
     596
     597    class FunctionCodeBlock : public CodeBlock {
     598    public:
     599        FunctionCodeBlock(ScopeNode* ownerNode, CodeType codeType, PassRefPtr<SourceProvider> sourceProvider, unsigned sourceOffset)
     600            : CodeBlock(ownerNode, codeType, sourceProvider, sourceOffset)
     601        {
     602        }
     603    };
     604
     605    class NativeCodeBlock : public CodeBlock {
     606    public:
     607        NativeCodeBlock(ScopeNode* ownerNode)
     608            : CodeBlock(ownerNode)
     609        {
     610        }
    586611    };
    587612
  • trunk/JavaScriptCore/bytecode/EvalCodeCache.h

    r47022 r47304  
    3030#define EvalCodeCache_h
    3131
     32#include "Executable.h"
    3233#include "JSGlobalObject.h"
    3334#include "Nodes.h"
     
    4243    class EvalCodeCache {
    4344    public:
    44         PassRefPtr<EvalNode> get(ExecState* exec, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue)
     45        PassRefPtr<EvalExecutable> get(ExecState* exec, const UString& evalSource, ScopeChainNode* scopeChain, JSValue& exceptionValue)
    4546        {
    46             RefPtr<EvalNode> evalNode;
     47            RefPtr<EvalExecutable> evalExecutable;
    4748
    4849            if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject())
    49                 evalNode = m_cacheMap.get(evalSource.rep());
     50                evalExecutable = m_cacheMap.get(evalSource.rep());
    5051
    51             if (!evalNode) {
    52                 int errorLine;
    53                 UString errorMessage;
    54                
    55                 SourceCode source = makeSource(evalSource);
    56                 evalNode = exec->globalData().parser->parse<EvalNode>(exec, exec->dynamicGlobalObject()->debugger(), source, &errorLine, &errorMessage);
    57                 if (evalNode) {
    58                     if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries)
    59                         m_cacheMap.set(evalSource.rep(), evalNode);
    60                 } else {
    61                     exceptionValue = Error::create(exec, SyntaxError, errorMessage, errorLine, source.provider()->asID(), 0);
     52            if (!evalExecutable) {
     53                evalExecutable = new EvalExecutable(makeSource(evalSource));
     54                exceptionValue = evalExecutable->parse(exec);
     55                if (exceptionValue)
    6256                    return 0;
    63                 }
     57
     58                if (evalSource.size() < maxCacheableSourceLength && (*scopeChain->begin())->isVariableObject() && m_cacheMap.size() < maxCacheEntries)
     59                    m_cacheMap.set(evalSource.rep(), evalExecutable);
    6460            }
    6561
    66             return evalNode.release();
     62            return evalExecutable.release();
    6763        }
    6864
     
    7975        static const int maxCacheEntries = 64;
    8076
    81         typedef HashMap<RefPtr<UString::Rep>, RefPtr<EvalNode> > EvalCacheMap;
     77        typedef HashMap<RefPtr<UString::Rep>, RefPtr<EvalExecutable> > EvalCacheMap;
    8278        EvalCacheMap m_cacheMap;
    8379    };
Note: See TracChangeset for help on using the changeset viewer.