1 /* src/vm/jit/patcher.h - code patching functions
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
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 Contact: cacao@cacaojvm.org
27 Authors: Christian Thalinger
29 Changes: Edwin Steiner
31 $Id: patcher.h 5281 2006-08-28 15:18:54Z twisti $
45 #if defined(ENABLE_THREADS)
46 # include "threads/native/lock.h"
49 #include "vm/global.h"
52 /* patcher macros *************************************************************/
54 #define PATCHER_FLAG_PATCHED (vftbl_t *) 0xdeadbeef
57 #if defined(ENABLE_THREADS)
59 #define PATCHER_MONITORENTER \
60 /* enter a monitor on the patching position */ \
62 lock_monitor_enter(o); \
64 /* check if the position has already been patched */ \
66 if (o->vftbl != NULL) { \
67 assert(o->vftbl == PATCHER_FLAG_PATCHED); \
69 lock_monitor_exit(o); \
75 #define PATCHER_MONITOREXIT \
76 /* leave the monitor on the patching position */ \
81 #define PATCHER_MARK_PATCHED_MONITOREXIT \
82 /* mark position as patched */ \
84 o->vftbl = PATCHER_FLAG_PATCHED; \
90 #define PATCHER_MONITORENTER /* nop */
91 #define PATCHER_MONITOREXIT /* nop */
92 #define PATCHER_MARK_PATCHED_MONITOREXIT /* nop */
94 #endif /* defined(ENABLE_THREADS) */
97 /* function prototypes ********************************************************/
99 java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra);
100 #define PATCHER_wrapper (functionptr) patcher_wrapper
102 bool patcher_resolve_class(u1 *sp);
103 #define PATCHER_resolve_class (functionptr) patcher_resolve_class
105 bool patcher_initialize_class(u1 *sp);
106 #define PATCHER_initialize_class (functionptr) patcher_initialize_class
108 bool patcher_resolve_classref_to_classinfo(u1 *sp);
109 #define PATCHER_resolve_classref_to_classinfo (functionptr) patcher_resolve_classref_to_classinfo
111 bool patcher_resolve_classref_to_vftbl(u1 *sp);
112 #define PATCHER_resolve_classref_to_vftbl (functionptr) patcher_resolve_classref_to_vftbl
114 bool patcher_resolve_classref_to_flags(u1 *sp);
115 #define PATCHER_resolve_classref_to_flags (functionptr) patcher_resolve_classref_to_flags
117 #if !defined(WITH_STATIC_CLASSPATH)
118 bool patcher_resolve_native_function(u1 *sp);
119 #define PATCHER_resolve_native_function (functionptr) patcher_resolve_native_function
123 bool patcher_get_putstatic(u1 *sp);
124 #define PATCHER_get_putstatic (functionptr) patcher_get_putstatic
126 #if defined(__I386__)
128 bool patcher_getfield(u1 *sp);
129 #define PATCHER_getfield (functionptr) patcher_getfield
131 bool patcher_putfield(u1 *sp);
132 #define PATCHER_putfield (functionptr) patcher_putfield
136 bool patcher_get_putfield(u1 *sp);
137 #define PATCHER_get_putfield (functionptr) patcher_get_putfield
139 #endif /* defined(__I386__) */
141 #if defined(__I386__) || defined(__X86_64__)
143 bool patcher_putfieldconst(u1 *sp);
144 #define PATCHER_putfieldconst (functionptr) patcher_putfieldconst
146 #endif /* defined(__I386__) || defined(__X86_64__) */
148 bool patcher_aconst(u1 *sp);
149 #define PATCHER_aconst (functionptr) patcher_aconst
151 bool patcher_builtin_multianewarray(u1 *sp);
152 #define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray
154 bool patcher_builtin_arraycheckcast(u1 *sp);
155 #define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast
157 bool patcher_invokestatic_special(u1 *sp);
158 #define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special
160 bool patcher_invokevirtual(u1 *sp);
161 #define PATCHER_invokevirtual (functionptr) patcher_invokevirtual
163 bool patcher_invokeinterface(u1 *sp);
164 #define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
167 /* only for interpreter */
168 bool patcher_checkcast_instanceof(u1 *sp);
169 #define PATCHER_checkcast_instanceof (functionptr) patcher_checkcast_instanceof
172 bool patcher_checkcast_instanceof_flags(u1 *sp);
173 #define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
175 bool patcher_checkcast_instanceof_interface(u1 *sp);
176 #define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
178 #if defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)
180 bool patcher_checkcast_class(u1 *sp);
181 #define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
183 bool patcher_instanceof_class(u1 *sp);
184 #define PATCHER_instanceof_class (functionptr) patcher_instanceof_class
186 #else /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)*/
188 bool patcher_checkcast_instanceof_class(u1 *sp);
189 #define PATCHER_checkcast_instanceof_class (functionptr) patcher_checkcast_instanceof_class
191 #endif /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) || defined(__POWERPC64__)*/
193 bool patcher_clinit(u1 *sp);
194 #define PATCHER_clinit (functionptr) patcher_clinit
196 bool patcher_athrow_areturn(u1 *sp);
197 #define PATCHER_athrow_areturn (functionptr) patcher_athrow_areturn
199 #if !defined(WITH_STATIC_CLASSPATH)
200 bool patcher_resolve_native(u1 *sp);
201 #define PATCHER_resolve_native (functionptr) patcher_resolve_native
205 /* stuff for the interpreter **************************************************/
207 #if defined(ENABLE_INTRP)
208 bool intrp_patcher_get_putstatic(u1 *sp);
209 bool intrp_patcher_get_putstatic_clinit(u1 *sp);
210 bool intrp_patcher_get_putfield(u1 *sp);
211 bool intrp_patcher_aconst(u1 *sp);
212 bool intrp_patcher_builtin_multianewarray(u1 *sp);
213 bool intrp_patcher_builtin_arraycheckcast(u1 *sp);
214 bool intrp_patcher_invokestatic_special(u1 *sp);
215 bool intrp_patcher_invokevirtual(u1 *sp);
216 bool intrp_patcher_invokeinterface(u1 *sp);
217 bool intrp_patcher_checkcast_instanceof(u1 *sp);
218 bool intrp_patcher_resolve_native(u1 *sp);
219 #endif /* defined(ENABLE_INTRP) */
221 #endif /* _PATCHER_H */
225 * These are local overrides for various environment variables in Emacs.
226 * Please do not remove this and leave it at the end of the file, where
227 * Emacs will automagically detect them.
228 * ---------------------------------------------------------------------
231 * indent-tabs-mode: t
235 * vim:noexpandtab:sw=4:ts=4: