Defined PATCHER_MONITORENTER/EXIT macros (i have some problems to see where
[cacao.git] / src / vm / jit / patcher.h
1 /* src/vm/jit/patcher.h - code patching functions
2
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
7
8    This file is part of CACAO.
9
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.
14
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.
19
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
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Christian Thalinger
28
29    Changes:
30
31    $Id: patcher.h 2527 2005-05-25 08:07:57Z twisti $
32
33 */
34
35 #ifndef _PATCHER_H
36 #define _PATCHER_H
37
38 #include "types.h"
39 #include "vm/global.h"
40
41
42 /* patcher macros *************************************************************/
43
44 #if defined(USE_THREADS)
45
46 #define PATCHER_MONITORENTER \
47         /* enter a monitor on the patching position */       \
48                                                              \
49         builtin_monitorenter(o);                             \
50                                                              \
51         /* check if the position has already been patched */ \
52                                                              \
53         if (o->vftbl) {                                      \
54                 builtin_monitorexit(o);                          \
55                                                              \
56                 return true;                                     \
57         }                                                    \
58
59
60 #define PATCHER_MONITOREXIT \
61         /* mark position as patched */                       \
62                                                              \
63         o->vftbl = (vftbl_t *) 1;                            \
64                                                              \
65         /* leave the monitor on the patching position */     \
66                                                              \
67         builtin_monitorexit(o);                              \
68
69 #else
70
71 #define PATCHER_MONITORENTER    /* nop */
72 #define PATCHER_MONITOREXIT     /* nop */
73
74 #endif /* defined(USE_THREADS) */
75
76
77 /* function prototypes ********************************************************/
78
79 bool patcher_get_putstatic(u1 *sp);
80 #define PATCHER_get_putstatic (functionptr) patcher_get_putstatic
81
82 #if defined(__I386__)
83
84 bool patcher_getfield(u1 *sp);
85 #define PATCHER_getfield (functionptr) patcher_getfield
86
87 bool patcher_putfield(u1 *sp);
88 #define PATCHER_putfield (functionptr) patcher_putfield
89
90 #else
91
92 bool patcher_get_putfield(u1 *sp);
93 #define PATCHER_get_putfield (functionptr) patcher_get_putfield
94
95 #endif /* defined(__I386__) */
96
97 #if defined(__I386__) || defined(__X86_64__)
98 bool patcher_putfieldconst(u1 *sp);
99 #define PATCHER_putfieldconst (functionptr) patcher_putfieldconst
100 #endif
101
102 bool patcher_builtin_new(u1 *sp);
103 #define PATCHER_builtin_new (functionptr) patcher_builtin_new
104
105 bool patcher_builtin_newarray(u1 *sp);
106 #define PATCHER_builtin_newarray (functionptr) patcher_builtin_newarray
107
108 bool patcher_builtin_multianewarray(u1 *sp);
109 #define PATCHER_builtin_multianewarray (functionptr) patcher_builtin_multianewarray
110
111 bool patcher_builtin_arraycheckcast(u1 *sp);
112 #define PATCHER_builtin_arraycheckcast (functionptr) patcher_builtin_arraycheckcast
113
114 bool patcher_builtin_arrayinstanceof(u1 *sp);
115 #define PATCHER_builtin_arrayinstanceof (functionptr) patcher_builtin_arrayinstanceof
116
117 bool patcher_invokestatic_special(u1 *sp);
118 #define PATCHER_invokestatic_special (functionptr) patcher_invokestatic_special
119
120 bool patcher_invokevirtual(u1 *sp);
121 #define PATCHER_invokevirtual (functionptr) patcher_invokevirtual
122
123 bool patcher_invokeinterface(u1 *sp);
124 #define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
125
126 bool patcher_checkcast_instanceof_flags(u1 *sp);
127 #define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
128
129 bool patcher_checkcast_instanceof_interface(u1 *sp);
130 #define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
131
132 #if defined(__I386__) || defined(__X86_64__)
133
134 bool patcher_checkcast_class(u1 *sp);
135 #define PATCHER_checkcast_class (functionptr) patcher_checkcast_class
136
137 bool patcher_instanceof_class(u1 *sp);
138 #define PATCHER_instanceof_class (functionptr) patcher_instanceof_class
139
140 #else /* defined(__I386__) || defined(__X86_64__) */
141
142 bool patcher_checkcast_instanceof_class(u1 *sp);
143 #define PATCHER_checkcast_instanceof_class (functionptr) patcher_checkcast_instanceof_class
144
145 #endif /* defined(__I386__) || defined(__X86_64__) */
146
147 bool patcher_clinit(u1 *sp);
148 #define PATCHER_clinit (functionptr) patcher_clinit
149
150 #endif /* _PATCHER_H */
151
152
153 /*
154  * These are local overrides for various environment variables in Emacs.
155  * Please do not remove this and leave it at the end of the file, where
156  * Emacs will automagically detect them.
157  * ---------------------------------------------------------------------
158  * Local variables:
159  * mode: c
160  * indent-tabs-mode: t
161  * c-basic-offset: 4
162  * tab-width: 4
163  * End:
164  * vim:noexpandtab:sw=4:ts=4:
165  */
166