* configure.ac (static-classpath): Removed.
[cacao.git] / src / vm / jit / patcher.h
1 /* src/vm/jit/patcher.h - code patching functions
2
3    Copyright (C) 1996-2005, 2006, 2007 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 */
26
27
28 #ifndef _PATCHER_H
29 #define _PATCHER_H
30
31 #include "config.h"
32
33 #include <assert.h>
34
35 #include "vm/types.h"
36
37 #include "threads/lock-common.h"
38
39 #include "vm/global.h"
40
41
42 #if defined(__ALPHA__) || defined(__ARM__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__S390__)
43 # error "you should no longer include this file"
44 #else
45
46
47 /* patcher macros *************************************************************/
48
49 #define PATCHER_FLAG_PATCHED    (vftbl_t *) 0xdeadbeef
50
51
52 #if defined(ENABLE_THREADS)
53
54 #define PATCHER_MONITORENTER \
55         /* enter a monitor on the patching position */       \
56                                                              \
57         lock_monitor_enter(o);                               \
58                                                              \
59         /* check if the position has already been patched */ \
60                                                              \
61         if (o->vftbl != NULL) {                              \
62         assert(o->vftbl == PATCHER_FLAG_PATCHED);        \
63                                                          \
64                 lock_monitor_exit(o);                            \
65                                                              \
66                 return NULL;                                     \
67         }                                                    \
68
69
70 #define PATCHER_MONITOREXIT \
71         /* leave the monitor on the patching position */     \
72                                                              \
73         lock_monitor_exit(o);
74
75
76 #define PATCHER_MARK_PATCHED_MONITOREXIT \
77         /* mark position as patched */                       \
78                                                              \
79         o->vftbl = PATCHER_FLAG_PATCHED;                     \
80                                                              \
81         PATCHER_MONITOREXIT
82
83 #else
84
85 #define PATCHER_MONITORENTER                 /* nop */
86 #define PATCHER_MONITOREXIT                  /* nop */
87 #define PATCHER_MARK_PATCHED_MONITOREXIT     /* nop */
88
89 #endif /* defined(ENABLE_THREADS) */
90
91
92 /* function prototypes ********************************************************/
93
94 java_object_t *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra);
95 #define PATCHER_wrapper (functionptr) patcher_wrapper
96
97 bool patcher_resolve_class(u1 *sp);
98 #define PATCHER_resolve_class (functionptr) patcher_resolve_class
99
100 bool patcher_initialize_class(u1 *sp);
101 #define PATCHER_initialize_class (functionptr) patcher_initialize_class
102
103 bool patcher_resolve_classref_to_classinfo(u1 *sp);
104 #define PATCHER_resolve_classref_to_classinfo (functionptr) patcher_resolve_classref_to_classinfo
105
106 bool patcher_resolve_classref_to_vftbl(u1 *sp);
107 #define PATCHER_resolve_classref_to_vftbl (functionptr) patcher_resolve_classref_to_vftbl
108
109 bool patcher_resolve_classref_to_flags(u1 *sp);
110 #define PATCHER_resolve_classref_to_flags (functionptr) patcher_resolve_classref_to_flags
111
112 bool patcher_resolve_native_function(u1 *sp);
113 #define PATCHER_resolve_native_function (functionptr) patcher_resolve_native_function
114
115
116 bool patcher_get_putstatic(u1 *sp);
117 #define PATCHER_get_putstatic (functionptr) patcher_get_putstatic
118
119 #if defined(__I386__)
120
121 bool patcher_getfield(u1 *sp);
122 #define PATCHER_getfield (functionptr) patcher_getfield
123
124 bool patcher_putfield(u1 *sp);
125 #define PATCHER_putfield (functionptr) patcher_putfield
126
127 #else
128
129 bool patcher_get_putfield(u1 *sp);
130 #define PATCHER_get_putfield (functionptr) patcher_get_putfield
131
132 #endif /* defined(__I386__) */
133
134 #if defined(__I386__) || defined(__X86_64__)
135
136 bool patcher_putfieldconst(u1 *sp);
137 #define PATCHER_putfieldconst (functionptr) patcher_putfieldconst
138
139 #endif /* defined(__I386__) || defined(__X86_64__) */
140
141 bool patcher_aconst(u1 *sp);
142 #define PATCHER_aconst (functionptr) patcher_aconst
143
144 bool patcher_builtin_multianewarray(u1 *sp);
145 #define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray
146
147 bool patcher_builtin_arraycheckcast(u1 *sp);
148 #define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast
149
150 bool patcher_invokestatic_special(u1 *sp);
151 #define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special
152
153 bool patcher_invokevirtual(u1 *sp);
154 #define PATCHER_invokevirtual (functionptr) patcher_invokevirtual
155
156 bool patcher_invokeinterface(u1 *sp);
157 #define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
158
159
160 /* only for interpreter */
161 bool patcher_checkcast_instanceof(u1 *sp);
162 #define PATCHER_checkcast_instanceof (functionptr) patcher_checkcast_instanceof
163
164
165 bool patcher_checkcast_instanceof_flags(u1 *sp);
166 #define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
167
168 bool patcher_checkcast_instanceof_interface(u1 *sp);
169 #define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
170
171 bool patcher_checkcast_interface(u1 *sp);
172 #define PATCHER_checkcast_interface (functionptr) patcher_checkcast_interface
173
174 bool patcher_instanceof_interface(u1 *sp);
175 #define PATCHER_instanceof_interface (functionptr) patcher_instanceof_interface
176
177 #if defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)
178
179 bool patcher_checkcast_class(u1 *sp);
180 #define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
181
182 bool patcher_instanceof_class(u1 *sp);
183 #define PATCHER_instanceof_class (functionptr) patcher_instanceof_class
184
185 #else /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)*/
186
187 bool patcher_checkcast_instanceof_class(u1 *sp);
188 #define PATCHER_checkcast_instanceof_class (functionptr) patcher_checkcast_instanceof_class
189
190 #endif /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)*/
191
192 bool patcher_clinit(u1 *sp);
193 #define PATCHER_clinit (functionptr) patcher_clinit
194
195 bool patcher_athrow_areturn(u1 *sp);
196 #define PATCHER_athrow_areturn (functionptr) patcher_athrow_areturn
197
198 bool patcher_resolve_native(u1 *sp);
199 #define PATCHER_resolve_native (functionptr) patcher_resolve_native
200
201
202 /* stuff for the interpreter **************************************************/
203
204 #if defined(ENABLE_INTRP)
205 bool intrp_patcher_get_putstatic(u1 *sp);
206 bool intrp_patcher_get_putstatic_clinit(u1 *sp);
207 bool intrp_patcher_get_putfield(u1 *sp);
208 bool intrp_patcher_aconst(u1 *sp);
209 bool intrp_patcher_builtin_multianewarray(u1 *sp);
210 bool intrp_patcher_builtin_arraycheckcast(u1 *sp);
211 bool intrp_patcher_invokestatic_special(u1 *sp);
212 bool intrp_patcher_invokevirtual(u1 *sp);
213 bool intrp_patcher_invokeinterface(u1 *sp);
214 bool intrp_patcher_checkcast_instanceof(u1 *sp);
215 bool intrp_patcher_resolve_native(u1 *sp);
216 #endif /* defined(ENABLE_INTRP) */
217
218 #endif /* architecture list */
219
220 #endif /* _PATCHER_H */
221
222
223 /*
224  * These are local overrides for various environment variables in Emacs.
225  * Please do not remove this and leave it at the end of the file, where
226  * Emacs will automagically detect them.
227  * ---------------------------------------------------------------------
228  * Local variables:
229  * mode: c
230  * indent-tabs-mode: t
231  * c-basic-offset: 4
232  * tab-width: 4
233  * End:
234  * vim:noexpandtab:sw=4:ts=4:
235  */
236