* src/vm/jit/asmpart.h (ASM_CALLJAVAFUNCTION): Removed.
[cacao.git] / src / vm / jit / asmpart.h
1 /* src/vm/jit/asmpart.h - prototypes for machine specfic functions
2
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
7
8    This file is part of CACAO.
9
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.
14
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.
19
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
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Reinhard Grafl
28             Andreas Krall
29
30    Changes: Christian Thalinger
31
32    $Id: asmpart.h 4553 2006-03-04 17:19:03Z twisti $
33
34 */
35
36
37 #ifndef _ASMPART_H
38 #define _ASMPART_H
39
40 #include "config.h"
41 #include "vm/types.h"
42
43
44 #if defined(USE_THREADS)
45 # if defined(NATIVE_THREADS)
46 #  include "threads/native/threads.h"
47 # else
48 #  include "threads/green/threads.h"
49 # endif
50 #endif
51
52 #include "vm/global.h"
53 #include "vm/linker.h"
54 #include "vm/resolve.h"
55 #include "vm/vm.h"
56 #include "vm/jit/stacktrace.h"
57
58
59 /* some macros ****************************************************************/
60
61 #if defined(ENABLE_JIT)
62 # if defined(ENABLE_INTRP)
63
64 #  define ASM_GETCLASSVALUES_ATOMIC(super,sub,out) \
65     do { \
66         if (opt_intrp) \
67             intrp_asm_getclassvalues_atomic((super), (sub), (out)); \
68         else \
69             asm_getclassvalues_atomic((super), (sub), (out)); \
70     } while (0)
71
72 # else /* defined(ENABLE_INTRP) */
73
74 #  define ASM_GETCLASSVALUES_ATOMIC(super,sub,out) \
75     asm_getclassvalues_atomic((super), (sub), (out))
76
77 # endif /* defined(ENABLE_INTRP) */
78
79 #else /* defined(ENABLE_JIT) */
80
81 #  define ASM_GETCLASSVALUES_ATOMIC(super,sub,out) \
82     intrp_asm_getclassvalues_atomic((super), (sub), (out))
83
84 #endif /* defined(ENABLE_JIT) */
85
86
87 typedef struct castinfo castinfo;
88
89 struct castinfo {
90         s4 super_baseval;
91         s4 super_diffval;
92         s4 sub_baseval;
93 };
94
95
96 /* function prototypes ********************************************************/
97
98 /* machine dependent initialization */
99 s4 asm_md_init(void);
100
101 void asm_sync_instruction_cache(void);
102
103
104 /* 
105    invokes the compiler for untranslated JavaVM methods.
106    Register R0 contains a pointer to the method info structure
107    (prepared by createcompilerstub).
108 */
109 void asm_call_jit_compiler(void);
110
111
112 /* 
113    This function calls a Java-method (which possibly needs compilation)
114    with up to 4 parameters. This function calls a Java-method (which
115    possibly needs compilation) with up to 4 parameters.
116 */
117
118 #if defined(ENABLE_JIT)
119 java_objectheader *asm_calljavafunction(methodinfo *m,
120                                                                                 void *arg1, void *arg2,
121                                                                                 void *arg3, void *arg4);
122
123 s4 asm_calljavafunction_int(methodinfo *m,
124                                                         void *arg1, void *arg2,
125                                                         void *arg3, void *arg4);
126 #endif
127
128 #if defined(ENABLE_INTRP)
129 java_objectheader *intrp_asm_calljavafunction(methodinfo *m,
130                                                                                           void *arg1, void *arg2,
131                                                                                           void *arg3, void *arg4);
132
133 s4 intrp_asm_calljavafunction_int(methodinfo *m,
134                                                                   void *arg1, void *arg2,
135                                                                   void *arg3, void *arg4);
136 #endif
137
138
139 /* 
140    This function calls a Java-method (which possibly needs compilation)
141    with up to 4 parameters. This function calls a Java-method (which
142    possibly needs compilation) with up to 4 parameters. 
143    also supports a return value
144 */
145
146 #if defined(ENABLE_JIT)
147 java_objectheader *asm_calljavafunction2(methodinfo *m, u4 count,
148                                                                                  vm_arg *vmargs);
149
150 s4     asm_calljavafunction2int(methodinfo *m, u4 count, vm_arg *vmargs);
151 s8     asm_calljavafunction2long(methodinfo *m, u4 count, vm_arg *vmargs);
152 float  asm_calljavafunction2float(methodinfo *m, u4 count, vm_arg *vmargs);
153 double asm_calljavafunction2double(methodinfo *m, u4 count, vm_arg *vmargs);
154 #endif
155
156 #if defined(ENABLE_INTRP)
157 java_objectheader *intrp_asm_calljavafunction2(methodinfo *m, u4 count,
158                                                                                            vm_arg *vmargs);
159
160 s4     intrp_asm_calljavafunction2int(methodinfo *m, u4 count, vm_arg *vmargs);
161 s8     intrp_asm_calljavafunction2long(methodinfo *m, u4 count, vm_arg *vmargs);
162 float  intrp_asm_calljavafunction2float(methodinfo *m, u4 count, vm_arg *vmargs);
163 double intrp_asm_calljavafunction2double(methodinfo *m, u4 count, vm_arg *vmargs);
164 #endif
165
166
167 /* We need these two labels in codegen.inc to add the asm_calljavafunction*'s
168    into the methodtable */
169 #if defined(__I386__) || defined(__X86_64__)
170 void calljava_xhandler(void);
171 void calljava_xhandler2(void);
172 #endif
173
174 /* exception handling functions */
175
176 #if defined(ENABLE_JIT)
177 void asm_handle_exception(void);
178 void asm_handle_nat_exception(void);
179 #endif
180
181 /* wrapper for code patching functions */
182 void asm_wrapper_patcher(void);
183
184 void *asm_switchstackandcall(void *stack, void *func, void **stacktopsave, void * p);
185
186 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
187 extern threadcritnode asm_criticalsections;
188 #endif
189
190
191 #if defined(ENABLE_JIT)
192 void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out);
193 #endif
194
195 #if defined(ENABLE_INTRP)
196 void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out);
197 #endif
198
199
200 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
201 void asm_perform_threadswitch(u1 **from, u1 **to, u1 **stackTop);
202 u1*  asm_initialize_thread_stack(void *func, u1 *stack);
203 #endif
204
205 /* may be required on some architectures (at least for PowerPC and ARM) */
206 void asm_cacheflush(void *p, s4 size);
207
208 #endif /* _ASMPART_H */
209
210
211 /*
212  * These are local overrides for various environment variables in Emacs.
213  * Please do not remove this and leave it at the end of the file, where
214  * Emacs will automagically detect them.
215  * ---------------------------------------------------------------------
216  * Local variables:
217  * mode: c
218  * indent-tabs-mode: t
219  * c-basic-offset: 4
220  * tab-width: 4
221  * End:
222  */