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 8295 2007-08-11 17:57:24Z michi $
39 #include "threads/lock-common.h"
41 #include "vm/global.h"
44 #if defined(__ALPHA__) || defined(__ARM__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__S390__)
45 # error "you should no longer include this file"
49 /* patcher macros *************************************************************/
51 #define PATCHER_FLAG_PATCHED (vftbl_t *) 0xdeadbeef
54 #if defined(ENABLE_THREADS)
56 #define PATCHER_MONITORENTER \
57 /* enter a monitor on the patching position */ \
59 lock_monitor_enter(o); \
61 /* check if the position has already been patched */ \
63 if (o->vftbl != NULL) { \
64 assert(o->vftbl == PATCHER_FLAG_PATCHED); \
66 lock_monitor_exit(o); \
72 #define PATCHER_MONITOREXIT \
73 /* leave the monitor on the patching position */ \
78 #define PATCHER_MARK_PATCHED_MONITOREXIT \
79 /* mark position as patched */ \
81 o->vftbl = PATCHER_FLAG_PATCHED; \
87 #define PATCHER_MONITORENTER /* nop */
88 #define PATCHER_MONITOREXIT /* nop */
89 #define PATCHER_MARK_PATCHED_MONITOREXIT /* nop */
91 #endif /* defined(ENABLE_THREADS) */
94 /* function prototypes ********************************************************/
96 java_object_t *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra);
97 #define PATCHER_wrapper (functionptr) patcher_wrapper
99 bool patcher_resolve_class(u1 *sp);
100 #define PATCHER_resolve_class (functionptr) patcher_resolve_class
102 bool patcher_initialize_class(u1 *sp);
103 #define PATCHER_initialize_class (functionptr) patcher_initialize_class
105 bool patcher_resolve_classref_to_classinfo(u1 *sp);
106 #define PATCHER_resolve_classref_to_classinfo (functionptr) patcher_resolve_classref_to_classinfo
108 bool patcher_resolve_classref_to_vftbl(u1 *sp);
109 #define PATCHER_resolve_classref_to_vftbl (functionptr) patcher_resolve_classref_to_vftbl
111 bool patcher_resolve_classref_to_flags(u1 *sp);
112 #define PATCHER_resolve_classref_to_flags (functionptr) patcher_resolve_classref_to_flags
114 #if !defined(WITH_STATIC_CLASSPATH)
115 bool patcher_resolve_native_function(u1 *sp);
116 #define PATCHER_resolve_native_function (functionptr) patcher_resolve_native_function
120 bool patcher_get_putstatic(u1 *sp);
121 #define PATCHER_get_putstatic (functionptr) patcher_get_putstatic
123 #if defined(__I386__)
125 bool patcher_getfield(u1 *sp);
126 #define PATCHER_getfield (functionptr) patcher_getfield
128 bool patcher_putfield(u1 *sp);
129 #define PATCHER_putfield (functionptr) patcher_putfield
133 bool patcher_get_putfield(u1 *sp);
134 #define PATCHER_get_putfield (functionptr) patcher_get_putfield
136 #endif /* defined(__I386__) */
138 #if defined(__I386__) || defined(__X86_64__)
140 bool patcher_putfieldconst(u1 *sp);
141 #define PATCHER_putfieldconst (functionptr) patcher_putfieldconst
143 #endif /* defined(__I386__) || defined(__X86_64__) */
145 bool patcher_aconst(u1 *sp);
146 #define PATCHER_aconst (functionptr) patcher_aconst
148 bool patcher_builtin_multianewarray(u1 *sp);
149 #define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray
151 bool patcher_builtin_arraycheckcast(u1 *sp);
152 #define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast
154 bool patcher_invokestatic_special(u1 *sp);
155 #define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special
157 bool patcher_invokevirtual(u1 *sp);
158 #define PATCHER_invokevirtual (functionptr) patcher_invokevirtual
160 bool patcher_invokeinterface(u1 *sp);
161 #define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
164 /* only for interpreter */
165 bool patcher_checkcast_instanceof(u1 *sp);
166 #define PATCHER_checkcast_instanceof (functionptr) patcher_checkcast_instanceof
169 bool patcher_checkcast_instanceof_flags(u1 *sp);
170 #define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
172 bool patcher_checkcast_instanceof_interface(u1 *sp);
173 #define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
175 bool patcher_checkcast_interface(u1 *sp);
176 #define PATCHER_checkcast_interface (functionptr) patcher_checkcast_interface
178 bool patcher_instanceof_interface(u1 *sp);
179 #define PATCHER_instanceof_interface (functionptr) patcher_instanceof_interface
181 #if defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)
183 bool patcher_checkcast_class(u1 *sp);
184 #define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
186 bool patcher_instanceof_class(u1 *sp);
187 #define PATCHER_instanceof_class (functionptr) patcher_instanceof_class
189 #else /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)*/
191 bool patcher_checkcast_instanceof_class(u1 *sp);
192 #define PATCHER_checkcast_instanceof_class (functionptr) patcher_checkcast_instanceof_class
194 #endif /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)*/
196 bool patcher_clinit(u1 *sp);
197 #define PATCHER_clinit (functionptr) patcher_clinit
199 bool patcher_athrow_areturn(u1 *sp);
200 #define PATCHER_athrow_areturn (functionptr) patcher_athrow_areturn
202 #if !defined(WITH_STATIC_CLASSPATH)
203 bool patcher_resolve_native(u1 *sp);
204 #define PATCHER_resolve_native (functionptr) patcher_resolve_native
208 /* stuff for the interpreter **************************************************/
210 #if defined(ENABLE_INTRP)
211 bool intrp_patcher_get_putstatic(u1 *sp);
212 bool intrp_patcher_get_putstatic_clinit(u1 *sp);
213 bool intrp_patcher_get_putfield(u1 *sp);
214 bool intrp_patcher_aconst(u1 *sp);
215 bool intrp_patcher_builtin_multianewarray(u1 *sp);
216 bool intrp_patcher_builtin_arraycheckcast(u1 *sp);
217 bool intrp_patcher_invokestatic_special(u1 *sp);
218 bool intrp_patcher_invokevirtual(u1 *sp);
219 bool intrp_patcher_invokeinterface(u1 *sp);
220 bool intrp_patcher_checkcast_instanceof(u1 *sp);
221 bool intrp_patcher_resolve_native(u1 *sp);
222 #endif /* defined(ENABLE_INTRP) */
224 #endif /* architecture list */
226 #endif /* _PATCHER_H */
230 * These are local overrides for various environment variables in Emacs.
231 * Please do not remove this and leave it at the end of the file, where
232 * Emacs will automagically detect them.
233 * ---------------------------------------------------------------------
236 * indent-tabs-mode: t
240 * vim:noexpandtab:sw=4:ts=4: