49 #include "vm/jit/patcher.hpp"
53 #if defined(ENABLE_THREADS)
57 #if !defined(STORE_ORDER_BARRIER) && !defined(ENABLE_THREADS)
58 #define STORE_ORDER_BARRIER()
63 #define GCC_PR15242_WORKAROUND
64 #ifdef GCC_PR15242_WORKAROUND
66 # define DO_GOTO goto before_goto
69 # define DO_GOTO goto *ip[-1]
74 # define SET_IP(p) do {ip=(p); NEXT_P0;} while (0)
75 # define NEXT_INST (*IP)
76 # define INC_IP(const_inc) do { ip+=(const_inc);} while (0)
78 # define NEXT_P1 (ip++)
79 # define NEXT_P2 do {NEXT_P1_5; DO_GOTO;} while(0)
81 #define NEXT ({DEF_CA NEXT_P1; NEXT_P2;})
82 #define IPTOS NEXT_INST
84 #if defined(__POWERPC__) || defined(__POWERPC64__) || defined(__SPARC__)
88 #if defined(USE_spTOS)
99 #elif defined(__X86_64__)
112 #define SUPER_END vm_count_block(IP)
115 #define vm_uncount_block(_ip)
119 #define THROW0 goto throw
121 #define THROW(_ball) do { \
123 goto *throw_##_ball; \
126 #define THROW(_ball) do { \
127 goto throw_##_ball##1; \
131 #define THROWCODE(_ball) \
134 *exceptionptr = (stacktrace_inline_##_ball(NULL, (u1 *) fp, (u1 *) IP, (u1 *) IP)); \
138 #define CHECK_NULL_PTR(ptr) \
140 if ((ptr) == NULL) { \
141 THROW(nullpointerexception); \
145 #define THROW_CLASSCASTEXCEPTION(o) \
147 classcastexception_object = o; \
148 THROW(classcastexception); \
151 #define CHECK_OUT_OF_BOUNDS(_array, _idx) \
153 if (length_array(_array) <= (u4) (_idx)) { \
154 arrayindexoutofbounds_index = (_idx); \
155 THROW(arrayindexoutofboundsexception); \
159 #define CHECK_ZERO_DIVISOR(_divisor) \
160 { if (_divisor == 0) \
161 THROW(arithmeticexception); \
166 #define access_local_long(_offset) \
167 ( *(s8 *)(((u1 *)fp) + (_offset)) )
170 #define length_array(array) \
171 ( ((java_arrayheader*)(array))->size )
173 #define access_array_int(array, index) \
174 ((((java_intarray*)(array))->data)[index])
176 #define access_array_long(array, index) \
177 ((((java_longarray*)(array))->data)[index])
179 #define access_array_char(array, index) \
180 ((((java_chararray*)(array))->data)[index])
182 #define access_array_short(array, index) \
183 ((((java_shortarray*)(array))->data)[index])
185 #define access_array_byte(array, index) \
186 ((((java_bytearray*)(array))->data)[index])
188 #define access_array_addr(array, index) \
189 ((((java_objectarray*)(array))->data)[index])
191 #define access_array_float(array, index) \
192 ((((java_floatarray*)(array))->data)[index])
195 #define FRAMESIZE(stub) (((Cell *)stub)[1])
198 #define CLEARSTACK(_start, _end) \
199 do {Cell *__start=(_start); MSET(__start,0,u1,(_end)-__start); } while (0)
201 #define CLEARSTACK(_start, _end)
206 #define NAME(_x) if (vm_debug) {fprintf(vm_out, "%lx: %-20s, ", (long)(ip-1), _x); fprintf(vm_out,"fp=%p, sp=%p", fp, sp);}
211 #define LABEL2(name) J_##name: __asm__("");
212 #define LABEL3(name) K_##name: __asm__("");
222 static Inst labels[] = {
223 #define INST_ADDR(_inst) (&&I_##_inst)
224 #include <java-labels.i>
227 #define INST_ADDR(_inst) (&&J_##_inst)
228 #include <java-labels.i>
230 #define INST_ADDR(_inst) (&&K_##_inst)
231 #include <java-labels.i>
237 #include <java-labels.i>
243 Label throw_arithmeticexception = &&throw_arithmeticexception1;
244 Label throw_arrayindexoutofboundsexception = &&throw_arrayindexoutofboundsexception1;
245 Label throw_classcastexception = &&throw_classcastexception1;
246 Label throw_nullpointerexception = &&throw_nullpointerexception1;
247 Label throw_arraystoreexception = &&throw_arraystoreexception1;
248 java_objectheader *classcastexception_object = NULL;
249 s4 arrayindexoutofbounds_index = 0;
252 fprintf(
vm_out,
"entering engine(%p,%p,%p)\n",ip0,
sp,fp);
254 return (java_objectheader *)labels;
263 throw_arithmeticexception = 0;
264 throw_arrayindexoutofboundsexception = 0;
265 throw_classcastexception = 0;
266 throw_nullpointerexception = 0;
267 throw_arraystoreexception = 0;
274 throw_classcastexception1:
276 *exceptionptr = stacktrace_inline_classcastexception(NULL, (
u1 *) fp, (
u1 *)
IP, (
u1 *)
IP, classcastexception_object);
280 throw_arrayindexoutofboundsexception1:
282 *exceptionptr = stacktrace_inline_arrayindexoutofboundsexception(NULL, (
u1 *) fp, (
u1 *)
IP, (
u1 *)
IP, arrayindexoutofbounds_index);
294 #define INST_ADDR(_inst) (&&I_##_inst)
297 after_last:
return NULL;