blob: 28f446d9e827be495734fa80e6effec5542c0cb2 [file] [log] [blame]
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +00001/*
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.coma963b962008-06-05 05:36:55 +000028
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000029#ifndef Machine_h
30#define Machine_h
31
weinig@apple.com49b32502008-07-06 00:10:04 +000032#include "ArgList.h"
ggaren@apple.com1d72f772008-07-03 00:47:00 +000033#include "JSCell.h"
34#include "JSValue.h"
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000035#include "Opcode.h"
ggaren@apple.com82a62d02008-06-27 22:35:33 +000036#include "RegisterFile.h"
weinig@apple.coma963b962008-06-05 05:36:55 +000037#include <wtf/HashMap.h>
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000038
cwzwarich@webkit.org3f782f62008-09-08 01:28:33 +000039namespace JSC {
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000040
41 class CodeBlock;
42 class EvalNode;
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000043 class FunctionBodyNode;
ggaren@apple.com82a62d02008-06-27 22:35:33 +000044 class Instruction;
kmccullough@apple.com70168ee2008-09-03 17:35:42 +000045 class InternalFunction;
alp@webkit.org7e2b6cd2008-10-10 00:50:25 +000046 class JITCodeBuffer;
ggaren@apple.com82a62d02008-06-27 22:35:33 +000047 class JSFunction;
oliver@apple.comc8f3a752008-06-28 04:02:03 +000048 class JSGlobalObject;
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000049 class ProgramNode;
50 class Register;
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000051 class ScopeChainNode;
barraclough@apple.comeb51bd92008-07-30 17:38:35 +000052 class SamplingTool;
weinig@apple.coma963b962008-06-05 05:36:55 +000053
alp@webkit.org7e2b6cd2008-10-10 00:50:25 +000054#if ENABLE(CTI)
55
mjs@apple.com36f4f422008-10-15 02:39:52 +000056#if USE(CTI_ARGUMENT)
57#define CTI_ARGS void** args
58#define ARGS (args)
59#else
mjs@apple.com2ac7a452008-10-17 03:24:41 +000060#define CTI_ARGS void* args, ...
mjs@apple.com36f4f422008-10-15 02:39:52 +000061#define ARGS (&args)
62#endif
63
64#if USE(FAST_CALL_CTI_ARGUMENT)
65
oliver@apple.com22851782008-10-11 05:49:39 +000066#if COMPILER(MSVC)
alp@webkit.org7e2b6cd2008-10-10 00:50:25 +000067#define SFX_CALL __fastcall
oliver@apple.com22851782008-10-11 05:49:39 +000068#elif COMPILER(GCC)
69#define SFX_CALL __attribute__ ((fastcall))
alp@webkit.org7e2b6cd2008-10-10 00:50:25 +000070#else
oliver@apple.com22851782008-10-11 05:49:39 +000071#error Need to support fastcall calling convention in this compiler
alp@webkit.org7e2b6cd2008-10-10 00:50:25 +000072#endif
oliver@apple.com22851782008-10-11 05:49:39 +000073
mjs@apple.com36f4f422008-10-15 02:39:52 +000074#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.org5df2ad52008-10-30 09:35:24 +000084 typedef uint64_t VoidPtrPair;
85
86 typedef union
87 {
alp@webkit.org246f4392008-10-30 12:37:10 +000088 struct { void* first; void* second; } s;
alp@webkit.org5df2ad52008-10-30 09:35:24 +000089 VoidPtrPair i;
90 } VoidPtrPairValue;
alp@webkit.org7e2b6cd2008-10-10 00:50:25 +000091#endif
92
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000093 enum DebugHookID {
ggaren@apple.comd0740c82008-05-28 20:47:13 +000094 WillExecuteProgram,
95 DidExecuteProgram,
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +000096 DidEnterCallFrame,
oliver@apple.com139b5292008-06-03 22:48:52 +000097 DidReachBreakpoint,
ggaren@apple.comd0740c82008-05-28 20:47:13 +000098 WillLeaveCallFrame,
99 WillExecuteStatement
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000100 };
101
ggaren@apple.com4668b2f2008-06-02 16:36:01 +0000102 enum { MaxReentryDepth = 128 };
103
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000104 class Machine {
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000105 friend class CTI;
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000106 public:
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000107 Machine();
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000108 ~Machine();
barraclough@apple.com7c876fc2008-11-11 05:09:46 +0000109
110 void initialize(JSGlobalData*);
ggaren@apple.com82a62d02008-06-27 22:35:33 +0000111
112 RegisterFile& registerFile() { return m_registerFile; }
113
ggaren@apple.come5af6d52008-09-26 22:43:16 +0000114 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.com2f6dfdf2008-05-22 01:20:45 +0000122
weinig@apple.coma963b962008-06-05 05:36:55 +0000123 OpcodeID getOpcodeID(Opcode opcode)
124 {
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000125 #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.com82a62d02008-06-27 22:35:33 +0000134
darin@apple.com44331f82008-10-24 16:22:51 +0000135 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.coma963b962008-06-05 05:36:55 +0000138
darin@apple.com44331f82008-10-24 16:22:51 +0000139 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.com0c677732008-09-30 00:46:25 +0000142
darin@apple.com8c2bac02008-10-09 00:40:43 +0000143 void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc);
oliver@apple.comc8f3a752008-06-28 04:02:03 +0000144 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.comd6eeeaa2008-09-24 07:32:23 +0000156 ASSERT(m_timeoutCheckCount);
oliver@apple.comc8f3a752008-06-28 04:02:03 +0000157 --m_timeoutCheckCount;
158 }
weinig@apple.coma963b962008-06-05 05:36:55 +0000159
oliver@apple.comc8f3a752008-06-28 04:02:03 +0000160 inline void initTimeout()
161 {
oliver@apple.comd6eeeaa2008-09-24 07:32:23 +0000162 ASSERT(!m_timeoutCheckCount);
oliver@apple.comc8f3a752008-06-28 04:02:03 +0000163 resetTimeoutCheck();
164 m_timeoutTime = 0;
165 m_timeoutCheckCount = 0;
166 }
barraclough@apple.comeb51bd92008-07-30 17:38:35 +0000167
ggaren@apple.combe95ccf2008-10-25 19:59:47 +0000168 void setSampler(SamplingTool* sampler) { m_sampler = sampler; }
169 SamplingTool* sampler() { return m_sampler; }
ggaren@apple.com82a62d02008-06-27 22:35:33 +0000170
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000171#if ENABLE(CTI)
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000172
mjs@apple.com36f4f422008-10-15 02:39:52 +0000173 static void SFX_CALL cti_timeout_check(CTI_ARGS);
174 static void SFX_CALL cti_register_file_check(CTI_ARGS);
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000175
darin@apple.com40d7c812008-10-20 16:22:55 +0000176 static JSObject* SFX_CALL cti_op_convert_this(CTI_ARGS);
mjs@apple.com36f4f422008-10-15 02:39:52 +0000177 static void SFX_CALL cti_op_end(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000178 static JSValue* SFX_CALL cti_op_add(CTI_ARGS);
179 static JSValue* SFX_CALL cti_op_pre_inc(CTI_ARGS);
mjs@apple.com36f4f422008-10-15 02:39:52 +0000180 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.com40d7c812008-10-20 16:22:55 +0000182 static JSObject* SFX_CALL cti_op_new_object(CTI_ARGS);
mjs@apple.com36f4f422008-10-15 02:39:52 +0000183 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.com40d7c812008-10-20 16:22:55 +0000187 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.com52eea522008-11-07 01:30:03 +0000195 static void* SFX_CALL cti_op_call_JSFunction(CTI_ARGS);
196 static VoidPtrPair SFX_CALL cti_op_call_arityCheck(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000197 static JSValue* SFX_CALL cti_op_call_NotJSFunction(CTI_ARGS);
mjs@apple.com36f4f422008-10-15 02:39:52 +0000198 static void SFX_CALL cti_op_create_arguments(CTI_ARGS);
cwzwarich@webkit.orga5fc2102008-10-18 09:44:50 +0000199 static void SFX_CALL cti_op_create_arguments_no_params(CTI_ARGS);
mjs@apple.com36f4f422008-10-15 02:39:52 +0000200 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.com4b8c0fb2008-10-20 16:48:30 +0000202 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.com36f4f422008-10-15 02:39:52 +0000204 static void SFX_CALL cti_op_ret_scopeChain(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000205 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.com52eea522008-11-07 01:30:03 +0000208 static JSObject* SFX_CALL cti_op_construct_JSConstruct(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000209 static JSValue* SFX_CALL cti_op_construct_NotJSConstruct(CTI_ARGS);
210 static JSValue* SFX_CALL cti_op_get_by_val(CTI_ARGS);
mjs@apple.com36f4f422008-10-15 02:39:52 +0000211 static VoidPtrPair SFX_CALL cti_op_resolve_func(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000212 static JSValue* SFX_CALL cti_op_sub(CTI_ARGS);
mjs@apple.com36f4f422008-10-15 02:39:52 +0000213 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.com40d7c812008-10-20 16:22:55 +0000215 static JSValue* SFX_CALL cti_op_lesseq(CTI_ARGS);
mjs@apple.com36f4f422008-10-15 02:39:52 +0000216 static int SFX_CALL cti_op_loop_if_true(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000217 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.com36f4f422008-10-15 02:39:52 +0000222 static int SFX_CALL cti_op_jless(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000223 static JSValue* SFX_CALL cti_op_not(CTI_ARGS);
mjs@apple.com36f4f422008-10-15 02:39:52 +0000224 static int SFX_CALL cti_op_jtrue(CTI_ARGS);
225 static VoidPtrPair SFX_CALL cti_op_post_inc(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000226 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.com36f4f422008-10-15 02:39:52 +0000231 static VoidPtrPair SFX_CALL cti_op_resolve_with_base(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000232 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.com36f4f422008-10-15 02:39:52 +0000236 static VoidPtrPair SFX_CALL cti_op_post_dec(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000237 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.com36f4f422008-10-15 02:39:52 +0000243 static JSPropertyNameIterator* SFX_CALL cti_op_get_pnames(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000244 static JSValue* SFX_CALL cti_op_next_pname(CTI_ARGS);
mjs@apple.com36f4f422008-10-15 02:39:52 +0000245 static void SFX_CALL cti_op_push_scope(CTI_ARGS);
246 static void SFX_CALL cti_op_pop_scope(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000247 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.com36f4f422008-10-15 02:39:52 +0000259 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.com40d7c812008-10-20 16:22:55 +0000264 static JSValue* SFX_CALL cti_op_del_by_val(CTI_ARGS);
mjs@apple.com36f4f422008-10-15 02:39:52 +0000265 static void SFX_CALL cti_op_put_getter(CTI_ARGS);
266 static void SFX_CALL cti_op_put_setter(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000267 static JSObject* SFX_CALL cti_op_new_error(CTI_ARGS);
mjs@apple.com36f4f422008-10-15 02:39:52 +0000268 static void SFX_CALL cti_op_debug(CTI_ARGS);
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000269
oliver@apple.com487b61b2008-10-30 04:33:21 +0000270 static JSValue* SFX_CALL cti_allocate_number(CTI_ARGS);
271
darin@apple.com40d7c812008-10-20 16:22:55 +0000272 static JSValue* SFX_CALL cti_vm_throw(CTI_ARGS);
barraclough@apple.com3a4eb9b2008-10-18 02:51:52 +0000273 static void* SFX_CALL cti_vm_lazyLinkCall(CTI_ARGS);
darin@apple.com40d7c812008-10-20 16:22:55 +0000274 static JSObject* SFX_CALL cti_op_push_activation(CTI_ARGS);
barraclough@apple.com5248a4c2008-09-17 19:29:19 +0000275
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000276#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.com44331f82008-10-24 16:22:51 +0000281 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.com0c677732008-09-30 00:46:25 +0000283
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000284 private:
weinig@apple.coma963b962008-06-05 05:36:55 +0000285 enum ExecutionFlag { Normal, InitializeAndReturn };
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000286
ggaren@apple.com68313b02008-11-13 00:48:23 +0000287 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.com82a62d02008-06-27 22:35:33 +0000289
darin@apple.com8c2bac02008-10-09 00:40:43 +0000290 NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine);
ggaren@apple.comb5b6b9a2008-07-16 22:47:32 +0000291
darin@apple.com44331f82008-10-24 16:22:51 +0000292 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.com8c2bac02008-10-09 00:40:43 +0000295 NEVER_INLINE void resolveBase(CallFrame*, Instruction* vPC);
darin@apple.com44331f82008-10-24 16:22:51 +0000296 NEVER_INLINE bool resolveBaseAndProperty(CallFrame*, Instruction*, JSValue*& exceptionValue);
darin@apple.com8c2bac02008-10-09 00:40:43 +0000297 NEVER_INLINE ScopeChainNode* createExceptionScope(CallFrame*, const Instruction* vPC);
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000298
darin@apple.com44331f82008-10-24 16:22:51 +0000299 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.coma963b962008-06-05 05:36:55 +0000302
darin@apple.com8c2bac02008-10-09 00:40:43 +0000303 static ALWAYS_INLINE CallFrame* slideRegisterWindowForCall(CodeBlock*, RegisterFile*, CallFrame*, size_t registerOffset, int argc);
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000304
darin@apple.com8c2bac02008-10-09 00:40:43 +0000305 static CallFrame* findFunctionCallFrame(CallFrame*, InternalFunction*);
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000306
darin@apple.com44331f82008-10-24 16:22:51 +0000307 JSValue* privateExecute(ExecutionFlag, RegisterFile*, CallFrame*, JSValue** exception);
darin@apple.com8c2bac02008-10-09 00:40:43 +0000308
ggaren@apple.com68313b02008-11-13 00:48:23 +0000309 void dumpCallFrame(CallFrame*);
310 void dumpRegisters(CallFrame*);
weinig@apple.coma963b962008-06-05 05:36:55 +0000311
darin@apple.com44331f82008-10-24 16:22:51 +0000312 JSValue* checkTimeout(JSGlobalObject*);
oliver@apple.comc8f3a752008-06-28 04:02:03 +0000313 void resetTimeoutCheck();
314
darin@apple.com44331f82008-10-24 16:22:51 +0000315 void tryCacheGetByID(CallFrame*, CodeBlock*, Instruction*, JSValue* baseValue, const Identifier& propertyName, const PropertySlot&);
weinig@apple.com3412bb42008-09-01 21:22:54 +0000316 void uncacheGetByID(CodeBlock*, Instruction* vPC);
darin@apple.com44331f82008-10-24 16:22:51 +0000317 void tryCachePutByID(CallFrame*, CodeBlock*, Instruction*, JSValue* baseValue, const PutPropertySlot&);
weinig@apple.com3412bb42008-09-01 21:22:54 +0000318 void uncachePutByID(CodeBlock*, Instruction* vPC);
ggaren@apple.com4b8c0fb2008-10-20 16:48:30 +0000319
320 bool isCallOpcode(Opcode opcode) { return opcode == getOpcode(op_call) || opcode == getOpcode(op_construct) || opcode == getOpcode(op_call_eval); }
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000321
322#if ENABLE(CTI)
ggaren@apple.com68313b02008-11-13 00:48:23 +0000323 static void throwStackOverflowPreviousFrame(CallFrame**, JSGlobalData*, void*& returnAddress);
darin@apple.com5a494422008-10-18 23:08:12 +0000324
darin@apple.com44331f82008-10-24 16:22:51 +0000325 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.comf88a4632008-09-07 05:44:58 +0000327
ggaren@apple.combe95ccf2008-10-25 19:59:47 +0000328 JITCodeBuffer* jitCodeBuffer() const { return m_jitCodeBuffer.get(); }
329#endif
330
331 SamplingTool* m_sampler;
332
333#if ENABLE(CTI)
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000334 void* m_ctiArrayLengthTrampoline;
335 void* m_ctiStringLengthTrampoline;
336
337 OwnPtr<JITCodeBuffer> m_jitCodeBuffer;
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000338#endif
339
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000340 int m_reentryDepth;
oliver@apple.comc8f3a752008-06-28 04:02:03 +0000341 unsigned m_timeoutTime;
342 unsigned m_timeAtLastCheckTimeout;
343 unsigned m_timeExecuting;
344 unsigned m_timeoutCheckCount;
345 unsigned m_ticksUntilNextTimeoutCheck;
346
ggaren@apple.com82a62d02008-06-27 22:35:33 +0000347 RegisterFile m_registerFile;
ggaren@apple.com1d72f772008-07-03 00:47:00 +0000348
349 void* m_jsArrayVptr;
350 void* m_jsStringVptr;
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000351 void* m_jsFunctionVptr;
ggaren@apple.com82a62d02008-06-27 22:35:33 +0000352
weinig@apple.coma963b962008-06-05 05:36:55 +0000353#if HAVE(COMPUTED_GOTO)
ggaren@apple.come5af6d52008-09-26 22:43:16 +0000354 Opcode m_opcodeTable[numOpcodeIDs]; // Maps OpcodeID => Opcode for compiling
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000355 HashMap<Opcode, OpcodeID> m_opcodeIDTable; // Maps Opcode => OpcodeID for decompiling
356#endif
357 };
weinig@apple.coma963b962008-06-05 05:36:55 +0000358
cwzwarich@webkit.org3f782f62008-09-08 01:28:33 +0000359} // namespace JSC
mrowe@apple.com2f6dfdf2008-05-22 01:20:45 +0000360
361#endif // Machine_h