* src/vm/global.h (ACC_CLASS_REFLECT_MASK): Added.
[cacao.git] / src / vm / global.h
1 /* src/vm/global.h - global definitions
2
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
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., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Reinhard Grafl
28             Andreas Krall
29
30    Changes: Mark Probst
31             Philipp Tomsich
32             Edwin Steiner
33             Joseph Wenninger
34             Christian Thalinger
35
36    $Id: global.h 4829 2006-04-24 17:16:45Z edwin $
37
38 */
39
40
41 #ifndef _GLOBAL_H
42 #define _GLOBAL_H
43
44 #include "config.h"
45 #include "vm/types.h"
46
47
48 /* additional data types ******************************************************/
49
50 typedef void *voidptr;                  /* generic pointer                    */
51 typedef void (*functionptr) (void);     /* generic function pointer           */
52 typedef u1* methodptr;
53
54 typedef int   bool;                     /* boolean data type                  */
55
56 #define true  1
57 #define false 0
58
59
60 /* immediate data union */
61
62 typedef union {
63         s4          i;
64         s8          l;
65         float       f;
66         double      d;
67         void       *a;
68         functionptr fp;
69         u1          b[8];
70 } imm_union;
71
72
73 /* forward typedefs ***********************************************************/
74
75 typedef struct java_objectheader java_objectheader; 
76 typedef struct java_objectarray java_objectarray;
77
78
79 /* define some CACAO paths ****************************************************/
80
81 #if defined(ENABLE_ZLIB)
82 # define CACAO_VM_ZIP_PATH          CACAO_PREFIX "/share/cacao/" VM_ZIP_STRING
83 #else
84 # define CACAO_VM_ZIP_PATH          CACAO_PREFIX "/share/cacao/"
85 #endif
86
87 #define CLASSPATH_GLIBJ_ZIP_PATH    CLASSPATH_PREFIX "/share/classpath/" GLIBJ_ZIP_STRING
88 #define CLASSPATH_LIBRARY_PATH      CLASSPATH_LIBDIR "/classpath"
89
90
91 /*
92  * ENABLE_VERIFIER activates bytecode verification and other checks
93  */
94 #define ENABLE_VERIFIER
95
96 /* if we have threads disabled this one is not defined ************************/
97
98 #if !defined(USE_THREADS)
99 #define THREADSPECIFIC
100 #endif
101
102
103 #define MAX_ALIGN 8             /* most generic alignment for JavaVM values   */
104
105
106 /* basic data types ***********************************************************/
107
108 /* CAUTION: jit/jit.h relies on these numerical values! */
109 #define TYPE_INT      0         /* the JavaVM types must numbered in the      */
110 #define TYPE_LONG     1         /* same order as the ICMD_Ixxx to ICMD_Axxx   */
111 #define TYPE_FLOAT    2         /* instructions (LOAD and STORE)              */
112 #define TYPE_DOUBLE   3         /* integer, long, float, double, address      */
113 #define TYPE_ADDRESS  4         /* all other types can be numbered arbitrarly */
114
115 #define TYPE_VOID    10
116
117 /* primitive data types *******************************************************/
118
119 /* These values are used in parsed descriptors and in some other
120    places were the different types handled internally as TYPE_INT have
121    to be distinguished. */
122
123 #define PRIMITIVETYPE_COUNT  11  /* number of primitive types (+ dummies)     */
124
125 /* CAUTION: Don't change the numerical values! These constants are
126    used as indices into the primitive type table. */
127
128 #define PRIMITIVETYPE_INT     TYPE_INT
129 #define PRIMITIVETYPE_LONG    TYPE_LONG
130 #define PRIMITIVETYPE_FLOAT   TYPE_FLOAT
131 #define PRIMITIVETYPE_DOUBLE  TYPE_DOUBLE
132 #define PRIMITIVETYPE_DUMMY1  TYPE_ADR     /* not used! */
133 #define PRIMITIVETYPE_BYTE    5
134 #define PRIMITIVETYPE_CHAR    6
135 #define PRIMITIVETYPE_SHORT   7
136 #define PRIMITIVETYPE_BOOLEAN 8
137 #define PRIMITIVETYPE_DUMMY2  9            /* not used! */
138 #define PRIMITIVETYPE_VOID    TYPE_VOID
139
140 /* some Java related defines **************************************************/
141
142 #define JAVA_VERSION    "1.4.2"         /* this version is supported by CACAO */
143 #define CLASS_VERSION   "49.0"
144
145
146 /* Java class file constants **************************************************/
147
148 #define MAGIC             0xCAFEBABE
149 #define MAJOR_VERSION     49
150 #define MINOR_VERSION     0
151
152
153 /* Constant pool tags *********************************************************/
154
155 #define CONSTANT_Class                 7
156 #define CONSTANT_Fieldref              9
157 #define CONSTANT_Methodref            10
158 #define CONSTANT_InterfaceMethodref   11
159 #define CONSTANT_String                8
160 #define CONSTANT_Integer               3
161 #define CONSTANT_Float                 4
162 #define CONSTANT_Long                  5
163 #define CONSTANT_Double                6
164 #define CONSTANT_NameAndType          12
165 #define CONSTANT_Utf8                  1
166
167 #define CONSTANT_UNUSED                0
168
169
170 /* Class/Field/Method access and property flags *******************************/
171
172 #define ACC_UNDEF               -1      /* used internally                    */
173 #define ACC_NONE                 0      /* used internally                    */
174
175 #define ACC_PUBLIC          0x0001
176 #define ACC_PRIVATE         0x0002
177 #define ACC_PROTECTED       0x0004
178 #define ACC_STATIC          0x0008
179 #define ACC_FINAL           0x0010
180 #define ACC_SUPER           0x0020
181 #define ACC_SYNCHRONIZED    0x0020
182 #define ACC_VOLATILE        0x0040
183 #define ACC_BRIDGE          0x0040
184 #define ACC_TRANSIENT       0x0080
185 #define ACC_VARARGS         0x0080
186 #define ACC_NATIVE          0x0100
187 #define ACC_INTERFACE       0x0200
188 #define ACC_ABSTRACT        0x0400
189 #define ACC_STRICT          0x0800
190 #define ACC_SYNTHETIC       0x1000
191 #define ACC_ANNOTATION      0x2000
192 #define ACC_ENUM            0x4000
193 #define ACC_MIRANDA         0x8000
194
195 /* special flags used in classinfo ********************************************/
196
197 #define ACC_CLASS_REFLECT_MASK 0x0000ffff     /* flags reported by reflection */
198 #define ACC_CLASS_HAS_POINTERS 0x00010000     /* instance contains pointers   */
199
200
201 /* data structures of the runtime system **************************************/
202
203 /* java_objectheader ***********************************************************
204
205    All objects (and arrays) which resides on the heap need the
206    following header at the beginning of the data structure.
207
208 *******************************************************************************/
209
210 struct java_objectheader {              /* header for all objects             */
211         struct _vftbl *vftbl;               /* pointer to virtual function table  */
212 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
213         void          *monitorPtr;
214 #endif
215 };
216
217
218 /* arrays **********************************************************************
219
220         All arrays are objects (they need the object header with a pointer
221         to a vftbl (array class table). There is one class for each array
222         type. The array type is described by an arraydescriptor struct
223         which is referenced by the vftbl.
224 */
225
226 /* CAUTION: Don't change the numerical values! These constants (with
227  * the exception of ARRAYTYPE_OBJECT) are used as indices in the
228  * primitive type table.
229  */
230 #define ARRAYTYPE_INT      PRIMITIVETYPE_INT
231 #define ARRAYTYPE_LONG     PRIMITIVETYPE_LONG
232 #define ARRAYTYPE_FLOAT    PRIMITIVETYPE_FLOAT
233 #define ARRAYTYPE_DOUBLE   PRIMITIVETYPE_DOUBLE
234 #define ARRAYTYPE_BYTE     PRIMITIVETYPE_BYTE
235 #define ARRAYTYPE_CHAR     PRIMITIVETYPE_CHAR
236 #define ARRAYTYPE_SHORT    PRIMITIVETYPE_SHORT
237 #define ARRAYTYPE_BOOLEAN  PRIMITIVETYPE_BOOLEAN
238 #define ARRAYTYPE_OBJECT   PRIMITIVETYPE_VOID     /* don't use as index! */
239
240 typedef struct java_arrayheader {       /* header for all arrays              */
241         java_objectheader objheader;        /* object header                      */
242         s4 size;                            /* array size                         */
243 } java_arrayheader;
244
245
246
247 /* structs for all kinds of arrays ********************************************/
248
249 /*  booleanarray and bytearray need identical memory layout (access methods
250     use the same machine code */
251
252 typedef struct java_booleanarray {
253         java_arrayheader header;
254         u1 data[1];
255 } java_booleanarray;
256
257 typedef struct java_bytearray {
258         java_arrayheader header;
259         s1 data[1];
260 } java_bytearray;
261
262 typedef struct java_chararray {
263         java_arrayheader header;
264         u2 data[1];
265 } java_chararray;
266
267 typedef struct java_shortarray {
268         java_arrayheader header;
269         s2 data[1];
270 } java_shortarray;
271
272 typedef struct java_intarray {
273         java_arrayheader header;
274         s4 data[1];
275 } java_intarray;
276
277 typedef struct java_longarray {
278         java_arrayheader header;
279         s8 data[1];
280 } java_longarray;
281
282 typedef struct java_floatarray {
283         java_arrayheader header;
284         float data[1];
285 } java_floatarray;
286
287 typedef struct java_doublearray {
288         java_arrayheader header;
289         double data[1];
290 } java_doublearray;
291
292 /*  objectarray and arrayarray need identical memory layout (access methods
293     use the same machine code */
294
295 struct java_objectarray {
296         java_arrayheader   header;
297         java_objectheader *data[1];
298 };
299
300
301 /* Synchronization ************************************************************/
302
303 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
304 void compiler_lock();
305 void compiler_unlock();
306 #endif
307
308 #endif /* _GLOBAL_H */
309
310
311 /*
312  * These are local overrides for various environment variables in Emacs.
313  * Please do not remove this and leave it at the end of the file, where
314  * Emacs will automagically detect them.
315  * ---------------------------------------------------------------------
316  * Local variables:
317  * mode: c
318  * indent-tabs-mode: t
319  * c-basic-offset: 4
320  * tab-width: 4
321  * End:
322  * vim:noexpandtab:sw=4:ts=4:
323  */