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 8299 2007-08-13 08:41:18Z 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_EVEN(a) ((a) = (((a) + 1) & ~1))
77 #define ALIGN_ODD(a) ((a) = (a) | 1 )
79 #define ALIGN_2(a) ALIGN_EVEN(a)
82 /* forward typedefs ***********************************************************/
84 typedef struct java_object_t java_object_t;
85 typedef struct java_objectarray java_objectarray;
88 #define MAX_ALIGN 8 /* most generic alignment for JavaVM values */
91 /* basic data types ***********************************************************/
93 /* The JavaVM types must numbered in the same order as the ICMD_Ixxx
94 to ICMD_Axxx instructions (LOAD and STORE). All other types can be
95 numbered arbitrarily. */
103 #define TYPE_RET 8 /* must not share bits with TYPE_FLT or TYPE_LNG */
108 #define IS_INT_LNG_TYPE(a) (!((a) & TYPE_FLT))
109 #define IS_FLT_DBL_TYPE(a) ((a) & TYPE_FLT)
110 #define IS_2_WORD_TYPE(a) ((a) & TYPE_LNG)
112 #define IS_INT_TYPE(a) ((a) == TYPE_INT)
113 #define IS_LNG_TYPE(a) ((a) == TYPE_LNG)
114 #define IS_FLT_TYPE(a) ((a) == TYPE_FLT)
115 #define IS_DBL_TYPE(a) ((a) == TYPE_DBL)
116 #define IS_ADR_TYPE(a) ((a) == TYPE_ADR)
118 #define IS_VOID_TYPE(a) ((a) == TYPE_VOID)
121 /* some Java related defines **************************************************/
123 #define JAVA_VERSION "1.5.0" /* this version is supported by CACAO */
124 #define CLASS_VERSION "50.0"
127 /* Java class file constants **************************************************/
129 #define MAGIC 0xCAFEBABE
130 #define MAJOR_VERSION 50
131 #define MINOR_VERSION 0
134 /* Constant pool tags *********************************************************/
136 #define CONSTANT_Class 7
137 #define CONSTANT_Fieldref 9
138 #define CONSTANT_Methodref 10
139 #define CONSTANT_InterfaceMethodref 11
140 #define CONSTANT_String 8
141 #define CONSTANT_Integer 3
142 #define CONSTANT_Float 4
143 #define CONSTANT_Long 5
144 #define CONSTANT_Double 6
145 #define CONSTANT_NameAndType 12
146 #define CONSTANT_Utf8 1
148 #define CONSTANT_UNUSED 0
151 /* Class/Field/Method access and property flags *******************************/
153 #define ACC_UNDEF -1 /* used internally */
154 #define ACC_NONE 0 /* used internally */
156 #define ACC_PUBLIC 0x0001
157 #define ACC_PRIVATE 0x0002
158 #define ACC_PROTECTED 0x0004
159 #define ACC_STATIC 0x0008
160 #define ACC_FINAL 0x0010
161 #define ACC_SUPER 0x0020
162 #define ACC_SYNCHRONIZED 0x0020
163 #define ACC_VOLATILE 0x0040
164 #define ACC_BRIDGE 0x0040
165 #define ACC_TRANSIENT 0x0080
166 #define ACC_VARARGS 0x0080
167 #define ACC_NATIVE 0x0100
168 #define ACC_INTERFACE 0x0200
169 #define ACC_ABSTRACT 0x0400
170 #define ACC_STRICT 0x0800
171 #define ACC_SYNTHETIC 0x1000
172 #define ACC_ANNOTATION 0x2000
173 #define ACC_ENUM 0x4000
174 #define ACC_MIRANDA 0x8000
176 /* special flags used in classinfo ********************************************/
178 #define ACC_CLASS_REFLECT_MASK 0x0000ffff/* flags reported by reflection */
180 #define ACC_CLASS_PRIMITIVE 0x00010000/* class is a primitive class */
182 #define ACC_CLASS_HAS_POINTERS 0x00020000/* instance contains pointers */
184 #define ACC_CLASS_REFERENCE_MASK 0x001c0000
185 #define ACC_CLASS_REFERENCE_SOFT 0x00040000
186 #define ACC_CLASS_REFERENCE_WEAK 0x00080000
187 #define ACC_CLASS_REFERENCE_PHANTOM 0x00100000
190 /* special flags used in methodinfo *******************************************/
192 #define ACC_METHOD_BUILTIN 0x00010000 /* use for descriptor parsing */
193 #define ACC_METHOD_IMPLEMENTED 0x00020000 /* there is an implementation */
194 #define ACC_METHOD_MONOMORPHIC 0x00040000 /* currently monomorphic method */
197 /* data structures of the runtime system **************************************/
199 /* java_object_t ***************************************************************
201 All objects (and arrays) which resides on the heap need the
202 following header at the beginning of the data structure.
204 TODO: Include detailed description from the Wiki (ObjectHeader) here.
206 *******************************************************************************/
208 #define HDRFLAG_FLC 0x01
209 #define HDRFLAG_MARK1 0x02
210 #define HDRFLAG_MARK2 0x04
211 #define HDRFLAG_UNCOLLECTABLE 0x08
212 #define HDRFLAG_HASH_TAKEN 0x10
213 #define HDRFLAG_HASH_ATTACHED 0x20
214 #define HDRFLAG_REFERENCING 0x40
216 struct java_object_t { /* header for all objects */
217 struct _vftbl *vftbl; /* pointer to virtual function table */
218 #if defined(ENABLE_THREADS)
219 struct lock_record_t *monitorPtr;
221 #if defined(ENABLE_THREADS) || defined(ENABLE_GC_CACAO)
222 ptrint hdrflags; /* word containing the FLC and GC bits */
228 typedef struct java_handle_t {
229 java_object_t *heap_object;
232 typedef java_object_t java_handle_t;
236 /* arrays **********************************************************************
238 All arrays are objects (they need the object header with a pointer
239 to a vftbl (array class table). There is one class for each array
240 type. The array type is described by an arraydescriptor struct
241 which is referenced by the vftbl.
244 typedef struct java_arrayheader { /* header for all arrays */
245 java_object_t objheader; /* object header */
246 s4 size; /* array size */
251 /* structs for all kinds of arrays ********************************************/
253 /* booleanarray and bytearray need identical memory layout (access methods
254 use the same machine code */
256 typedef struct java_booleanarray {
257 java_arrayheader header;
261 typedef struct java_bytearray {
262 java_arrayheader header;
266 typedef struct java_chararray {
267 java_arrayheader header;
271 typedef struct java_shortarray {
272 java_arrayheader header;
276 typedef struct java_intarray {
277 java_arrayheader header;
281 typedef struct java_longarray {
282 java_arrayheader header;
286 typedef struct java_floatarray {
287 java_arrayheader header;
291 typedef struct java_doublearray {
292 java_arrayheader header;
296 /* objectarray and arrayarray need identical memory layout (access methods
297 use the same machine code */
299 struct java_objectarray {
300 java_arrayheader header;
301 java_object_t *data[1];
305 /* global constants related to the verifier ***********************************/
307 /* The verifier needs additional variables in the variable array. Since these */
308 /* must be reserved and set by parse.c and stack.c, we define these numbers */
309 /* here to avoid mysterious hard-coded constants. */
310 /* stack.c needs an extra variable if the verifier is disabled. */
312 #if defined(ENABLE_VERIFIER)
313 # define VERIFIER_EXTRA_LOCALS 1
314 # define VERIFIER_EXTRA_VARS 1
315 # define STACK_EXTRA_VARS 0
317 # define VERIFIER_EXTRA_LOCALS 0
318 # define VERIFIER_EXTRA_VARS 0
319 # define STACK_EXTRA_VARS 1
322 #endif /* _GLOBAL_H */
326 * These are local overrides for various environment variables in Emacs.
327 * Please do not remove this and leave it at the end of the file, where
328 * Emacs will automagically detect them.
329 * ---------------------------------------------------------------------
332 * indent-tabs-mode: t
336 * vim:noexpandtab:sw=4:ts=4: