1 /* src/vm/global.h - global definitions
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
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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Reinhard Grafl
36 $Id: global.h 2591 2005-06-08 11:03:00Z twisti $
48 /* additional data types ******************************************************/
50 typedef void *voidptr; /* generic pointer */
51 typedef void (*functionptr) (void); /* generic function pointer */
52 typedef u1* methodptr;
54 typedef int bool; /* boolean data type */
60 /* immediate data union */
73 /* forward typedefs ***********************************************************/
75 typedef struct java_objectheader java_objectheader;
76 typedef struct java_objectarray java_objectarray;
79 /* define some cacao paths ****************************************************/
81 #define CACAO_JRE_DIR "/jre"
82 #define CACAO_LIBRARY_PATH "/jre/lib/"ARCH_DIR"/"
83 #define CACAO_RT_JAR_PATH "/jre/lib/rt.jar"
84 #define CACAO_EXT_DIR "/jre/lib/ext"
86 #if defined(WITH_EXTERNAL_CLASSPATH)
87 #define CACAO_VM_ZIP_PATH "/jre/lib/vm.zip"
88 #define CLASSPATH_LIBRARY_PATH "/lib/classpath"
89 #define CLASSPATH_GLIBJ_ZIP_PATH "/share/classpath/glibj.zip"
94 * CACAO_TYPECHECK activates typechecking (part of bytecode verification)
96 #define CACAO_TYPECHECK
99 * TYPECHECK_STACK_COMPCAT activates full checking of computational
100 * categories for stack manipulations (POP,POP2,SWAP,DUP,DUP2,DUP_X1,
101 * DUP2_X1,DUP_X2,DUP2_X2).
103 #define TYPECHECK_STACK_COMPCAT
105 /* if we have threads disabled this one is not defined ************************/
107 #if !defined(USE_THREADS)
108 #define THREADSPECIFIC
112 #define MAX_ALIGN 8 /* most generic alignment for JavaVM values */
115 /* basic data types ***********************************************************/
117 /* CAUTION: jit/jit.h relies on these numerical values! */
118 #define TYPE_INT 0 /* the JavaVM types must numbered in the */
119 #define TYPE_LONG 1 /* same order as the ICMD_Ixxx to ICMD_Axxx */
120 #define TYPE_FLOAT 2 /* instructions (LOAD and STORE) */
121 #define TYPE_DOUBLE 3 /* integer, long, float, double, address */
122 #define TYPE_ADDRESS 4 /* all other types can be numbered arbitrarly */
126 /* primitive data types *******************************************************/
128 /* These values are used in parsed descriptors and in some other places */
129 /* were the different types handled internally as TYPE_INT have to be */
132 #define PRIMITIVETYPE_COUNT 11 /* number of primitive types (+ dummies) */
134 /* CAUTION: Don't change the numerical values! These constants are
135 * used as indices into the primitive type table.
137 #define PRIMITIVETYPE_INT TYPE_INT
138 #define PRIMITIVETYPE_LONG TYPE_LONG
139 #define PRIMITIVETYPE_FLOAT TYPE_FLOAT
140 #define PRIMITIVETYPE_DOUBLE TYPE_DOUBLE
141 #define PRIMITIVETYPE_DUMMY1 TYPE_ADR /* not used! */
142 #define PRIMITIVETYPE_BYTE 5
143 #define PRIMITIVETYPE_CHAR 6
144 #define PRIMITIVETYPE_SHORT 7
145 #define PRIMITIVETYPE_BOOLEAN 8
146 #define PRIMITIVETYPE_DUMMY2 9 /* not used! */
147 #define PRIMITIVETYPE_VOID TYPE_VOID
149 /* Java class file constants **************************************************/
151 #define MAGIC 0xCAFEBABE
152 #define MAJOR_VERSION 48
153 #define MINOR_VERSION 0
156 /* Constant pool tags *********************************************************/
158 #define CONSTANT_Class 7
159 #define CONSTANT_Fieldref 9
160 #define CONSTANT_Methodref 10
161 #define CONSTANT_InterfaceMethodref 11
162 #define CONSTANT_String 8
163 #define CONSTANT_Integer 3
164 #define CONSTANT_Float 4
165 #define CONSTANT_Long 5
166 #define CONSTANT_Double 6
167 #define CONSTANT_NameAndType 12
168 #define CONSTANT_Utf8 1
170 #define CONSTANT_UNUSED 0
173 /* Class/Field/Method access and property flags *******************************/
175 #define ACC_UNDEF -1 /* used internally */
176 #define ACC_NONE 0 /* used internally */
178 #define ACC_PUBLIC 0x0001
179 #define ACC_PRIVATE 0x0002
180 #define ACC_PROTECTED 0x0004
181 #define ACC_STATIC 0x0008
182 #define ACC_FINAL 0x0010
183 #define ACC_SUPER 0x0020
184 #define ACC_SYNCHRONIZED 0x0020
185 #define ACC_VOLATILE 0x0040
186 #define ACC_BRIDGE 0x0040
187 #define ACC_TRANSIENT 0x0080
188 #define ACC_VARARGS 0x0080
189 #define ACC_NATIVE 0x0100
190 #define ACC_INTERFACE 0x0200
191 #define ACC_ABSTRACT 0x0400
192 #define ACC_STRICT 0x0800
193 #define ACC_SYNTHETIC 0x1000
194 #define ACC_ANNOTATION 0x2000
195 #define ACC_ENUM 0x4000
198 /* data structure for calls from c code to java methods */
200 struct jni_callblock {
205 typedef struct jni_callblock jni_callblock;
208 /* data structures of the runtime system **************************************/
210 /* java_objectheader ***********************************************************
212 All objects (and arrays) which resides on the heap need the
213 following header at the beginning of the data structure.
215 *******************************************************************************/
217 struct java_objectheader { /* header for all objects */
218 struct _vftbl *vftbl; /* pointer to virtual function table */
219 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
225 /* arrays **********************************************************************
227 All arrays are objects (they need the object header with a pointer
228 to a vftbl (array class table). There is one class for each array
229 type. The array type is described by an arraydescriptor struct
230 which is referenced by the vftbl.
233 /* CAUTION: Don't change the numerical values! These constants (with
234 * the exception of ARRAYTYPE_OBJECT) are used as indices in the
235 * primitive type table.
237 #define ARRAYTYPE_INT PRIMITIVETYPE_INT
238 #define ARRAYTYPE_LONG PRIMITIVETYPE_LONG
239 #define ARRAYTYPE_FLOAT PRIMITIVETYPE_FLOAT
240 #define ARRAYTYPE_DOUBLE PRIMITIVETYPE_DOUBLE
241 #define ARRAYTYPE_BYTE PRIMITIVETYPE_BYTE
242 #define ARRAYTYPE_CHAR PRIMITIVETYPE_CHAR
243 #define ARRAYTYPE_SHORT PRIMITIVETYPE_SHORT
244 #define ARRAYTYPE_BOOLEAN PRIMITIVETYPE_BOOLEAN
245 #define ARRAYTYPE_OBJECT PRIMITIVETYPE_VOID /* don't use as index! */
247 typedef struct java_arrayheader { /* header for all arrays */
248 java_objectheader objheader; /* object header */
249 s4 size; /* array size */
254 /* structs for all kinds of arrays ********************************************/
256 typedef struct java_chararray {
257 java_arrayheader header;
261 typedef struct java_floatheader {
262 java_arrayheader header;
266 typedef struct java_doublearray {
267 java_arrayheader header;
271 /* booleanarray and bytearray need identical memory layout (access methods
272 use the same machine code */
274 typedef struct java_booleanarray {
275 java_arrayheader header;
279 typedef struct java_bytearray {
280 java_arrayheader header;
284 typedef struct java_shortarray {
285 java_arrayheader header;
289 typedef struct java_intarray {
290 java_arrayheader header;
294 typedef struct java_longarray {
295 java_arrayheader header;
299 /* objectarray and arrayarray need identical memory layout (access methods
300 use the same machine code */
302 struct java_objectarray {
303 java_arrayheader header;
304 java_objectheader *data[1];
308 #define VFTBLINTERFACETABLE(v,i) (v)->interfacetable[-i]
311 /* flag variables *************************************************************/
313 extern bool cacao_initializing;
316 /* Synchronization ************************************************************/
318 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
321 void compiler_lock();
322 void compiler_unlock();
326 /**** Methods: called directly by cacao, which defines the callpath ***/
327 #define MAINCLASS mainstring
328 #define MAINMETH "main"
329 #define MAINDESC "([Ljava/lang/String;)V"
331 #define EXITCLASS "java/lang/System"
332 #define EXITMETH "exit"
333 #define EXITDESC "(I)V"
335 #if defined(USE_THREADS)
336 #define THREADCLASS "java/lang/Thread"
337 #define THREADMETH "<init>"
338 #define THREADDESC "(Ljava/lang/VMThread;Ljava/lang/String;IZ)V"
340 #define THREADGROUPCLASS "java/lang/ThreadGroup"
341 #define THREADGROUPMETH "addThread"
342 #define THREADGROUPDESC "(Ljava/lang/Thread;)V"
345 #endif /* _GLOBAL_H */
349 * These are local overrides for various environment variables in Emacs.
350 * Please do not remove this and leave it at the end of the file, where
351 * Emacs will automagically detect them.
352 * ---------------------------------------------------------------------
355 * indent-tabs-mode: t