mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
| 14 | * its contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 28 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 29 | #ifndef Machine_h |
| 30 | #define Machine_h |
| 31 | |
weinig@apple.com | 49b3250 | 2008-07-06 00:10:04 +0000 | [diff] [blame] | 32 | #include "ArgList.h" |
ggaren@apple.com | 1d72f77 | 2008-07-03 00:47:00 +0000 | [diff] [blame] | 33 | #include "JSCell.h" |
| 34 | #include "JSValue.h" |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 35 | #include "Opcode.h" |
ggaren@apple.com | 82a62d0 | 2008-06-27 22:35:33 +0000 | [diff] [blame] | 36 | #include "RegisterFile.h" |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 37 | #include <wtf/HashMap.h> |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 38 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 39 | namespace JSC { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 40 | |
| 41 | class CodeBlock; |
| 42 | class EvalNode; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 43 | class FunctionBodyNode; |
ggaren@apple.com | 82a62d0 | 2008-06-27 22:35:33 +0000 | [diff] [blame] | 44 | class Instruction; |
kmccullough@apple.com | 70168ee | 2008-09-03 17:35:42 +0000 | [diff] [blame] | 45 | class InternalFunction; |
alp@webkit.org | 7e2b6cd | 2008-10-10 00:50:25 +0000 | [diff] [blame] | 46 | class JITCodeBuffer; |
ggaren@apple.com | 82a62d0 | 2008-06-27 22:35:33 +0000 | [diff] [blame] | 47 | class JSFunction; |
oliver@apple.com | c8f3a75 | 2008-06-28 04:02:03 +0000 | [diff] [blame] | 48 | class JSGlobalObject; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 49 | class ProgramNode; |
| 50 | class Register; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 51 | class ScopeChainNode; |
barraclough@apple.com | eb51bd9 | 2008-07-30 17:38:35 +0000 | [diff] [blame] | 52 | class SamplingTool; |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 53 | |
alp@webkit.org | 7e2b6cd | 2008-10-10 00:50:25 +0000 | [diff] [blame] | 54 | #if ENABLE(CTI) |
| 55 | |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 56 | #if USE(CTI_ARGUMENT) |
| 57 | #define CTI_ARGS void** args |
| 58 | #define ARGS (args) |
| 59 | #else |
mjs@apple.com | 2ac7a45 | 2008-10-17 03:24:41 +0000 | [diff] [blame] | 60 | #define CTI_ARGS void* args, ... |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 61 | #define ARGS (&args) |
| 62 | #endif |
| 63 | |
| 64 | #if USE(FAST_CALL_CTI_ARGUMENT) |
| 65 | |
oliver@apple.com | 2285178 | 2008-10-11 05:49:39 +0000 | [diff] [blame] | 66 | #if COMPILER(MSVC) |
alp@webkit.org | 7e2b6cd | 2008-10-10 00:50:25 +0000 | [diff] [blame] | 67 | #define SFX_CALL __fastcall |
oliver@apple.com | 2285178 | 2008-10-11 05:49:39 +0000 | [diff] [blame] | 68 | #elif COMPILER(GCC) |
| 69 | #define SFX_CALL __attribute__ ((fastcall)) |
alp@webkit.org | 7e2b6cd | 2008-10-10 00:50:25 +0000 | [diff] [blame] | 70 | #else |
oliver@apple.com | 2285178 | 2008-10-11 05:49:39 +0000 | [diff] [blame] | 71 | #error Need to support fastcall calling convention in this compiler |
alp@webkit.org | 7e2b6cd | 2008-10-10 00:50:25 +0000 | [diff] [blame] | 72 | #endif |
oliver@apple.com | 2285178 | 2008-10-11 05:49:39 +0000 | [diff] [blame] | 73 | |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 74 | #else |
| 75 | |
| 76 | #if COMPILER(MSVC) |
| 77 | #define SFX_CALL __cdecl |
| 78 | #else |
| 79 | #define SFX_CALL |
| 80 | #endif |
| 81 | |
| 82 | #endif |
| 83 | |
alp@webkit.org | 5df2ad5 | 2008-10-30 09:35:24 +0000 | [diff] [blame] | 84 | typedef uint64_t VoidPtrPair; |
| 85 | |
| 86 | typedef union |
| 87 | { |
alp@webkit.org | 246f439 | 2008-10-30 12:37:10 +0000 | [diff] [blame] | 88 | struct { void* first; void* second; } s; |
alp@webkit.org | 5df2ad5 | 2008-10-30 09:35:24 +0000 | [diff] [blame] | 89 | VoidPtrPair i; |
| 90 | } VoidPtrPairValue; |
alp@webkit.org | 7e2b6cd | 2008-10-10 00:50:25 +0000 | [diff] [blame] | 91 | #endif |
| 92 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 93 | enum DebugHookID { |
ggaren@apple.com | d0740c8 | 2008-05-28 20:47:13 +0000 | [diff] [blame] | 94 | WillExecuteProgram, |
| 95 | DidExecuteProgram, |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 96 | DidEnterCallFrame, |
oliver@apple.com | 139b529 | 2008-06-03 22:48:52 +0000 | [diff] [blame] | 97 | DidReachBreakpoint, |
ggaren@apple.com | d0740c8 | 2008-05-28 20:47:13 +0000 | [diff] [blame] | 98 | WillLeaveCallFrame, |
| 99 | WillExecuteStatement |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 100 | }; |
| 101 | |
ggaren@apple.com | 4668b2f | 2008-06-02 16:36:01 +0000 | [diff] [blame] | 102 | enum { MaxReentryDepth = 128 }; |
| 103 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 104 | class Machine { |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 105 | friend class CTI; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 106 | public: |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 107 | Machine(); |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 108 | ~Machine(); |
barraclough@apple.com | 7c876fc | 2008-11-11 05:09:46 +0000 | [diff] [blame] | 109 | |
| 110 | void initialize(JSGlobalData*); |
ggaren@apple.com | 82a62d0 | 2008-06-27 22:35:33 +0000 | [diff] [blame] | 111 | |
| 112 | RegisterFile& registerFile() { return m_registerFile; } |
| 113 | |
ggaren@apple.com | e5af6d5 | 2008-09-26 22:43:16 +0000 | [diff] [blame] | 114 | Opcode getOpcode(OpcodeID id) |
| 115 | { |
| 116 | #if HAVE(COMPUTED_GOTO) |
| 117 | return m_opcodeTable[id]; |
| 118 | #else |
| 119 | return id; |
| 120 | #endif |
| 121 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 122 | |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 123 | OpcodeID getOpcodeID(Opcode opcode) |
| 124 | { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 125 | #if HAVE(COMPUTED_GOTO) |
| 126 | ASSERT(isOpcode(opcode)); |
| 127 | return m_opcodeIDTable.get(opcode); |
| 128 | #else |
| 129 | return opcode; |
| 130 | #endif |
| 131 | } |
| 132 | |
| 133 | bool isOpcode(Opcode opcode); |
ggaren@apple.com | 82a62d0 | 2008-06-27 22:35:33 +0000 | [diff] [blame] | 134 | |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 135 | JSValue* execute(ProgramNode*, CallFrame*, ScopeChainNode*, JSObject* thisObj, JSValue** exception); |
| 136 | JSValue* execute(FunctionBodyNode*, CallFrame*, JSFunction*, JSObject* thisObj, const ArgList& args, ScopeChainNode*, JSValue** exception); |
| 137 | JSValue* execute(EvalNode* evalNode, CallFrame* exec, JSObject* thisObj, ScopeChainNode* scopeChain, JSValue** exception); |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 138 | |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 139 | JSValue* retrieveArguments(CallFrame*, JSFunction*) const; |
| 140 | JSValue* retrieveCaller(CallFrame*, InternalFunction*) const; |
| 141 | void retrieveLastCaller(CallFrame*, int& lineNumber, intptr_t& sourceID, UString& sourceURL, JSValue*& function) const; |
ggaren@apple.com | 0c67773 | 2008-09-30 00:46:25 +0000 | [diff] [blame] | 142 | |
darin@apple.com | 8c2bac0 | 2008-10-09 00:40:43 +0000 | [diff] [blame] | 143 | void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc); |
oliver@apple.com | c8f3a75 | 2008-06-28 04:02:03 +0000 | [diff] [blame] | 144 | void setTimeoutTime(unsigned timeoutTime) { m_timeoutTime = timeoutTime; } |
| 145 | |
| 146 | void startTimeoutCheck() |
| 147 | { |
| 148 | if (!m_timeoutCheckCount) |
| 149 | resetTimeoutCheck(); |
| 150 | |
| 151 | ++m_timeoutCheckCount; |
| 152 | } |
| 153 | |
| 154 | void stopTimeoutCheck() |
| 155 | { |
oliver@apple.com | d6eeeaa | 2008-09-24 07:32:23 +0000 | [diff] [blame] | 156 | ASSERT(m_timeoutCheckCount); |
oliver@apple.com | c8f3a75 | 2008-06-28 04:02:03 +0000 | [diff] [blame] | 157 | --m_timeoutCheckCount; |
| 158 | } |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 159 | |
oliver@apple.com | c8f3a75 | 2008-06-28 04:02:03 +0000 | [diff] [blame] | 160 | inline void initTimeout() |
| 161 | { |
oliver@apple.com | d6eeeaa | 2008-09-24 07:32:23 +0000 | [diff] [blame] | 162 | ASSERT(!m_timeoutCheckCount); |
oliver@apple.com | c8f3a75 | 2008-06-28 04:02:03 +0000 | [diff] [blame] | 163 | resetTimeoutCheck(); |
| 164 | m_timeoutTime = 0; |
| 165 | m_timeoutCheckCount = 0; |
| 166 | } |
barraclough@apple.com | eb51bd9 | 2008-07-30 17:38:35 +0000 | [diff] [blame] | 167 | |
ggaren@apple.com | be95ccf | 2008-10-25 19:59:47 +0000 | [diff] [blame] | 168 | void setSampler(SamplingTool* sampler) { m_sampler = sampler; } |
| 169 | SamplingTool* sampler() { return m_sampler; } |
ggaren@apple.com | 82a62d0 | 2008-06-27 22:35:33 +0000 | [diff] [blame] | 170 | |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 171 | #if ENABLE(CTI) |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 172 | |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 173 | static void SFX_CALL cti_timeout_check(CTI_ARGS); |
| 174 | static void SFX_CALL cti_register_file_check(CTI_ARGS); |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 175 | |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 176 | static JSObject* SFX_CALL cti_op_convert_this(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 177 | static void SFX_CALL cti_op_end(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 178 | static JSValue* SFX_CALL cti_op_add(CTI_ARGS); |
| 179 | static JSValue* SFX_CALL cti_op_pre_inc(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 180 | static int SFX_CALL cti_op_loop_if_less(CTI_ARGS); |
| 181 | static int SFX_CALL cti_op_loop_if_lesseq(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 182 | static JSObject* SFX_CALL cti_op_new_object(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 183 | static void SFX_CALL cti_op_put_by_id(CTI_ARGS); |
| 184 | static void SFX_CALL cti_op_put_by_id_second(CTI_ARGS); |
| 185 | static void SFX_CALL cti_op_put_by_id_generic(CTI_ARGS); |
| 186 | static void SFX_CALL cti_op_put_by_id_fail(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 187 | static JSValue* SFX_CALL cti_op_get_by_id(CTI_ARGS); |
| 188 | static JSValue* SFX_CALL cti_op_get_by_id_second(CTI_ARGS); |
| 189 | static JSValue* SFX_CALL cti_op_get_by_id_generic(CTI_ARGS); |
| 190 | static JSValue* SFX_CALL cti_op_get_by_id_fail(CTI_ARGS); |
| 191 | static JSValue* SFX_CALL cti_op_del_by_id(CTI_ARGS); |
| 192 | static JSValue* SFX_CALL cti_op_instanceof(CTI_ARGS); |
| 193 | static JSValue* SFX_CALL cti_op_mul(CTI_ARGS); |
| 194 | static JSObject* SFX_CALL cti_op_new_func(CTI_ARGS); |
barraclough@apple.com | 52eea52 | 2008-11-07 01:30:03 +0000 | [diff] [blame] | 195 | static void* SFX_CALL cti_op_call_JSFunction(CTI_ARGS); |
| 196 | static VoidPtrPair SFX_CALL cti_op_call_arityCheck(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 197 | static JSValue* SFX_CALL cti_op_call_NotJSFunction(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 198 | static void SFX_CALL cti_op_create_arguments(CTI_ARGS); |
cwzwarich@webkit.org | a5fc210 | 2008-10-18 09:44:50 +0000 | [diff] [blame] | 199 | static void SFX_CALL cti_op_create_arguments_no_params(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 200 | static void SFX_CALL cti_op_tear_off_activation(CTI_ARGS); |
| 201 | static void SFX_CALL cti_op_tear_off_arguments(CTI_ARGS); |
ggaren@apple.com | 4b8c0fb | 2008-10-20 16:48:30 +0000 | [diff] [blame] | 202 | static void SFX_CALL cti_op_profile_will_call(CTI_ARGS); |
| 203 | static void SFX_CALL cti_op_profile_did_call(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 204 | static void SFX_CALL cti_op_ret_scopeChain(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 205 | static JSObject* SFX_CALL cti_op_new_array(CTI_ARGS); |
| 206 | static JSValue* SFX_CALL cti_op_resolve(CTI_ARGS); |
| 207 | static JSValue* SFX_CALL cti_op_resolve_global(CTI_ARGS); |
barraclough@apple.com | 52eea52 | 2008-11-07 01:30:03 +0000 | [diff] [blame] | 208 | static JSObject* SFX_CALL cti_op_construct_JSConstruct(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 209 | static JSValue* SFX_CALL cti_op_construct_NotJSConstruct(CTI_ARGS); |
| 210 | static JSValue* SFX_CALL cti_op_get_by_val(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 211 | static VoidPtrPair SFX_CALL cti_op_resolve_func(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 212 | static JSValue* SFX_CALL cti_op_sub(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 213 | static void SFX_CALL cti_op_put_by_val(CTI_ARGS); |
| 214 | static void SFX_CALL cti_op_put_by_val_array(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 215 | static JSValue* SFX_CALL cti_op_lesseq(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 216 | static int SFX_CALL cti_op_loop_if_true(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 217 | static JSValue* SFX_CALL cti_op_resolve_base(CTI_ARGS); |
| 218 | static JSValue* SFX_CALL cti_op_negate(CTI_ARGS); |
| 219 | static JSValue* SFX_CALL cti_op_resolve_skip(CTI_ARGS); |
| 220 | static JSValue* SFX_CALL cti_op_div(CTI_ARGS); |
| 221 | static JSValue* SFX_CALL cti_op_pre_dec(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 222 | static int SFX_CALL cti_op_jless(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 223 | static JSValue* SFX_CALL cti_op_not(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 224 | static int SFX_CALL cti_op_jtrue(CTI_ARGS); |
| 225 | static VoidPtrPair SFX_CALL cti_op_post_inc(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 226 | static JSValue* SFX_CALL cti_op_eq(CTI_ARGS); |
| 227 | static JSValue* SFX_CALL cti_op_lshift(CTI_ARGS); |
| 228 | static JSValue* SFX_CALL cti_op_bitand(CTI_ARGS); |
| 229 | static JSValue* SFX_CALL cti_op_rshift(CTI_ARGS); |
| 230 | static JSValue* SFX_CALL cti_op_bitnot(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 231 | static VoidPtrPair SFX_CALL cti_op_resolve_with_base(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 232 | static JSObject* SFX_CALL cti_op_new_func_exp(CTI_ARGS); |
| 233 | static JSValue* SFX_CALL cti_op_mod(CTI_ARGS); |
| 234 | static JSValue* SFX_CALL cti_op_less(CTI_ARGS); |
| 235 | static JSValue* SFX_CALL cti_op_neq(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 236 | static VoidPtrPair SFX_CALL cti_op_post_dec(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 237 | static JSValue* SFX_CALL cti_op_urshift(CTI_ARGS); |
| 238 | static JSValue* SFX_CALL cti_op_bitxor(CTI_ARGS); |
| 239 | static JSObject* SFX_CALL cti_op_new_regexp(CTI_ARGS); |
| 240 | static JSValue* SFX_CALL cti_op_bitor(CTI_ARGS); |
| 241 | static JSValue* SFX_CALL cti_op_call_eval(CTI_ARGS); |
| 242 | static JSValue* SFX_CALL cti_op_throw(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 243 | static JSPropertyNameIterator* SFX_CALL cti_op_get_pnames(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 244 | static JSValue* SFX_CALL cti_op_next_pname(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 245 | static void SFX_CALL cti_op_push_scope(CTI_ARGS); |
| 246 | static void SFX_CALL cti_op_pop_scope(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 247 | static JSValue* SFX_CALL cti_op_typeof(CTI_ARGS); |
| 248 | static JSValue* SFX_CALL cti_op_is_undefined(CTI_ARGS); |
| 249 | static JSValue* SFX_CALL cti_op_is_boolean(CTI_ARGS); |
| 250 | static JSValue* SFX_CALL cti_op_is_number(CTI_ARGS); |
| 251 | static JSValue* SFX_CALL cti_op_is_string(CTI_ARGS); |
| 252 | static JSValue* SFX_CALL cti_op_is_object(CTI_ARGS); |
| 253 | static JSValue* SFX_CALL cti_op_is_function(CTI_ARGS); |
| 254 | static JSValue* SFX_CALL cti_op_stricteq(CTI_ARGS); |
| 255 | static JSValue* SFX_CALL cti_op_nstricteq(CTI_ARGS); |
| 256 | static JSValue* SFX_CALL cti_op_to_jsnumber(CTI_ARGS); |
| 257 | static JSValue* SFX_CALL cti_op_in(CTI_ARGS); |
| 258 | static JSObject* SFX_CALL cti_op_push_new_scope(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 259 | static void SFX_CALL cti_op_jmp_scopes(CTI_ARGS); |
| 260 | static void SFX_CALL cti_op_put_by_index(CTI_ARGS); |
| 261 | static void* SFX_CALL cti_op_switch_imm(CTI_ARGS); |
| 262 | static void* SFX_CALL cti_op_switch_char(CTI_ARGS); |
| 263 | static void* SFX_CALL cti_op_switch_string(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 264 | static JSValue* SFX_CALL cti_op_del_by_val(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 265 | static void SFX_CALL cti_op_put_getter(CTI_ARGS); |
| 266 | static void SFX_CALL cti_op_put_setter(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 267 | static JSObject* SFX_CALL cti_op_new_error(CTI_ARGS); |
mjs@apple.com | 36f4f42 | 2008-10-15 02:39:52 +0000 | [diff] [blame] | 268 | static void SFX_CALL cti_op_debug(CTI_ARGS); |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 269 | |
oliver@apple.com | 487b61b | 2008-10-30 04:33:21 +0000 | [diff] [blame] | 270 | static JSValue* SFX_CALL cti_allocate_number(CTI_ARGS); |
| 271 | |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 272 | static JSValue* SFX_CALL cti_vm_throw(CTI_ARGS); |
barraclough@apple.com | 3a4eb9b | 2008-10-18 02:51:52 +0000 | [diff] [blame] | 273 | static void* SFX_CALL cti_vm_lazyLinkCall(CTI_ARGS); |
darin@apple.com | 40d7c81 | 2008-10-20 16:22:55 +0000 | [diff] [blame] | 274 | static JSObject* SFX_CALL cti_op_push_activation(CTI_ARGS); |
barraclough@apple.com | 5248a4c | 2008-09-17 19:29:19 +0000 | [diff] [blame] | 275 | |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 276 | #endif // ENABLE(CTI) |
| 277 | |
| 278 | // Default number of ticks before a timeout check should be done. |
| 279 | static const int initialTickCountThreshold = 1024; |
| 280 | |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 281 | bool isJSArray(JSValue* v) { return !JSImmediate::isImmediate(v) && v->asCell()->vptr() == m_jsArrayVptr; } |
| 282 | bool isJSString(JSValue* v) { return !JSImmediate::isImmediate(v) && v->asCell()->vptr() == m_jsStringVptr; } |
ggaren@apple.com | 0c67773 | 2008-09-30 00:46:25 +0000 | [diff] [blame] | 283 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 284 | private: |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 285 | enum ExecutionFlag { Normal, InitializeAndReturn }; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 286 | |
ggaren@apple.com | 68313b0 | 2008-11-13 00:48:23 +0000 | [diff] [blame^] | 287 | NEVER_INLINE JSValue* callEval(CallFrame*, RegisterFile*, Register* argv, int argc, int registerOffset, JSValue*& exceptionValue); |
| 288 | JSValue* execute(EvalNode*, CallFrame*, JSObject* thisObject, int globalRegisterOffset, ScopeChainNode*, JSValue** exception); |
ggaren@apple.com | 82a62d0 | 2008-06-27 22:35:33 +0000 | [diff] [blame] | 289 | |
darin@apple.com | 8c2bac0 | 2008-10-09 00:40:43 +0000 | [diff] [blame] | 290 | NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine); |
ggaren@apple.com | b5b6b9a | 2008-07-16 22:47:32 +0000 | [diff] [blame] | 291 | |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 292 | NEVER_INLINE bool resolve(CallFrame*, Instruction*, JSValue*& exceptionValue); |
| 293 | NEVER_INLINE bool resolveSkip(CallFrame*, Instruction*, JSValue*& exceptionValue); |
| 294 | NEVER_INLINE bool resolveGlobal(CallFrame*, Instruction*, JSValue*& exceptionValue); |
darin@apple.com | 8c2bac0 | 2008-10-09 00:40:43 +0000 | [diff] [blame] | 295 | NEVER_INLINE void resolveBase(CallFrame*, Instruction* vPC); |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 296 | NEVER_INLINE bool resolveBaseAndProperty(CallFrame*, Instruction*, JSValue*& exceptionValue); |
darin@apple.com | 8c2bac0 | 2008-10-09 00:40:43 +0000 | [diff] [blame] | 297 | NEVER_INLINE ScopeChainNode* createExceptionScope(CallFrame*, const Instruction* vPC); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 298 | |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 299 | NEVER_INLINE bool unwindCallFrame(CallFrame*&, JSValue*, const Instruction*&, CodeBlock*&); |
| 300 | NEVER_INLINE Instruction* throwException(CallFrame*&, JSValue*&, const Instruction*, bool); |
| 301 | NEVER_INLINE bool resolveBaseAndFunc(CallFrame*, Instruction*, JSValue*& exceptionValue); |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 302 | |
darin@apple.com | 8c2bac0 | 2008-10-09 00:40:43 +0000 | [diff] [blame] | 303 | static ALWAYS_INLINE CallFrame* slideRegisterWindowForCall(CodeBlock*, RegisterFile*, CallFrame*, size_t registerOffset, int argc); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 304 | |
darin@apple.com | 8c2bac0 | 2008-10-09 00:40:43 +0000 | [diff] [blame] | 305 | static CallFrame* findFunctionCallFrame(CallFrame*, InternalFunction*); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 306 | |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 307 | JSValue* privateExecute(ExecutionFlag, RegisterFile*, CallFrame*, JSValue** exception); |
darin@apple.com | 8c2bac0 | 2008-10-09 00:40:43 +0000 | [diff] [blame] | 308 | |
ggaren@apple.com | 68313b0 | 2008-11-13 00:48:23 +0000 | [diff] [blame^] | 309 | void dumpCallFrame(CallFrame*); |
| 310 | void dumpRegisters(CallFrame*); |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 311 | |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 312 | JSValue* checkTimeout(JSGlobalObject*); |
oliver@apple.com | c8f3a75 | 2008-06-28 04:02:03 +0000 | [diff] [blame] | 313 | void resetTimeoutCheck(); |
| 314 | |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 315 | void tryCacheGetByID(CallFrame*, CodeBlock*, Instruction*, JSValue* baseValue, const Identifier& propertyName, const PropertySlot&); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 316 | void uncacheGetByID(CodeBlock*, Instruction* vPC); |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 317 | void tryCachePutByID(CallFrame*, CodeBlock*, Instruction*, JSValue* baseValue, const PutPropertySlot&); |
weinig@apple.com | 3412bb4 | 2008-09-01 21:22:54 +0000 | [diff] [blame] | 318 | void uncachePutByID(CodeBlock*, Instruction* vPC); |
ggaren@apple.com | 4b8c0fb | 2008-10-20 16:48:30 +0000 | [diff] [blame] | 319 | |
| 320 | bool isCallOpcode(Opcode opcode) { return opcode == getOpcode(op_call) || opcode == getOpcode(op_construct) || opcode == getOpcode(op_call_eval); } |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 321 | |
| 322 | #if ENABLE(CTI) |
ggaren@apple.com | 68313b0 | 2008-11-13 00:48:23 +0000 | [diff] [blame^] | 323 | static void throwStackOverflowPreviousFrame(CallFrame**, JSGlobalData*, void*& returnAddress); |
darin@apple.com | 5a49442 | 2008-10-18 23:08:12 +0000 | [diff] [blame] | 324 | |
darin@apple.com | 44331f8 | 2008-10-24 16:22:51 +0000 | [diff] [blame] | 325 | void tryCTICacheGetByID(CallFrame*, CodeBlock*, void* returnAddress, JSValue* baseValue, const Identifier& propertyName, const PropertySlot&); |
| 326 | void tryCTICachePutByID(CallFrame*, CodeBlock*, void* returnAddress, JSValue* baseValue, const PutPropertySlot&); |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 327 | |
ggaren@apple.com | be95ccf | 2008-10-25 19:59:47 +0000 | [diff] [blame] | 328 | JITCodeBuffer* jitCodeBuffer() const { return m_jitCodeBuffer.get(); } |
| 329 | #endif |
| 330 | |
| 331 | SamplingTool* m_sampler; |
| 332 | |
| 333 | #if ENABLE(CTI) |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 334 | void* m_ctiArrayLengthTrampoline; |
| 335 | void* m_ctiStringLengthTrampoline; |
| 336 | |
| 337 | OwnPtr<JITCodeBuffer> m_jitCodeBuffer; |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 338 | #endif |
| 339 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 340 | int m_reentryDepth; |
oliver@apple.com | c8f3a75 | 2008-06-28 04:02:03 +0000 | [diff] [blame] | 341 | unsigned m_timeoutTime; |
| 342 | unsigned m_timeAtLastCheckTimeout; |
| 343 | unsigned m_timeExecuting; |
| 344 | unsigned m_timeoutCheckCount; |
| 345 | unsigned m_ticksUntilNextTimeoutCheck; |
| 346 | |
ggaren@apple.com | 82a62d0 | 2008-06-27 22:35:33 +0000 | [diff] [blame] | 347 | RegisterFile m_registerFile; |
ggaren@apple.com | 1d72f77 | 2008-07-03 00:47:00 +0000 | [diff] [blame] | 348 | |
| 349 | void* m_jsArrayVptr; |
| 350 | void* m_jsStringVptr; |
mrowe@apple.com | f88a463 | 2008-09-07 05:44:58 +0000 | [diff] [blame] | 351 | void* m_jsFunctionVptr; |
ggaren@apple.com | 82a62d0 | 2008-06-27 22:35:33 +0000 | [diff] [blame] | 352 | |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 353 | #if HAVE(COMPUTED_GOTO) |
ggaren@apple.com | e5af6d5 | 2008-09-26 22:43:16 +0000 | [diff] [blame] | 354 | Opcode m_opcodeTable[numOpcodeIDs]; // Maps OpcodeID => Opcode for compiling |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 355 | HashMap<Opcode, OpcodeID> m_opcodeIDTable; // Maps Opcode => OpcodeID for decompiling |
| 356 | #endif |
| 357 | }; |
weinig@apple.com | a963b96 | 2008-06-05 05:36:55 +0000 | [diff] [blame] | 358 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 359 | } // namespace JSC |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 360 | |
| 361 | #endif // Machine_h |