* src/vm/exceptions.c (exceptions_handle_exception): Check for special
[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             Edwin Steiner
32
33    $Id: asmpart.h 4707 2006-03-30 09:52:49Z twisti $
34
35 */
36
37
38 #ifndef _ASMPART_H
39 #define _ASMPART_H
40
41 #include "config.h"
42 #include "vm/types.h"
43
44
45 #if defined(USE_THREADS)
46 # if defined(NATIVE_THREADS)
47 #  include "threads/native/threads.h"
48 # else
49 #  include "threads/green/threads.h"
50 # endif
51 #endif
52
53 #include "vm/global.h"
54 #include "vm/linker.h"
55 #include "vm/resolve.h"
56 #include "vm/vm.h"
57 #include "vm/jit/replace.h"
58 #include "vm/jit/stacktrace.h"
59
60
61 /* some macros ****************************************************************/
62
63 #if defined(ENABLE_JIT)
64 # if defined(ENABLE_INTRP)
65
66 #  define ASM_GETCLASSVALUES_ATOMIC(super,sub,out) \
67     do { \
68         if (opt_intrp) \
69             intrp_asm_getclassvalues_atomic((super), (sub), (out)); \
70         else \
71             asm_getclassvalues_atomic((super), (sub), (out)); \
72     } while (0)
73
74 # else /* defined(ENABLE_INTRP) */
75
76 #  define ASM_GETCLASSVALUES_ATOMIC(super,sub,out) \
77     asm_getclassvalues_atomic((super), (sub), (out))
78
79 # endif /* defined(ENABLE_INTRP) */
80
81 #else /* defined(ENABLE_JIT) */
82
83 #  define ASM_GETCLASSVALUES_ATOMIC(super,sub,out) \
84     intrp_asm_getclassvalues_atomic((super), (sub), (out))
85
86 #endif /* defined(ENABLE_JIT) */
87
88
89 typedef struct castinfo castinfo;
90
91 struct castinfo {
92         s4 super_baseval;
93         s4 super_diffval;
94         s4 sub_baseval;
95 };
96
97
98 /* function prototypes ********************************************************/
99
100 /* machine dependent initialization */
101 s4   asm_md_init(void);
102
103 /* 
104    invokes the compiler for untranslated JavaVM methods.
105    Register R0 contains a pointer to the method info structure
106    (prepared by createcompilerstub).
107 */
108 void asm_call_jit_compiler(void);
109
110
111 #if defined(ENABLE_JIT)
112 java_objectheader *asm_vm_call_method(methodinfo *m, s4 vmargscount,
113                                                                           vm_arg *vmargs);
114
115 s4     asm_vm_call_method_int(methodinfo *m, s4 vmargscount, vm_arg *vmargs);
116 s8     asm_vm_call_method_long(methodinfo *m, s4 vmargscount, vm_arg *vmargs);
117 float  asm_vm_call_method_float(methodinfo *m, s4 vmargscount, vm_arg *vmargs);
118 double asm_vm_call_method_double(methodinfo *m, s4 vmargscount, vm_arg *vmargs);
119
120 void   asm_vm_call_method_exception_handler(void);
121 #endif
122
123 #if defined(ENABLE_INTRP)
124 java_objectheader *intrp_asm_vm_call_method(methodinfo *m, s4 vmargscount,
125                                                                                         vm_arg *vmargs);
126
127 s4     intrp_asm_vm_call_method_int(methodinfo *m, s4 vmargscount,
128                                                                         vm_arg *vmargs);
129 s8     intrp_asm_vm_call_method_long(methodinfo *m, s4 vmargscount,
130                                                                          vm_arg *vmargs);
131 float  intrp_asm_vm_call_method_float(methodinfo *m, s4 vmargscount,
132                                                                           vm_arg *vmargs);
133 double intrp_asm_vm_call_method_double(methodinfo *m, s4 vmargscount,
134                                                                            vm_arg *vmargs);
135 #endif
136
137
138 /* We need these two labels in codegen.inc to add the asm_calljavafunction*'s
139    into the methodtable */
140 #if defined(__I386__) || defined(__X86_64__)
141 void calljava_xhandler2(void);
142 #endif
143
144 /* exception handling functions */
145
146 #if defined(ENABLE_JIT)
147 void asm_handle_exception(void);
148 void asm_handle_nat_exception(void);
149 #endif
150
151 /* wrapper for code patching functions */
152 void asm_wrapper_patcher(void);
153
154 /* functions for on-stack replacement */
155 void asm_replacement_out(void);
156 void asm_replacement_in(executionstate *es);
157
158 void *asm_switchstackandcall(void *stack, void *func, void **stacktopsave, void * p);
159
160 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
161 extern threadcritnode asm_criticalsections;
162 #endif
163
164
165 #if defined(ENABLE_JIT)
166 void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out);
167 #endif
168
169 #if defined(ENABLE_INTRP)
170 void intrp_asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out);
171 #endif
172
173
174 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
175 void asm_perform_threadswitch(u1 **from, u1 **to, u1 **stackTop);
176 u1*  asm_initialize_thread_stack(void *func, u1 *stack);
177 #endif
178
179 /* cache flush function */
180 void asm_cacheflush(u1 *addr, s4 nbytes);
181
182 #endif /* _ASMPART_H */
183
184
185 /*
186  * These are local overrides for various environment variables in Emacs.
187  * Please do not remove this and leave it at the end of the file, where
188  * Emacs will automagically detect them.
189  * ---------------------------------------------------------------------
190  * Local variables:
191  * mode: c
192  * indent-tabs-mode: t
193  * c-basic-offset: 4
194  * tab-width: 4
195  * End:
196  * vim:noexpandtab:sw=4:ts=4:
197  */