1 /* src/vm/jit/asmpart.h - prototypes for machine specfic functions
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Reinhard Grafl
30 Changes: Christian Thalinger
32 $Id: asmpart.h 4357 2006-01-22 23:33:38Z twisti $
44 #if defined(USE_THREADS)
45 # if defined(NATIVE_THREADS)
46 # include "threads/native/threads.h"
48 # include "threads/green/threads.h"
52 #include "vm/global.h"
53 #include "vm/linker.h"
54 #include "vm/resolve.h"
55 #include "vm/jit/stacktrace.h"
58 /* some macros ****************************************************************/
60 #if defined(ENABLE_JIT)
61 # if defined(ENABLE_INTRP)
63 # define ASM_CALLJAVAFUNCTION(m,a0,a1,a2,a3) \
66 (void) intrp_asm_calljavafunction((m), (a0), (a1), (a2), (a3)); \
68 (void) asm_calljavafunction((m), (a0), (a1), (a2), (a3)); \
71 # define ASM_CALLJAVAFUNCTION_ADR(o,m,a0,a1,a2,a3) \
74 (o) = intrp_asm_calljavafunction((m), (a0), (a1), (a2), (a3)); \
76 (o) = asm_calljavafunction((m), (a0), (a1), (a2), (a3)); \
79 # define ASM_CALLJAVAFUNCTION_INT(i,m,a0,a1,a2,a3) \
82 (i) = intrp_asm_calljavafunction_int((m), (a0), (a1), (a2), (a3)); \
84 (i) = asm_calljavafunction_int((m), (a0), (a1), (a2), (a3)); \
88 # define ASM_CALLJAVAFUNCTION2(m,count,x,callblock) \
91 (void) intrp_asm_calljavafunction2((m), (count), (x), (callblock)); \
93 (void) asm_calljavafunction2((m), (count), (x), (callblock)); \
96 # define ASM_CALLJAVAFUNCTION2_ADR(o,m,count,x,callblock) \
99 (o) = intrp_asm_calljavafunction2((m), (count), (x), (callblock)); \
101 (o) = asm_calljavafunction2((m), (count), (x), (callblock)); \
104 # define ASM_CALLJAVAFUNCTION2_INT(i,m,count,x,callblock) \
107 (i) = intrp_asm_calljavafunction2int((m), (count), (x), (callblock)); \
109 (i) = asm_calljavafunction2int((m), (count), (x), (callblock)); \
112 # define ASM_CALLJAVAFUNCTION2_LONG(l,m,count,x,callblock) \
115 (l) = intrp_asm_calljavafunction2long((m), (count), (x), (callblock)); \
117 (l) = asm_calljavafunction2long((m), (count), (x), (callblock)); \
120 # define ASM_CALLJAVAFUNCTION2_FLOAT(f,m,count,x,callblock) \
123 (f) = intrp_asm_calljavafunction2float((m), (count), (x), (callblock)); \
125 (f) = asm_calljavafunction2float((m), (count), (x), (callblock)); \
128 # define ASM_CALLJAVAFUNCTION2_DOUBLE(d,m,count,x,callblock) \
131 (d) = intrp_asm_calljavafunction2double((m), (count), (x), (callblock)); \
133 (d) = asm_calljavafunction2double((m), (count), (x), (callblock)); \
137 # define ASM_GETCLASSVALUES_ATOMIC(super,sub,out) \
140 intrp_asm_getclassvalues_atomic((super), (sub), (out)); \
142 asm_getclassvalues_atomic((super), (sub), (out)); \
145 # else /* defined(ENABLE_INTRP) */
147 # define ASM_CALLJAVAFUNCTION(m,a0,a1,a2,a3) \
148 (void) asm_calljavafunction((m), (a0), (a1), (a2), (a3))
150 # define ASM_CALLJAVAFUNCTION_ADR(o,m,a0,a1,a2,a3) \
151 (o) = asm_calljavafunction((m), (a0), (a1), (a2), (a3))
153 # define ASM_CALLJAVAFUNCTION_INT(i,m,a0,a1,a2,a3) \
154 (i) = asm_calljavafunction_int((m), (a0), (a1), (a2), (a3))
157 # define ASM_CALLJAVAFUNCTION2(m,count,x,callblock) \
158 (void) asm_calljavafunction2((m), (count), (x), (callblock))
160 # define ASM_CALLJAVAFUNCTION2_ADR(o,m,count,x,callblock) \
161 (o) = asm_calljavafunction2((m), (count), (x), (callblock))
163 # define ASM_CALLJAVAFUNCTION2_INT(i,m,count,x,callblock) \
164 (i) = asm_calljavafunction2int((m), (count), (x), (callblock))
166 # define ASM_CALLJAVAFUNCTION2_LONG(l,m,count,x,callblock) \
167 (l) = asm_calljavafunction2long((m), (count), (x), (callblock))
169 # define ASM_CALLJAVAFUNCTION2_FLOAT(f,m,count,x,callblock) \
170 (f) = asm_calljavafunction2float((m), (count), (x), (callblock))
172 # define ASM_CALLJAVAFUNCTION2_DOUBLE(d,m,count,x,callblock) \
173 (d) = asm_calljavafunction2double((m), (count), (x), (callblock))
176 # define ASM_GETCLASSVALUES_ATOMIC(super,sub,out) \
177 asm_getclassvalues_atomic((super), (sub), (out))
179 # endif /* defined(ENABLE_INTRP) */
181 #else /* defined(ENABLE_JIT) */
183 # define ASM_CALLJAVAFUNCTION(m,a0,a1,a2,a3) \
184 (void) intrp_asm_calljavafunction((m), (a0), (a1), (a2), (a3))
186 # define ASM_CALLJAVAFUNCTION_ADR(o,m,a0,a1,a2,a3) \
187 (o) = intrp_asm_calljavafunction((m), (a0), (a1), (a2), (a3))
189 # define ASM_CALLJAVAFUNCTION_INT(i,m,a0,a1,a2,a3) \
190 (i) = intrp_asm_calljavafunction_int((m), (a0), (a1), (a2), (a3))
193 # define ASM_CALLJAVAFUNCTION2(m,count,x,callblock) \
194 (void) intrp_asm_calljavafunction2((m), (count), (x), (callblock))
196 # define ASM_CALLJAVAFUNCTION2_ADR(o,m,count,x,callblock) \
197 (o) = intrp_asm_calljavafunction2((m), (count), (x), (callblock))
199 # define ASM_CALLJAVAFUNCTION2_INT(i,m,count,x,callblock) \
200 (i) = intrp_asm_calljavafunction2int((m), (count), (x), (callblock))
202 # define ASM_CALLJAVAFUNCTION2_LONG(l,m,count,x,callblock) \
203 (l) = intrp_asm_calljavafunction2long((m), (count), (x), (callblock))
205 # define ASM_CALLJAVAFUNCTION2_FLOAT(f,m,count,x,callblock) \
206 (f) = intrp_asm_calljavafunction2float((m), (count), (x), (callblock))
208 # define ASM_CALLJAVAFUNCTION2_DOUBLE(d,m,count,x,callblock) \
209 (d) = intrp_asm_calljavafunction2double((m), (count), (x), (callblock))
212 # define ASM_GETCLASSVALUES_ATOMIC(super,sub,out) \
213 intrp_asm_getclassvalues_atomic((super), (sub), (out))
215 #endif /* defined(ENABLE_JIT) */
218 typedef struct castinfo castinfo;
227 #if defined(__ALPHA__)
229 determines if the byte support instruction set (21164a and higher)
232 int has_no_x_instr_set(void);
233 void asm_sync_instruction_cache(void);
238 invokes the compiler for untranslated JavaVM methods.
239 Register R0 contains a pointer to the method info structure
240 (prepared by createcompilerstub).
242 void asm_call_jit_compiler(void);
246 This function calls a Java-method (which possibly needs compilation)
247 with up to 4 parameters. This function calls a Java-method (which
248 possibly needs compilation) with up to 4 parameters.
251 #if defined(ENABLE_JIT)
252 java_objectheader *asm_calljavafunction(methodinfo *m,
253 void *arg1, void *arg2,
254 void *arg3, void *arg4);
256 s4 asm_calljavafunction_int(methodinfo *m,
257 void *arg1, void *arg2,
258 void *arg3, void *arg4);
261 #if defined(ENABLE_INTRP)
262 java_objectheader *intrp_asm_calljavafunction(methodinfo *m,
263 void *arg1, void *arg2,
264 void *arg3, void *arg4);
266 s4 intrp_asm_calljavafunction_int(methodinfo *m,
267 void *arg1, void *arg2,
268 void *arg3, void *arg4);
273 This function calls a Java-method (which possibly needs compilation)
274 with up to 4 parameters. This function calls a Java-method (which
275 possibly needs compilation) with up to 4 parameters.
276 also supports a return value
279 #if defined(ENABLE_JIT)
280 java_objectheader *asm_calljavafunction2(methodinfo *m, u4 count, u4 size,
281 jni_callblock *callblock);
283 s4 asm_calljavafunction2int(methodinfo *m, u4 count, u4 size,
284 jni_callblock *callblock);
286 s8 asm_calljavafunction2long(methodinfo *m, u4 count, u4 size,
287 jni_callblock *callblock);
289 float asm_calljavafunction2float(methodinfo *m, u4 count, u4 size,
290 jni_callblock *callblock);
292 double asm_calljavafunction2double(methodinfo *m, u4 count, u4 size,
293 jni_callblock *callblock);
296 #if defined(ENABLE_INTRP)
297 java_objectheader *intrp_asm_calljavafunction2(methodinfo *m, u4 count, u4 size,
298 jni_callblock *callblock);
300 s4 intrp_asm_calljavafunction2int(methodinfo *m, u4 count, u4 size,
301 jni_callblock *callblock);
303 s8 intrp_asm_calljavafunction2long(methodinfo *m, u4 count, u4 size,
304 jni_callblock *callblock);
306 float intrp_asm_calljavafunction2float(methodinfo *m, u4 count, u4 size,
307 jni_callblock *callblock);
309 double intrp_asm_calljavafunction2double(methodinfo *m, u4 count, u4 size,
310 jni_callblock *callblock);
314 /* We need these two labels in codegen.inc to add the asm_calljavafunction*'s
315 into the methodtable */
316 #if defined(__I386__) || defined(__X86_64__)
317 void calljava_xhandler(void);
318 void calljava_xhandler2(void);
321 /* exception handling functions */
323 #if defined(ENABLE_JIT)
324 void asm_handle_exception(void);
325 void asm_handle_nat_exception(void);
328 /* wrapper for code patching functions */
329 void asm_wrapper_patcher(void);
331 void *asm_switchstackandcall(void *stack, void *func, void **stacktopsave, void * p);
333 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
334 extern threadcritnode asm_criticalsections;
338 #if defined(ENABLE_JIT)
339 void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out);
342 #if defined(ENABLE_INTRP)
343 void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out);
347 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
348 void asm_perform_threadswitch(u1 **from, u1 **to, u1 **stackTop);
349 u1* asm_initialize_thread_stack(void *func, u1 *stack);
352 /* may be required on some architectures (at least for PowerPC and ARM) */
353 void asm_cacheflush(void *p, s4 size);
355 #endif /* _ASMPART_H */
359 * These are local overrides for various environment variables in Emacs.
360 * Please do not remove this and leave it at the end of the file, where
361 * Emacs will automagically detect them.
362 * ---------------------------------------------------------------------
365 * indent-tabs-mode: t