Ignore:
Timestamp:
Jul 13, 2010, 5:27:13 PM (15 years ago)
Author:
[email protected]
Message:

Bug 42207 - Clean up interface to compile executables, always check for exceptions

Reviewed by Oliver Hunt.

Presently interface to compile executable is inconsistent between eval/program and
function code, and is error prone in allowing a caller to byte compile without JIT
compiling an executable (we rely on all executables with codeblocks having JIT code).
Unify on an interface where all compilation is performed by a single compile (with
ForCall|ForConstruct variants) method, and make all clients check for errors.

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::unwindCallFrame):
(JSC::Interpreter::execute):
(JSC::Interpreter::executeCall):
(JSC::Interpreter::executeConstruct):
(JSC::Interpreter::prepareForRepeatCall):
(JSC::Interpreter::privateExecute):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • parser/Parser.h:

(JSC::Parser::isFunctionBodyNode):
(JSC::Parser::parse):

  • runtime/ArrayPrototype.cpp:

(JSC::isNumericCompareFunction):

  • runtime/ExceptionHelpers.cpp:

(JSC::createStackOverflowError):

  • runtime/ExceptionHelpers.h:
  • 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):

  • runtime/Executable.h:

(JSC::EvalExecutable::compile):
(JSC::EvalExecutable::generatedBytecode):
(JSC::EvalExecutable::generatedJITCode):
(JSC::ProgramExecutable::compile):
(JSC::ProgramExecutable::generatedBytecode):
(JSC::ProgramExecutable::generatedJITCode):
(JSC::FunctionExecutable::generatedBytecode):
(JSC::FunctionExecutable::compileForCall):
(JSC::FunctionExecutable::compileForConstruct):
(JSC::FunctionExecutable::generatedJITCodeForConstructWithArityCheck):

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunction):

  • runtime/JSActivation.cpp:

(JSC::JSActivation::argumentsGetter):

  • runtime/JSGlobalData.h:

