1 /* src/vm/global.h - global definitions
3 Copyright (C) 1996-2005, 2007, 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 $Id: global.h 7940 2007-05-23 09:42:08Z michi $
37 /* additional data types ******************************************************/
39 typedef void *voidptr; /* generic pointer */
40 typedef void (*functionptr) (void); /* generic function pointer */
41 typedef u1* methodptr;
43 typedef unsigned int bool; /* boolean data type */
49 #if defined(ENABLE_SSA)
50 /* immediate to get an addidional target Local Var Index */
51 /* for IINC in Combination with SSA */
58 /* immediate data union */
68 #if defined(ENABLE_SSA)
74 /* alignment macros ***********************************************************/
76 #define ALIGN_2(a) do { if ((a) & 0x1) (a)++; } while (0)
79 /* forward typedefs ***********************************************************/
81 typedef struct java_objectheader java_objectheader;
82 typedef struct java_objectarray java_objectarray;
85 #define MAX_ALIGN 8 /* most generic alignment for JavaVM values */
88 /* basic data types ***********************************************************/
90 /* The JavaVM types must numbered in the same order as the ICMD_Ixxx
91 to ICMD_Axxx instructions (LOAD and STORE). All other types can be
92 numbered arbitrarily. */
100 #define TYPE_RET 8 /* must not share bits with TYPE_FLT or TYPE_LNG */
105 #define IS_INT_LNG_TYPE(a) (!((a) & TYPE_FLT))
106 #define IS_FLT_DBL_TYPE(a) ((a) & TYPE_FLT)
107 #define IS_2_WORD_TYPE(a) ((a) & TYPE_LNG)
109 #define IS_INT_TYPE(a) ((a) == TYPE_INT)
110 #define IS_LNG_TYPE(a) ((a) == TYPE_LNG)
111 #define IS_FLT_TYPE(a) ((a) == TYPE_FLT)
112 #define IS_DBL_TYPE(a) ((a) == TYPE_DBL)
113 #define IS_ADR_TYPE(a) ((a) == TYPE_ADR)
115 #define IS_VOID_TYPE(a) ((a) == TYPE_VOID)
118 /* primitive data types *******************************************************/
120 /* These values are used in parsed descriptors and in some other
121 places were the different types handled internally as TYPE_INT have
122 to be distinguished. */
124 #define PRIMITIVETYPE_COUNT 11 /* number of primitive types (+ dummies) */
126 /* CAUTION: Don't change the numerical values! These constants are
127 used as indices into the primitive type table. */
129 #define PRIMITIVETYPE_INT TYPE_INT
130 #define PRIMITIVETYPE_LONG TYPE_LNG
131 #define PRIMITIVETYPE_FLOAT TYPE_FLT
132 #define PRIMITIVETYPE_DOUBLE TYPE_DBL
133 #define PRIMITIVETYPE_DUMMY1 TYPE_ADR /* not used! */
134 #define PRIMITIVETYPE_BYTE 5
135 #define PRIMITIVETYPE_CHAR 6
136 #define PRIMITIVETYPE_SHORT 7
137 #define PRIMITIVETYPE_BOOLEAN 8
138 #define PRIMITIVETYPE_DUMMY2 9 /* not used! */
139 #define PRIMITIVETYPE_VOID TYPE_VOID
141 /* some Java related defines **************************************************/
143 #define JAVA_VERSION "1.5.0" /* this version is supported by CACAO */
144 #define CLASS_VERSION "50.0"
147 /* Java class file constants **************************************************/
149 #define MAGIC 0xCAFEBABE
150 #define MAJOR_VERSION 50
151 #define MINOR_VERSION 0
154 /* Constant pool tags *********************************************************/
156 #define CONSTANT_Class 7
157 #define CONSTANT_Fieldref 9
158 #define CONSTANT_Methodref 10
159 #define CONSTANT_InterfaceMethodref 11
160 #define CONSTANT_String 8
161 #define CONSTANT_Integer 3
162 #define CONSTANT_Float 4
163 #define CONSTANT_Long 5
164 #define CONSTANT_Double 6
165 #define CONSTANT_NameAndType 12
166 #define CONSTANT_Utf8 1
168 #define CONSTANT_UNUSED 0
171 /* Class/Field/Method access and property flags *******************************/
173 #define ACC_UNDEF -1 /* used internally */
174 #define ACC_NONE 0 /* used internally */
176 #define ACC_PUBLIC 0x0001
177 #define ACC_PRIVATE 0x0002
178 #define ACC_PROTECTED 0x0004
179 #define ACC_STATIC 0x0008
180 #define ACC_FINAL 0x0010
181 #define ACC_SUPER 0x0020
182 #define ACC_SYNCHRONIZED 0x0020
183 #define ACC_VOLATILE 0x0040
184 #define ACC_BRIDGE 0x0040
185 #define ACC_TRANSIENT 0x0080
186 #define ACC_VARARGS 0x0080
187 #define ACC_NATIVE 0x0100
188 #define ACC_INTERFACE 0x0200
189 #define ACC_ABSTRACT 0x0400
190 #define ACC_STRICT 0x0800
191 #define ACC_SYNTHETIC 0x1000
192 #define ACC_ANNOTATION 0x2000
193 #define ACC_ENUM 0x4000
194 #define ACC_MIRANDA 0x8000
196 /* special flags used in classinfo ********************************************/
198 #define ACC_CLASS_REFLECT_MASK 0x0000ffff/* flags reported by reflection */
200 #define ACC_CLASS_PRIMITIVE 0x00010000/* class is a primitive class */
201 #define ACC_CLASS_HAS_POINTERS 0x00020000/* instance contains pointers */
202 #define ACC_CLASS_SOFT_REFERENCE 0x00040000
203 #define ACC_CLASS_WEAK_REFERENCE 0x00080000
204 #define ACC_CLASS_PHANTOM_REFERENCE 0x00100000
207 /* special flags used in methodinfo *******************************************/
209 #define ACC_METHOD_IMPLEMENTED 0x00010000 /* there is an implementation */
210 #define ACC_METHOD_MONOMORPHIC 0x00020000 /* currently monomorphic method */
213 /* data structures of the runtime system **************************************/
215 /* java_objectheader ***********************************************************
217 All objects (and arrays) which resides on the heap need the
218 following header at the beginning of the data structure.
220 TODO: Include detailed description from the Wiki (ObjectHeader) here.
222 *******************************************************************************/
224 #define HDRFLAG_FLC 0x01
225 #define HDRFLAG_MARK1 0x02
226 #define HDRFLAG_MARK2 0x04
227 #define HDRFLAG_UNCOLLECTABLE 0x08
228 #define HDRFLAG_HASH_TAKEN 0x10
229 #define HDRFLAG_HASH_ATTACHED 0x20
230 #define HDRFLAG_REFERENCING 0x40
232 struct java_objectheader { /* header for all objects */
233 struct _vftbl *vftbl; /* pointer to virtual function table */
234 #if defined(ENABLE_THREADS)
235 struct lock_record_t *monitorPtr;
237 #if defined(ENABLE_THREADS) || defined(ENABLE_GC_CACAO)
238 ptrint hdrflags; /* word containing the FLC and GC bits */
243 /* arrays **********************************************************************
245 All arrays are objects (they need the object header with a pointer
246 to a vftbl (array class table). There is one class for each array
247 type. The array type is described by an arraydescriptor struct
248 which is referenced by the vftbl.
251 /* CAUTION: Don't change the numerical values! These constants (with
252 * the exception of ARRAYTYPE_OBJECT) are used as indices in the
253 * primitive type table.
255 #define ARRAYTYPE_INT PRIMITIVETYPE_INT
256 #define ARRAYTYPE_LONG PRIMITIVETYPE_LONG
257 #define ARRAYTYPE_FLOAT PRIMITIVETYPE_FLOAT
258 #define ARRAYTYPE_DOUBLE PRIMITIVETYPE_DOUBLE
259 #define ARRAYTYPE_BYTE PRIMITIVETYPE_BYTE
260 #define ARRAYTYPE_CHAR PRIMITIVETYPE_CHAR
261 #define ARRAYTYPE_SHORT PRIMITIVETYPE_SHORT
262 #define ARRAYTYPE_BOOLEAN PRIMITIVETYPE_BOOLEAN
263 #define ARRAYTYPE_OBJECT PRIMITIVETYPE_VOID /* don't use as index! */
265 typedef struct java_arrayheader { /* header for all arrays */
266 java_objectheader objheader; /* object header */
267 s4 size; /* array size */
272 /* structs for all kinds of arrays ********************************************/
274 /* booleanarray and bytearray need identical memory layout (access methods
275 use the same machine code */
277 typedef struct java_booleanarray {
278 java_arrayheader header;
282 typedef struct java_bytearray {
283 java_arrayheader header;
287 typedef struct java_chararray {
288 java_arrayheader header;
292 typedef struct java_shortarray {
293 java_arrayheader header;
297 typedef struct java_intarray {
298 java_arrayheader header;
302 typedef struct java_longarray {
303 java_arrayheader header;
307 typedef struct java_floatarray {
308 java_arrayheader header;
312 typedef struct java_doublearray {
313 java_arrayheader header;
317 /* objectarray and arrayarray need identical memory layout (access methods
318 use the same machine code */
320 struct java_objectarray {
321 java_arrayheader header;
322 java_objectheader *data[1];
326 /* global constants related to the verifier ***********************************/
328 /* The verifier needs additional variables in the variable array. Since these */
329 /* must be reserved and set by parse.c and stack.c, we define these numbers */
330 /* here to avoid mysterious hard-coded constants. */
331 /* stack.c needs an extra variable if the verifier is disabled. */
333 #if defined(ENABLE_VERIFIER)
334 # define VERIFIER_EXTRA_LOCALS 1
335 # define VERIFIER_EXTRA_VARS 1
336 # define STACK_EXTRA_VARS 0
338 # define VERIFIER_EXTRA_LOCALS 0
339 # define VERIFIER_EXTRA_VARS 0
340 # define STACK_EXTRA_VARS 1
343 #endif /* _GLOBAL_H */
347 * These are local overrides for various environment variables in Emacs.
348 * Please do not remove this and leave it at the end of the file, where
349 * Emacs will automagically detect them.
350 * ---------------------------------------------------------------------
353 * indent-tabs-mode: t
357 * vim:noexpandtab:sw=4:ts=4: