1 /* src/vm/jit/patcher.h - code patching functions
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Christian Thalinger
31 $Id: patcher.h 4155 2006-01-12 21:17:46Z twisti $
42 #include "vm/global.h"
45 /* patcher macros *************************************************************/
47 #if defined(USE_THREADS)
49 #define PATCHER_MONITORENTER \
50 /* enter a monitor on the patching position */ \
52 builtin_monitorenter(o); \
54 /* check if the position has already been patched */ \
57 builtin_monitorexit(o); \
63 #define PATCHER_MONITOREXIT \
64 /* leave the monitor on the patching position */ \
66 builtin_monitorexit(o);
69 #define PATCHER_MARK_PATCHED_MONITOREXIT \
70 /* mark position as patched */ \
72 o->vftbl = (vftbl_t *) 1; \
78 #define PATCHER_MONITORENTER /* nop */
79 #define PATCHER_MONITOREXIT /* nop */
80 #define PATCHER_MARK_PATCHED_MONITOREXIT /* nop */
82 #endif /* defined(USE_THREADS) */
85 /* function prototypes ********************************************************/
87 bool patcher_get_putstatic(u1 *sp);
88 #define PATCHER_get_putstatic (functionptr) patcher_get_putstatic
92 bool patcher_getfield(u1 *sp);
93 #define PATCHER_getfield (functionptr) patcher_getfield
95 bool patcher_putfield(u1 *sp);
96 #define PATCHER_putfield (functionptr) patcher_putfield
100 bool patcher_get_putfield(u1 *sp);
101 #define PATCHER_get_putfield (functionptr) patcher_get_putfield
103 #endif /* defined(__I386__) */
105 #if defined(__I386__) || defined(__X86_64__)
107 bool patcher_putfieldconst(u1 *sp);
108 #define PATCHER_putfieldconst (functionptr) patcher_putfieldconst
110 #endif /* defined(__I386__) || defined(__X86_64__) */
112 bool patcher_aconst(u1 *sp);
113 #define PATCHER_aconst (functionptr) patcher_aconst
115 bool patcher_builtin_multianewarray(u1 *sp);
116 #define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray
118 bool patcher_builtin_arraycheckcast(u1 *sp);
119 #define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast
121 bool patcher_invokestatic_special(u1 *sp);
122 #define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special
124 bool patcher_invokevirtual(u1 *sp);
125 #define PATCHER_invokevirtual (functionptr) patcher_invokevirtual
127 bool patcher_invokeinterface(u1 *sp);
128 #define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
131 /* only for interpreter */
132 bool patcher_checkcast_instanceof(u1 *sp);
133 #define PATCHER_checkcast_instanceof (functionptr) patcher_checkcast_instanceof
136 bool patcher_checkcast_instanceof_flags(u1 *sp);
137 #define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
139 bool patcher_checkcast_instanceof_interface(u1 *sp);
140 #define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
142 #if defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__)
144 bool patcher_checkcast_class(u1 *sp);
145 #define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
147 bool patcher_instanceof_class(u1 *sp);
148 #define PATCHER_instanceof_class (functionptr) patcher_instanceof_class
150 #else /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) */
152 bool patcher_checkcast_instanceof_class(u1 *sp);
153 #define PATCHER_checkcast_instanceof_class (functionptr) patcher_checkcast_instanceof_class
155 #endif /* defined(__I386__) || defined(__X86_64__) || defined(__POWERPC__) */
157 bool patcher_clinit(u1 *sp);
158 #define PATCHER_clinit (functionptr) patcher_clinit
160 bool patcher_athrow_areturn(u1 *sp);
161 #define PATCHER_athrow_areturn (functionptr) patcher_athrow_areturn
163 #if !defined(ENABLE_STATICVM)
164 bool patcher_resolve_native(u1 *sp);
165 #define PATCHER_resolve_native (functionptr) patcher_resolve_native
166 #endif /* !defined(ENABLE_STATICVM) */
169 /* stuff for the interpreter **************************************************/
171 #if defined(ENABLE_INTRP)
172 bool intrp_patcher_get_putstatic(u1 *sp);
173 bool intrp_patcher_get_putfield(u1 *sp);
174 bool intrp_patcher_aconst(u1 *sp);
175 bool intrp_patcher_builtin_multianewarray(u1 *sp);
176 bool intrp_patcher_builtin_arraycheckcast(u1 *sp);
177 bool intrp_patcher_invokestatic_special(u1 *sp);
178 bool intrp_patcher_invokevirtual(u1 *sp);
179 bool intrp_patcher_invokeinterface(u1 *sp);
180 bool intrp_patcher_checkcast_instanceof(u1 *sp);
181 bool intrp_patcher_resolve_native(u1 *sp);
182 #endif /* defined(ENABLE_INTRP) */
184 #endif /* _PATCHER_H */
188 * These are local overrides for various environment variables in Emacs.
189 * Please do not remove this and leave it at the end of the file, where
190 * Emacs will automagically detect them.
191 * ---------------------------------------------------------------------
194 * indent-tabs-mode: t
198 * vim:noexpandtab:sw=4:ts=4: