1 /* src/vm/global.h - global definitions
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: Reinhard Grafl
36 $Id: global.h 5234 2006-08-14 17:50:12Z christian $
48 /* additional data types ******************************************************/
50 typedef void *voidptr; /* generic pointer */
51 typedef void (*functionptr) (void); /* generic function pointer */
52 typedef u1* methodptr;
54 typedef unsigned int bool; /* boolean data type */
60 #if defined(ENABLE_SSA)
61 /* immediate to get an addidional target Local Var Index */
62 /* for IINC in Combination with SSA */
69 /* immediate data union */
79 #if defined(ENABLE_SSA)
85 /* forward typedefs ***********************************************************/
87 typedef struct java_objectheader java_objectheader;
88 typedef struct java_objectarray java_objectarray;
91 /* define some CACAO paths ****************************************************/
93 #define CLASSPATH_LIBRARY_PATH CLASSPATH_LIBDIR "/classpath"
96 #define MAX_ALIGN 8 /* most generic alignment for JavaVM values */
99 /* basic data types ***********************************************************/
101 /* The JavaVM types must numbered in the same order as the ICMD_Ixxx
102 to ICMD_Axxx instructions (LOAD and STORE). All other types can be
103 numbered arbitrarily. */
114 #define IS_INT_LNG_TYPE(a) (!((a) & TYPE_FLT))
115 #define IS_FLT_DBL_TYPE(a) ((a) & TYPE_FLT)
116 #define IS_2_WORD_TYPE(a) ((a) & TYPE_LNG)
118 #define IS_INT_TYPE(a) ((a) == TYPE_INT)
119 #define IS_LNG_TYPE(a) ((a) == TYPE_LNG)
120 #define IS_FLT_TYPE(a) ((a) == TYPE_FLT)
121 #define IS_DBL_TYPE(a) ((a) == TYPE_DBL)
122 #define IS_ADR_TYPE(a) ((a) == TYPE_ADR)
124 #define IS_VOID_TYPE(a) ((a) == TYPE_VOID)
127 /* primitive data types *******************************************************/
129 /* These values are used in parsed descriptors and in some other
130 places were the different types handled internally as TYPE_INT have
131 to be distinguished. */
133 #define PRIMITIVETYPE_COUNT 11 /* number of primitive types (+ dummies) */
135 /* CAUTION: Don't change the numerical values! These constants are
136 used as indices into the primitive type table. */
138 #define PRIMITIVETYPE_INT TYPE_INT
139 #define PRIMITIVETYPE_LONG TYPE_LNG
140 #define PRIMITIVETYPE_FLOAT TYPE_FLT
141 #define PRIMITIVETYPE_DOUBLE TYPE_DBL
142 #define PRIMITIVETYPE_DUMMY1 TYPE_ADR /* not used! */
143 #define PRIMITIVETYPE_BYTE 5
144 #define PRIMITIVETYPE_CHAR 6
145 #define PRIMITIVETYPE_SHORT 7
146 #define PRIMITIVETYPE_BOOLEAN 8
147 #define PRIMITIVETYPE_DUMMY2 9 /* not used! */
148 #define PRIMITIVETYPE_VOID TYPE_VOID
150 /* some Java related defines **************************************************/
152 #define JAVA_VERSION "1.4.2" /* this version is supported by CACAO */
153 #define CLASS_VERSION "49.0"
156 /* Java class file constants **************************************************/
158 #define MAGIC 0xCAFEBABE
159 #define MAJOR_VERSION 49
160 #define MINOR_VERSION 0
163 /* Constant pool tags *********************************************************/
165 #define CONSTANT_Class 7
166 #define CONSTANT_Fieldref 9
167 #define CONSTANT_Methodref 10
168 #define CONSTANT_InterfaceMethodref 11
169 #define CONSTANT_String 8
170 #define CONSTANT_Integer 3
171 #define CONSTANT_Float 4
172 #define CONSTANT_Long 5
173 #define CONSTANT_Double 6
174 #define CONSTANT_NameAndType 12
175 #define CONSTANT_Utf8 1
177 #define CONSTANT_UNUSED 0
180 /* Class/Field/Method access and property flags *******************************/
182 #define ACC_UNDEF -1 /* used internally */
183 #define ACC_NONE 0 /* used internally */
185 #define ACC_PUBLIC 0x0001
186 #define ACC_PRIVATE 0x0002
187 #define ACC_PROTECTED 0x0004
188 #define ACC_STATIC 0x0008
189 #define ACC_FINAL 0x0010
190 #define ACC_SUPER 0x0020
191 #define ACC_SYNCHRONIZED 0x0020
192 #define ACC_VOLATILE 0x0040
193 #define ACC_BRIDGE 0x0040
194 #define ACC_TRANSIENT 0x0080
195 #define ACC_VARARGS 0x0080
196 #define ACC_NATIVE 0x0100
197 #define ACC_INTERFACE 0x0200
198 #define ACC_ABSTRACT 0x0400
199 #define ACC_STRICT 0x0800
200 #define ACC_SYNTHETIC 0x1000
201 #define ACC_ANNOTATION 0x2000
202 #define ACC_ENUM 0x4000
203 #define ACC_MIRANDA 0x8000
205 /* special flags used in classinfo ********************************************/
207 #define ACC_CLASS_REFLECT_MASK 0x0000ffff /* flags reported by reflection */
208 #define ACC_CLASS_HAS_POINTERS 0x00010000 /* instance contains pointers */
211 /* data structures of the runtime system **************************************/
213 /* java_objectheader ***********************************************************
215 All objects (and arrays) which resides on the heap need the
216 following header at the beginning of the data structure.
218 *******************************************************************************/
220 struct java_objectheader { /* header for all objects */
221 struct _vftbl *vftbl; /* pointer to virtual function table */
222 #if defined(ENABLE_THREADS)
223 struct lock_record_t *monitorPtr;
224 ptrint flcword; /* word containing the FLC bit */
229 /* arrays **********************************************************************
231 All arrays are objects (they need the object header with a pointer
232 to a vftbl (array class table). There is one class for each array
233 type. The array type is described by an arraydescriptor struct
234 which is referenced by the vftbl.
237 /* CAUTION: Don't change the numerical values! These constants (with
238 * the exception of ARRAYTYPE_OBJECT) are used as indices in the
239 * primitive type table.
241 #define ARRAYTYPE_INT PRIMITIVETYPE_INT
242 #define ARRAYTYPE_LONG PRIMITIVETYPE_LONG
243 #define ARRAYTYPE_FLOAT PRIMITIVETYPE_FLOAT
244 #define ARRAYTYPE_DOUBLE PRIMITIVETYPE_DOUBLE
245 #define ARRAYTYPE_BYTE PRIMITIVETYPE_BYTE
246 #define ARRAYTYPE_CHAR PRIMITIVETYPE_CHAR
247 #define ARRAYTYPE_SHORT PRIMITIVETYPE_SHORT
248 #define ARRAYTYPE_BOOLEAN PRIMITIVETYPE_BOOLEAN
249 #define ARRAYTYPE_OBJECT PRIMITIVETYPE_VOID /* don't use as index! */
251 typedef struct java_arrayheader { /* header for all arrays */
252 java_objectheader objheader; /* object header */
253 s4 size; /* array size */
258 /* structs for all kinds of arrays ********************************************/
260 /* booleanarray and bytearray need identical memory layout (access methods
261 use the same machine code */
263 typedef struct java_booleanarray {
264 java_arrayheader header;
268 typedef struct java_bytearray {
269 java_arrayheader header;
273 typedef struct java_chararray {
274 java_arrayheader header;
278 typedef struct java_shortarray {
279 java_arrayheader header;
283 typedef struct java_intarray {
284 java_arrayheader header;
288 typedef struct java_longarray {
289 java_arrayheader header;
293 typedef struct java_floatarray {
294 java_arrayheader header;
298 typedef struct java_doublearray {
299 java_arrayheader header;
303 /* objectarray and arrayarray need identical memory layout (access methods
304 use the same machine code */
306 struct java_objectarray {
307 java_arrayheader header;
308 java_objectheader *data[1];
312 /* Synchronization ************************************************************/
314 #if defined(ENABLE_THREADS)
315 void compiler_lock();
316 void compiler_unlock();
319 #endif /* _GLOBAL_H */
323 * These are local overrides for various environment variables in Emacs.
324 * Please do not remove this and leave it at the end of the file, where
325 * Emacs will automagically detect them.
326 * ---------------------------------------------------------------------
329 * indent-tabs-mode: t
333 * vim:noexpandtab:sw=4:ts=4: