Renamed patcher wrapper functions.
[cacao.git] / src / vm / jit / asmpart.h
1 /* src/vm/jit/asmpart.h - prototypes for machine specfic functions
2
3    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    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., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Reinhard Grafl
28             Andreas Krall
29
30    Changes: Christian Thalinger
31
32    $Id: asmpart.h 2327 2005-04-21 22:36:46Z twisti $
33
34 */
35
36
37 #ifndef _ASMPART_H
38 #define _ASMPART_H
39
40 #if defined(USE_THREADS)
41 # if defined(NATIVE_THREADS)
42 #  include "threads/native/threads.h"
43 # else
44 #  include "threads/green/threads.h"
45 # endif
46 #endif
47
48 #include "vm/resolve.h"
49 #include "vm/jit/stacktrace.h"
50
51
52 typedef struct castinfo castinfo;
53
54 struct castinfo {
55         s4 super_baseval;
56         s4 super_diffval;
57         s4 sub_baseval;
58 };
59
60
61 #if defined(__ALPHA__)
62 /* 
63    determines if the byte support instruction set (21164a and higher)
64    is available.
65 */
66 int has_no_x_instr_set();
67 #endif
68
69
70 /* 
71    invokes the compiler for untranslated JavaVM methods.
72    Register R0 contains a pointer to the method info structure
73    (prepared by createcompilerstub).
74 */
75 void asm_call_jit_compiler();
76
77
78 /* 
79    This function calls a Java-method (which possibly needs compilation)
80    with up to 4 parameters. This function calls a Java-method (which
81    possibly needs compilation) with up to 4 parameters.
82 */
83 java_objectheader *asm_calljavafunction(methodinfo *m, void *arg1, void *arg2,
84                                         void *arg3, void *arg4);
85
86 s4 asm_calljavafunction_int(methodinfo *m, void *arg1, void *arg2,
87                                                         void *arg3, void *arg4);
88
89
90 /* 
91    This function calls a Java-method (which possibly needs compilation)
92    with up to 4 parameters. This function calls a Java-method (which
93    possibly needs compilation) with up to 4 parameters. 
94    also supports a return value
95 */
96 java_objectheader *asm_calljavafunction2(methodinfo *m, u4 count, u4 size, void *callblock);
97 s4 asm_calljavafunction2int(methodinfo *m, u4 count, u4 size, void *callblock);
98 s8 asm_calljavafunction2long(methodinfo *m, u4 count, u4 size, void *callblock);
99 float asm_calljavafunction2float(methodinfo *m, u4 count, u4 size, void *callblock);
100 double asm_calljavafunction2double(methodinfo *m, u4 count, u4 size, void *callblock);
101
102 /* We need these two labels in codegen.inc to add the asm_calljavafunction*'s
103    into the methodtable */
104 #if defined(__I386__) || defined(__X86_64__)
105 void calljava_xhandler();
106 void calljava_xhandler2();
107 #endif
108
109 void asm_handle_exception();
110 void asm_handle_nat_exception();
111 void asm_handle_nullptr_exception();
112
113 void asm_handle_builtin_exception(classinfo *);
114 void asm_throw_and_handle_exception();
115 #ifdef __ALPHA__
116 void asm_throw_and_handle_nat_exception();
117 void asm_refillin_and_handle_exception();
118 void asm_throw_and_handle_arrayindexoutofbounds_exception();
119 #endif
120 void asm_throw_and_handle_hardware_arithmetic_exception();
121
122
123 /* wrapper for code patching functions */
124
125 void asm_wrapper_patcher(void);
126
127 void asm_wrapper_patcher_builtin_new(unresolved_class *uc);
128 #define asm_wrapper_patcher_BUILTIN_new (functionptr) asm_wrapper_patcher_builtin_new
129
130 void asm_wrapper_patcher_builtin_newarray(unresolved_class *uc);
131 #define asm_wrapper_patcher_BUILTIN_newarray (functionptr) asm_wrapper_patcher_builtin_newarray
132
133 void asm_wrapper_patcher_builtin_multianewarray(unresolved_class *uc);
134 #define asm_wrapper_patcher_BUILTIN_multianewarray (functionptr) asm_wrapper_patcher_builtin_multianewarray
135
136 void asm_wrapper_patcher_builtin_checkarraycast(unresolved_class *uc);
137 #define asm_wrapper_patcher_BUILTIN_checkarraycast (functionptr) asm_wrapper_patcher_builtin_checkarraycast
138
139 void asm_wrapper_patcher_builtin_arrayinstanceof(unresolved_class *uc);
140 #define asm_wrapper_patcher_BUILTIN_arrayinstanceof (functionptr) asm_wrapper_patcher_builtin_arrayinstanceof
141
142
143 stacktraceelement *asm_get_stackTrace();
144
145 void *asm_switchstackandcall(void *stack, void *func, void **stacktopsave, void * p);
146
147 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
148 extern threadcritnode asm_criticalsections;
149 #endif
150
151 void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out);
152
153 void asm_prepare_native_stackinfo(void*ret,void*stackbegin);
154 void asm_remove_native_stackinfo();
155
156 #if defined(USE_THREADS) && !defined(NATIVE_THREADS)
157 void asm_perform_threadswitch(u1 **from, u1 **to, u1 **stackTop);
158 u1*  asm_initialize_thread_stack(void *func, u1 *stack);
159 #endif
160
161 #endif /* _ASMPART_H */
162
163
164 /*
165  * These are local overrides for various environment variables in Emacs.
166  * Please do not remove this and leave it at the end of the file, where
167  * Emacs will automagically detect them.
168  * ---------------------------------------------------------------------
169  * Local variables:
170  * mode: c
171  * indent-tabs-mode: t
172  * c-basic-offset: 4
173  * tab-width: 4
174  * End:
175  */