diff options
Diffstat (limited to 'JavaScriptCore/runtime/Executable.h')
-rw-r--r-- | JavaScriptCore/runtime/Executable.h | 168 |
1 files changed, 61 insertions, 107 deletions
diff --git a/JavaScriptCore/runtime/Executable.h b/JavaScriptCore/runtime/Executable.h index 516d6ce..10dfb34 100644 --- a/JavaScriptCore/runtime/Executable.h +++ b/JavaScriptCore/runtime/Executable.h @@ -98,6 +98,8 @@ namespace JSC { public: static PassRefPtr<NativeExecutable> create(MacroAssemblerCodePtr callThunk, NativeFunction function, MacroAssemblerCodePtr constructThunk, NativeFunction constructor) { + if (!callThunk) + return adoptRef(new NativeExecutable(JITCode(), function, JITCode(), constructor)); return adoptRef(new NativeExecutable(JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor)); } @@ -193,42 +195,38 @@ namespace JSC { ~EvalExecutable(); - EvalCodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode) + JSObject* compile(ExecState* exec, ScopeChainNode* scopeChainNode) { - if (!m_evalCodeBlock) { - JSObject* error = compile(exec, scopeChainNode); - ASSERT_UNUSED(!error, error); - } - return *m_evalCodeBlock; + JSObject* error = 0; + if (!m_evalCodeBlock) + error = compileInternal(exec, scopeChainNode); + ASSERT(!error == !!m_evalCodeBlock); + return error; } - JSObject* compile(ExecState*, ScopeChainNode*); - - static PassRefPtr<EvalExecutable> create(ExecState* exec, const SourceCode& source) { return adoptRef(new EvalExecutable(exec, source)); } - - private: - EvalExecutable(ExecState* exec, const SourceCode& source) - : ScriptExecutable(exec, source) - , m_evalCodeBlock(0) + EvalCodeBlock& generatedBytecode() { + ASSERT(m_evalCodeBlock); + return *m_evalCodeBlock; } - virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*); - - EvalCodeBlock* m_evalCodeBlock; + static PassRefPtr<EvalExecutable> create(ExecState* exec, const SourceCode& source) { return adoptRef(new EvalExecutable(exec, source)); } #if ENABLE(JIT) - public: - JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode) + JITCode& generatedJITCode() { - if (!m_jitCodeForCall) - generateJITCode(exec, scopeChainNode); - return m_jitCodeForCall; + return generatedJITCodeForCall(); } +#endif private: - void generateJITCode(ExecState*, ScopeChainNode*); -#endif + EvalExecutable(ExecState*, const SourceCode&); + + JSObject* compileInternal(ExecState*, ScopeChainNode*); + + virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*); + + OwnPtr<EvalCodeBlock> m_evalCodeBlock; }; class ProgramExecutable : public ScriptExecutable { @@ -240,41 +238,38 @@ namespace JSC { ~ProgramExecutable(); - ProgramCodeBlock& bytecode(ExecState* exec, ScopeChainNode* scopeChainNode) + JSObject* compile(ExecState* exec, ScopeChainNode* scopeChainNode) { - if (!m_programCodeBlock) { - JSObject* error = compile(exec, scopeChainNode); - ASSERT_UNUSED(!error, error); - } - return *m_programCodeBlock; + JSObject* error = 0; + if (!m_programCodeBlock) + error = compileInternal(exec, scopeChainNode); + ASSERT(!error == !!m_programCodeBlock); + return error; } - JSObject* checkSyntax(ExecState*); - JSObject* compile(ExecState*, ScopeChainNode*); - - private: - ProgramExecutable(ExecState* exec, const SourceCode& source) - : ScriptExecutable(exec, source) - , m_programCodeBlock(0) + ProgramCodeBlock& generatedBytecode() { + ASSERT(m_programCodeBlock); + return *m_programCodeBlock; } - virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*); - - ProgramCodeBlock* m_programCodeBlock; + JSObject* checkSyntax(ExecState*); #if ENABLE(JIT) - public: - JITCode& jitCode(ExecState* exec, ScopeChainNode* scopeChainNode) + JITCode& generatedJITCode() { - if (!m_jitCodeForCall) - generateJITCode(exec, scopeChainNode); - return m_jitCodeForCall; + return generatedJITCodeForCall(); } +#endif private: - void generateJITCode(ExecState*, ScopeChainNode*); -#endif + ProgramExecutable(ExecState*, const SourceCode&); + + JSObject* compileInternal(ExecState*, ScopeChainNode*); + + virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*); + + OwnPtr<ProgramCodeBlock> m_programCodeBlock; }; class FunctionExecutable : public ScriptExecutable { @@ -300,7 +295,7 @@ namespace JSC { // Returns either call or construct bytecode. This can be appropriate // for answering questions that that don't vary between call and construct -- // for example, argumentsRegister(). - FunctionCodeBlock& generatedByteCode() + FunctionCodeBlock& generatedBytecode() { if (m_codeBlockForCall) return *m_codeBlockForCall; @@ -308,12 +303,13 @@ namespace JSC { return *m_codeBlockForConstruct; } - FunctionCodeBlock* bytecodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode) + JSObject* compileForCall(ExecState* exec, ScopeChainNode* scopeChainNode) { - ASSERT(scopeChainNode); + JSObject* error = 0; if (!m_codeBlockForCall) - compileForCall(exec, scopeChainNode); - return m_codeBlockForCall; + error = compileForCallInternal(exec, scopeChainNode); + ASSERT(!error == !!m_codeBlockForCall); + return error; } bool isGeneratedForCall() const @@ -327,12 +323,13 @@ namespace JSC { return *m_codeBlockForCall; } - FunctionCodeBlock* bytecodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode) + JSObject* compileForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode) { - ASSERT(scopeChainNode); + JSObject* error = 0; if (!m_codeBlockForConstruct) - compileForConstruct(exec, scopeChainNode); - return m_codeBlockForConstruct; + error = compileForConstructInternal(exec, scopeChainNode); + ASSERT(!error == !!m_codeBlockForConstruct); + return error; } bool isGeneratedForConstruct() const @@ -353,40 +350,15 @@ namespace JSC { SharedSymbolTable* symbolTable() const { return m_symbolTable; } void recompile(ExecState*); - void markAggregate(MarkStack& markStack); - static PassRefPtr<FunctionExecutable> fromGlobalCode(const Identifier&, ExecState*, Debugger*, const SourceCode&, int* errLine = 0, UString* errMsg = 0); + void markAggregate(MarkStack&); + static PassRefPtr<FunctionExecutable> fromGlobalCode(const Identifier&, ExecState*, Debugger*, const SourceCode&, JSObject** exception); private: - FunctionExecutable(JSGlobalData* globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine) - : ScriptExecutable(globalData, source) - , m_numVariables(0) - , m_forceUsesArguments(forceUsesArguments) - , m_parameters(parameters) - , m_codeBlockForCall(0) - , m_codeBlockForConstruct(0) - , m_name(name) - , m_symbolTable(0) - { - m_firstLine = firstLine; - m_lastLine = lastLine; - } + FunctionExecutable(JSGlobalData*, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, int firstLine, int lastLine); + FunctionExecutable(ExecState*, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, int firstLine, int lastLine); - FunctionExecutable(ExecState* exec, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine) - : ScriptExecutable(exec, source) - , m_numVariables(0) - , m_forceUsesArguments(forceUsesArguments) - , m_parameters(parameters) - , m_codeBlockForCall(0) - , m_codeBlockForConstruct(0) - , m_name(name) - , m_symbolTable(0) - { - m_firstLine = firstLine; - m_lastLine = lastLine; - } - - bool compileForCall(ExecState*, ScopeChainNode*); - bool compileForConstruct(ExecState*, ScopeChainNode*); + JSObject* compileForCallInternal(ExecState*, ScopeChainNode*); + JSObject* compileForConstructInternal(ExecState*, ScopeChainNode*); virtual PassOwnPtr<ExceptionInfo> reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*); @@ -394,27 +366,13 @@ namespace JSC { bool m_forceUsesArguments : 1; RefPtr<FunctionParameters> m_parameters; - FunctionCodeBlock* m_codeBlockForCall; - FunctionCodeBlock* m_codeBlockForConstruct; + OwnPtr<FunctionCodeBlock> m_codeBlockForCall; + OwnPtr<FunctionCodeBlock> m_codeBlockForConstruct; Identifier m_name; SharedSymbolTable* m_symbolTable; #if ENABLE(JIT) public: - JITCode& jitCodeForCall(ExecState* exec, ScopeChainNode* scopeChainNode) - { - if (!m_jitCodeForCall) - generateJITCodeForCall(exec, scopeChainNode); - return m_jitCodeForCall; - } - - JITCode& jitCodeForConstruct(ExecState* exec, ScopeChainNode* scopeChainNode) - { - if (!m_jitCodeForConstruct) - generateJITCodeForConstruct(exec, scopeChainNode); - return m_jitCodeForConstruct; - } - MacroAssemblerCodePtr generatedJITCodeForCallWithArityCheck() { ASSERT(m_jitCodeForCall); @@ -428,10 +386,6 @@ namespace JSC { ASSERT(m_jitCodeForConstructWithArityCheck); return m_jitCodeForConstructWithArityCheck; } - - private: - void generateJITCodeForCall(ExecState*, ScopeChainNode*); - void generateJITCodeForConstruct(ExecState*, ScopeChainNode*); #endif }; |