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/runtime/Executable.h

    r47665 r47738  
    3333
    3434    class CodeBlock;
     35    class Debugger;
    3536    class EvalCodeBlock;
    3637    class ProgramCodeBlock;
     
    105106            : ExecutableBase(NUM_PARAMETERS_NOT_COMPILED)
    106107            , m_source(source)
     108            , m_features(0)
    107109        {
    108110        }
    109111
    110112        const SourceCode& source() { return m_source; }
    111         intptr_t sourceID() const { return m_node->sourceID(); }
    112         const UString& sourceURL() const { return m_node->sourceURL(); }
    113         int lineNo() const { return m_node->lineNo(); }
    114         int lastLine() const { return m_node->lastLine(); }
    115 
    116         bool usesEval() const { return m_node->usesEval(); }
    117         bool usesArguments() const { return m_node->usesArguments(); }
    118         bool needsActivation() const { return m_node->needsActivation(); }
     113        intptr_t sourceID() const { return m_source.provider()->asID(); }
     114        const UString& sourceURL() const { return m_source.provider()->url(); }
     115        int lineNo() const { return m_firstLine; }
     116        int lastLine() const { return m_lastLine; }
     117
     118        bool usesEval() const { return m_features & EvalFeature; }
     119        bool usesArguments() const { return m_features & ArgumentsFeature; }
     120        bool needsActivation() const { return m_features & (EvalFeature | ClosureFeature | WithFeature | CatchFeature); }
    119121
    120122        virtual ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*) = 0;
    121123
    122124    protected:
     125        void recordParse(CodeFeatures features, int firstLine, int lastLine)
     126        {
     127            m_features = features;
     128            m_firstLine = firstLine;
     129            m_lastLine = lastLine;
     130        }
     131
    123132        SourceCode m_source;
    124         RefPtr<ScopeNode> m_node;
     133        CodeFeatures m_features;
     134        int m_firstLine;
     135        int m_lastLine;
    125136    };
    126137
     
    135146        ~EvalExecutable();
    136147
    137         JSObject* parse(ExecState*, bool allowDebug = true);
    138 
    139         EvalCodeBlock& bytecode(ScopeChainNode* scopeChainNode)
    140         {
    141             if (!m_evalCodeBlock)
    142                 generateBytecode(scopeChainNode);
     148        EvalCodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode)
     149        {
     150            if (!m_evalCodeBlock) {
     151                JSObject* error = compile(exec, scopeChainNode);
     152                ASSERT_UNUSED(!error, error);
     153            }
    143154            return *m_evalCodeBlock;
    144155        }
    145156
     157        JSObject* compile(ExecState*, ScopeChainNode*);
     158
    146159        ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
    147 
    148160        static PassRefPtr<EvalExecutable> create(const SourceCode& source) { return adoptRef(new EvalExecutable(source)); }
    149161
    150162    private:
    151         EvalNode* evalNode() { return static_cast<EvalNode*>(m_node.get()); }
    152 
    153         void generateBytecode(ScopeChainNode*);
    154 
    155163        EvalCodeBlock* m_evalCodeBlock;
    156164
    157165#if ENABLE(JIT)
    158166    public:
    159         JITCode& jitCode(ScopeChainNode* scopeChainNode)
     167        JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode)
    160168        {
    161169            if (!m_jitCode)
    162                 generateJITCode(scopeChainNode);
     170                generateJITCode(exec, scopeChainNode);
    163171            return m_jitCode;
    164172        }
    165173
    166174    private:
    167         void generateJITCode(ScopeChainNode*);
     175        void generateJITCode(ExecState*, ScopeChainNode*);
    168176#endif
    169177    };
     
    179187        ~ProgramExecutable();
    180188
    181         JSObject* parse(ExecState*, bool allowDebug = true);
    182 
    183         // CodeBlocks for program code are transient and therefore to not gain from from throwing out there exception information.
     189        ProgramCodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode)
     190        {
     191            if (!m_programCodeBlock) {
     192                JSObject* error = compile(exec, scopeChainNode);
     193                ASSERT_UNUSED(!error, error);
     194            }
     195            return *m_programCodeBlock;
     196        }
     197
     198        JSObject* checkSyntax(ExecState*);
     199        JSObject* compile(ExecState*, ScopeChainNode*);
     200
     201        // CodeBlocks for program code are transient and therefore do not gain from from throwing out there exception information.
    184202        ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*) { ASSERT_NOT_REACHED(); return 0; }
    185203
    186         ProgramCodeBlock& bytecode(ScopeChainNode* scopeChainNode)
    187         {
    188             if (!m_programCodeBlock)
    189                 generateBytecode(scopeChainNode);
    190             return *m_programCodeBlock;
    191         }
    192 
    193     private:
    194         ProgramNode* programNode() { return static_cast<ProgramNode*>(m_node.get()); }
    195 
    196         void generateBytecode(ScopeChainNode*);
    197 
     204    private:
    198205        ProgramCodeBlock* m_programCodeBlock;
    199206
    200207#if ENABLE(JIT)
    201208    public:
    202         JITCode& jitCode(ScopeChainNode* scopeChainNode)
     209        JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode)
    203210        {
    204211            if (!m_jitCode)
    205                 generateJITCode(scopeChainNode);
     212                generateJITCode(exec, scopeChainNode);
    206213            return m_jitCode;
    207214        }
    208215
    209216    private:
    210         void generateJITCode(ScopeChainNode*);
     217        void generateJITCode(ExecState*, ScopeChainNode*);
    211218#endif
    212219    };
     
    215222        friend class JIT;
    216223    public:
    217         FunctionExecutable(const Identifier& name, FunctionBodyNode* body)
    218             : ScriptExecutable(body->source())
     224        FunctionExecutable(const Identifier& name, const SourceCode& source, bool forceUsesArguments, Identifier* parameters, int parameterCount, int firstLine, int lastLine)
     225            : ScriptExecutable(source)
     226            , m_forceUsesArguments(forceUsesArguments)
     227            , m_parameters(parameters)
     228            , m_parameterCount(parameterCount)
    219229            , m_codeBlock(0)
    220230            , m_name(name)
    221231            , m_numVariables(0)
    222232        {
    223             m_node = body;
     233            m_firstLine = firstLine;
     234            m_lastLine = lastLine;
    224235        }
    225236
    226237        ~FunctionExecutable();
    227238
    228         const Identifier& name() { return m_name; }
    229 
    230         JSFunction* make(ExecState*, ScopeChainNode* scopeChain);
    231 
    232         CodeBlock& bytecode(ScopeChainNode* scopeChainNode)
     239        JSFunction* make(ExecState* exec, ScopeChainNode* scopeChain)
     240        {
     241            return new (exec) JSFunction(exec, this, scopeChain);
     242        }
     243
     244        CodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode)
    233245        {
    234246            ASSERT(scopeChainNode);
    235247            if (!m_codeBlock)
    236                 generateBytecode(scopeChainNode);
     248                compile(exec, scopeChainNode);
    237249            return *m_codeBlock;
    238250        }
     251
     252        bool isGenerated() const
     253        {
     254            return m_codeBlock;
     255        }
     256
    239257        CodeBlock& generatedBytecode()
    240258        {
     
    243261        }
    244262
    245         bool usesEval() const { return body()->usesEval(); }
    246         bool usesArguments() const { return body()->usesArguments(); }
    247         size_t parameterCount() const { return body()->parameterCount(); }
     263        const Identifier& name() { return m_name; }
     264        size_t parameterCount() const { return m_parameterCount; }
    248265        size_t variableCount() const { return m_numVariables; }
    249         UString paramString() const { return body()->paramString(); }
    250 
    251         bool isGenerated() const
    252         {
    253             return m_codeBlock;
    254         }
     266        UString paramString() const;
    255267
    256268        void recompile(ExecState*);
    257 
    258269        ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
    259 
    260270        void markAggregate(MarkStack& markStack);
    261 
    262     private:
    263         FunctionBodyNode* body() const { return static_cast<FunctionBodyNode*>(m_node.get()); }
    264 
    265         void generateBytecode(ScopeChainNode*);
    266 
     271        static PassRefPtr<FunctionExecutable> fromGlobalCode(const Identifier&, ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0);
     272
     273    private:
     274        void compile(ExecState*, ScopeChainNode*);
     275        Identifier* copyParameters();
     276
     277        bool m_forceUsesArguments;
     278        Identifier* m_parameters;
     279        int m_parameterCount;
    267280        CodeBlock* m_codeBlock;
    268         const Identifier& m_name;
     281        Identifier m_name;
    269282        size_t m_numVariables;
    270283
    271284#if ENABLE(JIT)
    272285    public:
    273         JITCode& jitCode(ScopeChainNode* scopeChainNode)
     286        JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode)
    274287        {
    275288            if (!m_jitCode)
    276                 generateJITCode(scopeChainNode);
     289                generateJITCode(exec, scopeChainNode);
    277290            return m_jitCode;
    278291        }
    279292
    280293    private:
    281         void generateJITCode(ScopeChainNode*);
     294        void generateJITCode(ExecState*, ScopeChainNode*);
    282295#endif
    283296    };
     
    289302    }
    290303
    291     inline JSFunction* FunctionExecutable::make(ExecState* exec, ScopeChainNode* scopeChain)
    292     {
    293         return new (exec) JSFunction(exec, this, scopeChain);
    294     }
    295 
    296304    inline bool JSFunction::isHostFunction() const
    297305    {
Note: See TracChangeset for help on using the changeset viewer.