(JSC::JSGlobalData::canUseJIT):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/Executable.h

    r63237 r63267  
    194194        ~EvalExecutable();
    195195
    196         EvalCodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode)
    197         {
    198             if (!m_evalCodeBlock) {
    199                 JSObject* error = compile(exec, scopeChainNode);
    200                 ASSERT_UNUSED(!error, error);
    201             }
     196        JSObject* compile(ExecState* exec, ScopeChainNode* scopeChainNode)
     197        {
     198            JSObject* error = 0;
     199            if (!m_evalCodeBlock)
     200                error = compileInternal(exec, scopeChainNode);
     201            ASSERT(!error == !!m_evalCodeBlock);
     202            return error;
     203        }
     204
     205        EvalCodeBlock& generatedBytecode()
     206        {
     207            ASSERT(m_evalCodeBlock);
    202208            return *m_evalCodeBlock;
    203209        }
    204210
    205         JSObject* compile(ExecState*, ScopeChainNode*);
    206 
    207211        static PassRefPtr<EvalExecutable> create(ExecState* exec, const SourceCode& source) { return adoptRef(new EvalExecutable(exec, source)); }
     212
     213#if ENABLE(JIT)
     214        JITCode& generatedJITCode()
     215        {
     216            return generatedJITCodeForCall();
     217        }
     218#endif
    208219
    209220    private:
     
    214225        }
    215226
     227        JSObject* compileInternal(ExecState*, ScopeChainNode*);
     228
    216229        virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
    217230
    218231        EvalCodeBlock* m_evalCodeBlock;
    219 
    220 #if ENABLE(JIT)
    221     public:
    222         JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode)
    223         {
    224             if (!m_jitCodeForCall)
    225                 generateJITCode(exec, scopeChainNode);
    226             return m_jitCodeForCall;
    227         }
    228 
    229     private:
    230         void generateJITCode(ExecState*, ScopeChainNode*);
    231 #endif
    232232    };
    233233
     
    241241        ~ProgramExecutable();
    242242
    243         ProgramCodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode)
    244         {
    245             if (!m_programCodeBlock) {
    246                 JSObject* error = compile(exec, scopeChainNode);
    247                 ASSERT_UNUSED(!error, error);
    248             }
     243        JSObject* compile(ExecState* exec, ScopeChainNode* scopeChainNode)
     244        {
     245            JSObject* error = 0;
     246            if (!m_programCodeBlock)
     247                error = compileInternal(exec, scopeChainNode);
     248            ASSERT(!error == !!m_programCodeBlock);
     249            return error;
     250        }
     251
     252        ProgramCodeBlock& generatedBytecode()
     253        {
     254            ASSERT(m_programCodeBlock);
    249255            return *m_programCodeBlock;
    250256        }
    251257
    252258        JSObject* checkSyntax(ExecState*);
    253         JSObject* compile(ExecState*, ScopeChainNode*);
     259
     260#if ENABLE(JIT)
     261        JITCode& generatedJITCode()
     262        {
     263            return generatedJITCodeForCall();
     264        }
     265#endif
    254266
    255267    private:
     
    260272        }
    261273
     274        JSObject* compileInternal(ExecState*, ScopeChainNode*);
     275
    262276        virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
    263277
    264278        ProgramCodeBlock* m_programCodeBlock;
    265 
    266 #if ENABLE(JIT)
    267     public:
    268         JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode)
    269         {
    270             if (!m_jitCodeForCall)
    271                 generateJITCode(exec, scopeChainNode);
    272             return m_jitCodeForCall;
    273         }
    274 
    275     private:
    276         void generateJITCode(ExecState*, ScopeChainNode*);
    277 #endif
    278279    };
    279280
     
    301302        // for answering questions that that don't vary between call and construct --
    302303        // for example, argumentsRegister().
    303         FunctionCodeBlock& generatedByteCode()
     304        FunctionCodeBlock& generatedBytecode()
    304305        {
    305306            if (m_codeBlockForCall)
     
    309310        }
    310311
    311         FunctionCodeBlock* bytecodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode)
    312         {
    313             ASSERT(scopeChainNode);
     312        JSObject* compileForCall(ExecState* exec, ScopeChainNode* scopeChainNode)
     313        {
     314            JSObject* error = 0;
    314315            if (!m_codeBlockForCall)
    315                 compileForCall(exec, scopeChainNode);
    316             return m_codeBlockForCall;
     316                error = compileForCallInternal(exec, scopeChainNode);
     317            ASSERT(!error == !!m_codeBlockForCall);
     318            return error;
    317319        }
    318320
     
    328330        }
    329331
    330         FunctionCodeBlock* bytecodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode)
    331         {
    332             ASSERT(scopeChainNode);
     332        JSObject* compileForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode)
     333        {
     334            JSObject* error = 0;
    333335            if (!m_codeBlockForConstruct)
    334                 compileForConstruct(exec, scopeChainNode);
    335             return m_codeBlockForConstruct;
     336                error = compileForConstructInternal(exec, scopeChainNode);
     337            ASSERT(!error == !!m_codeBlockForConstruct);
     338            return error;
    336339        }
    337340
     
    355358        void recompile(ExecState*);
    356359        void markAggregate(MarkStack& markStack);
    357         static PassRefPtr<FunctionExecutable> fromGlobalCode(const Identifier&, ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0);
     360        static PassRefPtr<FunctionExecutable> fromGlobalCode(const Identifier&, ExecState*, Debugger*, const SourceCode&, JSObject** exception);
    358361
    359362    private:
     
    386389        }
    387390
    388         bool compileForCall(ExecState*, ScopeChainNode*);
    389         bool compileForConstruct(ExecState*, ScopeChainNode*);
     391        JSObject* compileForCallInternal(ExecState*, ScopeChainNode*);
     392        JSObject* compileForConstructInternal(ExecState*, ScopeChainNode*);
    390393
    391394        virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
     
    402405#if ENABLE(JIT)
    403406    public:
    404         JITCode& jitCodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode)
    405         {
    406             if (!m_jitCodeForCall)
    407                 generateJITCodeForCall(exec, scopeChainNode);
    408             return m_jitCodeForCall;
    409         }
    410 
    411         JITCode& jitCodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode)
    412         {
    413             if (!m_jitCodeForConstruct)
    414                 generateJITCodeForConstruct(exec, scopeChainNode);
    415             return m_jitCodeForConstruct;
    416         }
    417        
    418         bool tryJitCodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode)
    419         {
    420             FunctionCodeBlock* codeBlock = bytecodeForCall(exec, scopeChainNode);
    421             if (!codeBlock)
    422                 return false;
    423             if (!m_jitCodeForCall)
    424                 generateJITCodeForCall(exec, scopeChainNode);
    425             return true;
    426         }
    427        
    428         bool tryJitCodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode)
    429         {
    430             FunctionCodeBlock* codeBlock = bytecodeForConstruct(exec, scopeChainNode);
    431             if (!codeBlock)
    432                 return false;
    433             if (!m_jitCodeForConstruct)
    434                 generateJITCodeForConstruct(exec, scopeChainNode);
    435             return true;
    436         }
    437 
    438407        MacroAssemblerCodePtr generatedJITCodeForCallWithArityCheck()
    439408        {
     
    449418            return m_jitCodeForConstructWithArityCheck;
    450419        }
    451 
    452     private:
    453         void generateJITCodeForCall(ExecState*, ScopeChainNode*);
    454         void generateJITCodeForConstruct(ExecState*, ScopeChainNode*);
    455420#endif
    456421    };
Note: See TracChangeset for help on using the changeset viewer.