1 /* src/vm/jit/patcher.h - code patching functions
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
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 $Id: patcher.h 7813 2007-04-25 19:20:13Z twisti $
39 #include "threads/lock-common.h"
41 #include "vm/global.h"
44 /* patcher macros *************************************************************/
46 #define PATCHER_FLAG_PATCHED (vftbl_t *) 0xdeadbeef
49 #if defined(ENABLE_THREADS)
51 #define PATCHER_MONITORENTER \
52 /* enter a monitor on the patching position */ \
54 lock_monitor_enter(o); \
56 /* check if the position has already been patched */ \
58 if (o->vftbl != NULL) { \
59 assert(o->vftbl == PATCHER_FLAG_PATCHED); \
61 lock_monitor_exit(o); \
67 #define PATCHER_MONITOREXIT \
68 /* leave the monitor on the patching position */ \
73 #define PATCHER_MARK_PATCHED_MONITOREXIT \
74 /* mark position as patched */ \
76 o->vftbl = PATCHER_FLAG_PATCHED; \
82 #define PATCHER_MONITORENTER /* nop */
83 #define PATCHER_MONITOREXIT /* nop */
84 #define PATCHER_MARK_PATCHED_MONITOREXIT /* nop */
86 #endif /* defined(ENABLE_THREADS) */
89 /* function prototypes ********************************************************/
91 java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra);
92 #define PATCHER_wrapper (functionptr) patcher_wrapper
94 bool patcher_resolve_class(u1 *sp);
95 #define PATCHER_resolve_class (functionptr) patcher_resolve_class
97 bool patcher_initialize_class(u1 *sp);
98 #define PATCHER_initialize_class (functionptr) patcher_initialize_class
100 bool patcher_resolve_classref_to_classinfo(u1 *sp);
101 #define PATCHER_resolve_classref_to_classinfo (functionptr) patcher_resolve_classref_to_classinfo
103 bool patcher_resolve_classref_to_vftbl(u1 *sp);
104 #define PATCHER_resolve_classref_to_vftbl (functionptr) patcher_resolve_classref_to_vftbl
106 bool patcher_resolve_classref_to_flags(u1 *sp);
107 #define PATCHER_resolve_classref_to_flags (functionptr) patcher_resolve_classref_to_flags
109 #if !defined(WITH_STATIC_CLASSPATH)
110 bool patcher_resolve_native_function(u1 *sp);
111 #define PATCHER_resolve_native_function (functionptr) patcher_resolve_native_function
115 bool patcher_get_putstatic(u1 *sp);
116 #define PATCHER_get_putstatic (functionptr) patcher_get_putstatic
118 #if defined(__I386__)
120 bool patcher_getfield(u1 *sp);
121 #define PATCHER_getfield (functionptr) patcher_getfield
123 bool patcher_putfield(u1 *sp);
124 #define PATCHER_putfield (functionptr) patcher_putfield
128 bool patcher_get_putfield(u1 *sp);
129 #define PATCHER_get_putfield (functionptr) patcher_get_putfield
131 #endif /* defined(__I386__) */
133 #if defined(__I386__) || defined(__X86_64__)
135 bool patcher_putfieldconst(u1 *sp);
136 #define PATCHER_putfieldconst (functionptr) patcher_putfieldconst
138 #endif /* defined(__I386__) || defined(__X86_64__) */
140 bool patcher_aconst(u1 *sp);
141 #define PATCHER_aconst (functionptr) patcher_aconst
143 bool patcher_builtin_multianewarray(u1 *sp);
144 #define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray
146 bool patcher_builtin_arraycheckcast(u1 *sp);
147 #define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast
149 bool patcher_invokestatic_special(u1 *sp);
150 #define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special
152 bool patcher_invokevirtual(u1 *sp);
153 #define PATCHER_invokevirtual (functionptr) patcher_invokevirtual
155 bool patcher_invokeinterface(u1 *sp);
156 #define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
159 /* only for interpreter */
160 bool patcher_checkcast_instanceof(u1 *sp);
161 #define PATCHER_checkcast_instanceof (functionptr) patcher_checkcast_instanceof
164 bool patcher_checkcast_instanceof_flags(u1 *sp);
165 #define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
167 bool patcher_checkcast_instanceof_interface(u1 *sp);
168 #define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
170 bool patcher_checkcast_interface(u1 *sp);
171 #define PATCHER_checkcast_interface (functionptr) patcher_checkcast_interface
173 bool patcher_instanceof_interface(u1 *sp);
174 #define PATCHER_instanceof_interface (functionptr) patcher_instanceof_interface
176 #if defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)
178 bool patcher_checkcast_class(u1 *sp);
179 #define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
181 bool patcher_instanceof_class(u1 *sp);
182 #define PATCHER_instanceof_class (functionptr) patcher_instanceof_class
184 #else /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)*/
186 bool patcher_checkcast_instanceof_class(u1 *sp);
187 #define PATCHER_checkcast_instanceof_class (functionptr) patcher_checkcast_instanceof_class
189 #endif /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)*/
191 bool patcher_clinit(u1 *sp);
192 #define PATCHER_clinit (functionptr) patcher_clinit
194 bool patcher_athrow_areturn(u1 *sp);
195 #define PATCHER_athrow_areturn (functionptr) patcher_athrow_areturn
197 #if !defined(WITH_STATIC_CLASSPATH)
198 bool patcher_resolve_native(u1 *sp);
199 #define PATCHER_resolve_native (functionptr) patcher_resolve_native
203 /* stuff for the interpreter **************************************************/
205 #if defined(ENABLE_INTRP)
206 bool intrp_patcher_get_putstatic(u1 *sp);
207 bool intrp_patcher_get_putstatic_clinit(u1 *sp);
208 bool intrp_patcher_get_putfield(u1 *sp);
209 bool intrp_patcher_aconst(u1 *sp);
210 bool intrp_patcher_builtin_multianewarray(u1 *sp);
211 bool intrp_patcher_builtin_arraycheckcast(u1 *sp);
212 bool intrp_patcher_invokestatic_special(u1 *sp);
213 bool intrp_patcher_invokevirtual(u1 *sp);
214 bool intrp_patcher_invokeinterface(u1 *sp);
215 bool intrp_patcher_checkcast_instanceof(u1 *sp);
216 bool intrp_patcher_resolve_native(u1 *sp);
217 #endif /* defined(ENABLE_INTRP) */
219 #endif /* _PATCHER_H */
223 * These are local overrides for various environment variables in Emacs.
224 * Please do not remove this and leave it at the end of the file, where
225 * Emacs will automagically detect them.
226 * ---------------------------------------------------------------------
229 * indent-tabs-mode: t
233 * vim:noexpandtab:sw=4:ts=4: