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 5077 2006-07-04 19:06:56Z twisti $
45 #include "vm/global.h"
48 /* patcher macros *************************************************************/
50 #define PATCHER_FLAG_PATCHED (vftbl_t *) 0xdeadbeef
53 #if defined(ENABLE_THREADS)
55 #define PATCHER_MONITORENTER \
56 /* enter a monitor on the patching position */ \
58 builtin_monitorenter(o); \
60 /* check if the position has already been patched */ \
62 if (o->vftbl != NULL) { \
63 assert(o->vftbl == PATCHER_FLAG_PATCHED); \
65 builtin_monitorexit(o); \
71 #define PATCHER_MONITOREXIT \
72 /* leave the monitor on the patching position */ \
74 builtin_monitorexit(o);
77 #define PATCHER_MARK_PATCHED_MONITOREXIT \
78 /* mark position as patched */ \
80 o->vftbl = PATCHER_FLAG_PATCHED; \
86 #define PATCHER_MONITORENTER /* nop */
87 #define PATCHER_MONITOREXIT /* nop */
88 #define PATCHER_MARK_PATCHED_MONITOREXIT /* nop */
90 #endif /* defined(ENABLE_THREADS) */
93 /* function prototypes ********************************************************/
95 java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra);
96 #define PATCHER_wrapper (functionptr) patcher_wrapper
98 bool patcher_get_putstatic(u1 *sp);
99 #define PATCHER_get_putstatic (functionptr) patcher_get_putstatic
101 #if defined(__I386__)
103 bool patcher_getfield(u1 *sp);
104 #define PATCHER_getfield (functionptr) patcher_getfield
106 bool patcher_putfield(u1 *sp);
107 #define PATCHER_putfield (functionptr) patcher_putfield
111 bool patcher_get_putfield(u1 *sp);
112 #define PATCHER_get_putfield (functionptr) patcher_get_putfield
114 #endif /* defined(__I386__) */
116 #if defined(__I386__) || defined(__X86_64__)
118 bool patcher_putfieldconst(u1 *sp);
119 #define PATCHER_putfieldconst (functionptr) patcher_putfieldconst
121 #endif /* defined(__I386__) || defined(__X86_64__) */
123 bool patcher_aconst(u1 *sp);
124 #define PATCHER_aconst (functionptr) patcher_aconst
126 bool patcher_builtin_multianewarray(u1 *sp);
127 #define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray
129 bool patcher_builtin_arraycheckcast(u1 *sp);
130 #define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast
132 bool patcher_invokestatic_special(u1 *sp);
133 #define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special
135 bool patcher_invokevirtual(u1 *sp);
136 #define PATCHER_invokevirtual (functionptr) patcher_invokevirtual
138 bool patcher_invokeinterface(u1 *sp);
139 #define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
142 /* only for interpreter */
143 bool patcher_checkcast_instanceof(u1 *sp);
144 #define PATCHER_checkcast_instanceof (functionptr) patcher_checkcast_instanceof
147 bool patcher_checkcast_instanceof_flags(u1 *sp);
148 #define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
150 bool patcher_checkcast_instanceof_interface(u1 *sp);
151 #define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
153 #if defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__)
155 bool patcher_checkcast_class(u1 *sp);
156 #define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
158 bool patcher_instanceof_class(u1 *sp);
159 #define PATCHER_instanceof_class (functionptr) patcher_instanceof_class
161 #else /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) */
163 bool patcher_checkcast_instanceof_class(u1 *sp);
164 #define PATCHER_checkcast_instanceof_class (functionptr) patcher_checkcast_instanceof_class
166 #endif /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) */
168 bool patcher_clinit(u1 *sp);
169 #define PATCHER_clinit (functionptr) patcher_clinit
171 bool patcher_athrow_areturn(u1 *sp);
172 #define PATCHER_athrow_areturn (functionptr) patcher_athrow_areturn
174 #if !defined(WITH_STATIC_CLASSPATH)
175 bool patcher_resolve_native(u1 *sp);
176 #define PATCHER_resolve_native (functionptr) patcher_resolve_native
180 /* stuff for the interpreter **************************************************/
182 #if defined(ENABLE_INTRP)
183 bool intrp_patcher_get_putstatic(u1 *sp);
184 bool intrp_patcher_get_putstatic_clinit(u1 *sp);
185 bool intrp_patcher_get_putfield(u1 *sp);
186 bool intrp_patcher_aconst(u1 *sp);
187 bool intrp_patcher_builtin_multianewarray(u1 *sp);
188 bool intrp_patcher_builtin_arraycheckcast(u1 *sp);
189 bool intrp_patcher_invokestatic_special(u1 *sp);
190 bool intrp_patcher_invokevirtual(u1 *sp);
191 bool intrp_patcher_invokeinterface(u1 *sp);
192 bool intrp_patcher_checkcast_instanceof(u1 *sp);
193 bool intrp_patcher_resolve_native(u1 *sp);
194 #endif /* defined(ENABLE_INTRP) */
196 #endif /* _PATCHER_H */
200 * These are local overrides for various environment variables in Emacs.
201 * Please do not remove this and leave it at the end of the file, where
202 * Emacs will automagically detect them.
203 * ---------------------------------------------------------------------
206 * indent-tabs-mode: t
210 * vim:noexpandtab:sw=4:ts=4: