/* src/vm/global.h - global definitions
- Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
- R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
- C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
- Institut f. Computersprachen - TU Wien
+ Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+ E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+ J. Wenninger, Institut f. Computersprachen - TU Wien
This file is part of CACAO.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
- Contact: cacao@complang.tuwien.ac.at
+ Contact: cacao@cacaojvm.org
Authors: Reinhard Grafl
Andreas Krall
Joseph Wenninger
Christian Thalinger
- $Id: global.h 4306 2006-01-19 20:53:39Z twisti $
+ $Id: global.h 6030 2006-11-20 14:18:12Z michi $
*/
#define _GLOBAL_H
#include "config.h"
-#include "types.h"
+#include "vm/types.h"
/* additional data types ******************************************************/
typedef void (*functionptr) (void); /* generic function pointer */
typedef u1* methodptr;
-typedef int bool; /* boolean data type */
+typedef unsigned int bool; /* boolean data type */
-#define true 1
-#define false 0
+#define true 1
+#define false 0
+#if defined(ENABLE_SSA)
+/* immediate to get an addidional target Local Var Index */
+/* for IINC in Combination with SSA */
+struct imm {
+ s4 i;
+ s4 op1_t;
+};
+#endif
+
/* immediate data union */
typedef union {
void *a;
functionptr fp;
u1 b[8];
+#if defined(ENABLE_SSA)
+ struct imm _i;
+#endif
} imm_union;
typedef struct java_objectarray java_objectarray;
-/* define some CACAO paths ****************************************************/
+#define MAX_ALIGN 8 /* most generic alignment for JavaVM values */
-#define CACAO_VM_ZIP_PATH CACAO_PREFIX "/share/cacao/vm.zip"
-#define CLASSPATH_GLIBJ_ZIP_PATH CLASSPATH_PREFIX "/share/classpath/" GLIBJZ_STRING
-#define CLASSPATH_LIBRARY_PATH CLASSPATH_LIBDIR "/classpath"
+/* basic data types ***********************************************************/
-/*
- * ENABLE_VERIFIER activates bytecode verification and other checks
- */
-#define ENABLE_VERIFIER
+/* The JavaVM types must numbered in the same order as the ICMD_Ixxx
+ to ICMD_Axxx instructions (LOAD and STORE). All other types can be
+ numbered arbitrarily. */
-/*
- * TYPECHECK_STACK_COMPCAT activates full checking of computational
- * categories for stack manipulations (POP,POP2,SWAP,DUP,DUP2,DUP_X1,
- * DUP2_X1,DUP_X2,DUP2_X2).
- */
-#define TYPECHECK_STACK_COMPCAT
+#define TYPE_INT 0
+#define TYPE_LNG 1
+#define TYPE_FLT 2
+#define TYPE_DBL 3
+#define TYPE_ADR 4
-/* if we have threads disabled this one is not defined ************************/
+#define TYPE_RET 8 /* must not share bits with TYPE_FLT or TYPE_LNG */
-#if !defined(USE_THREADS)
-#define THREADSPECIFIC
-#endif
+#define TYPE_VOID 10
-#define MAX_ALIGN 8 /* most generic alignment for JavaVM values */
+#define IS_INT_LNG_TYPE(a) (!((a) & TYPE_FLT))
+#define IS_FLT_DBL_TYPE(a) ((a) & TYPE_FLT)
+#define IS_2_WORD_TYPE(a) ((a) & TYPE_LNG)
+#define IS_INT_TYPE(a) ((a) == TYPE_INT)
+#define IS_LNG_TYPE(a) ((a) == TYPE_LNG)
+#define IS_FLT_TYPE(a) ((a) == TYPE_FLT)
+#define IS_DBL_TYPE(a) ((a) == TYPE_DBL)
+#define IS_ADR_TYPE(a) ((a) == TYPE_ADR)
-/* basic data types ***********************************************************/
+#define IS_VOID_TYPE(a) ((a) == TYPE_VOID)
-/* CAUTION: jit/jit.h relies on these numerical values! */
-#define TYPE_INT 0 /* the JavaVM types must numbered in the */
-#define TYPE_LONG 1 /* same order as the ICMD_Ixxx to ICMD_Axxx */
-#define TYPE_FLOAT 2 /* instructions (LOAD and STORE) */
-#define TYPE_DOUBLE 3 /* integer, long, float, double, address */
-#define TYPE_ADDRESS 4 /* all other types can be numbered arbitrarly */
-
-#define TYPE_VOID 10
/* primitive data types *******************************************************/
-/* These values are used in parsed descriptors and in some other places */
-/* were the different types handled internally as TYPE_INT have to be */
-/* distinguished. */
+/* These values are used in parsed descriptors and in some other
+ places were the different types handled internally as TYPE_INT have
+ to be distinguished. */
#define PRIMITIVETYPE_COUNT 11 /* number of primitive types (+ dummies) */
/* CAUTION: Don't change the numerical values! These constants are
- * used as indices into the primitive type table.
- */
+ used as indices into the primitive type table. */
+
#define PRIMITIVETYPE_INT TYPE_INT
-#define PRIMITIVETYPE_LONG TYPE_LONG
-#define PRIMITIVETYPE_FLOAT TYPE_FLOAT
-#define PRIMITIVETYPE_DOUBLE TYPE_DOUBLE
+#define PRIMITIVETYPE_LONG TYPE_LNG
+#define PRIMITIVETYPE_FLOAT TYPE_FLT
+#define PRIMITIVETYPE_DOUBLE TYPE_DBL
#define PRIMITIVETYPE_DUMMY1 TYPE_ADR /* not used! */
#define PRIMITIVETYPE_BYTE 5
#define PRIMITIVETYPE_CHAR 6
#define ACC_SYNTHETIC 0x1000
#define ACC_ANNOTATION 0x2000
#define ACC_ENUM 0x4000
+#define ACC_MIRANDA 0x8000
+/* special flags used in classinfo ********************************************/
-/* data structure for calls from c code to java methods */
+#define ACC_CLASS_REFLECT_MASK 0x0000ffff /* flags reported by reflection */
+#define ACC_CLASS_HAS_POINTERS 0x00010000 /* instance contains pointers */
-struct jni_callblock {
- u8 itemtype;
- u8 item;
-};
+/* special flags used in methodinfo *******************************************/
-typedef struct jni_callblock jni_callblock;
+#define ACC_METHOD_IMPLEMENTED 0x00010000 /* there is an implementation */
+#define ACC_METHOD_MONOMORPHIC 0x00020000 /* currently monomorphic method */
/* data structures of the runtime system **************************************/
All objects (and arrays) which resides on the heap need the
following header at the beginning of the data structure.
+ TODO: Include detailed description from the Wiki (ObjectHeader) here.
+
*******************************************************************************/
-struct java_objectheader { /* header for all objects */
- struct _vftbl *vftbl; /* pointer to virtual function table */
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
- void *monitorPtr;
+#define HDRFLAG_FLC 0x01
+
+struct java_objectheader { /* header for all objects */
+ struct _vftbl *vftbl; /* pointer to virtual function table */
+#if defined(ENABLE_THREADS)
+ struct lock_record_t *monitorPtr;
+#endif
+#if defined(ENABLE_THREADS) || defined(ENABLE_GC_CACAO)
+ ptrint hdrflags; /* word containing the FLC and GC bits */
#endif
};
/* structs for all kinds of arrays ********************************************/
-typedef struct java_chararray {
- java_arrayheader header;
- u2 data[1];
-} java_chararray;
-
-typedef struct java_floatarray {
- java_arrayheader header;
- float data[1];
-} java_floatarray;
-
-typedef struct java_doublearray {
- java_arrayheader header;
- double data[1];
-} java_doublearray;
-
/* booleanarray and bytearray need identical memory layout (access methods
use the same machine code */
s1 data[1];
} java_bytearray;
+typedef struct java_chararray {
+ java_arrayheader header;
+ u2 data[1];
+} java_chararray;
+
typedef struct java_shortarray {
java_arrayheader header;
s2 data[1];
s8 data[1];
} java_longarray;
+typedef struct java_floatarray {
+ java_arrayheader header;
+ float data[1];
+} java_floatarray;
+
+typedef struct java_doublearray {
+ java_arrayheader header;
+ double data[1];
+} java_doublearray;
+
/* objectarray and arrayarray need identical memory layout (access methods
use the same machine code */
};
-#define VFTBLINTERFACETABLE(v,i) (v)->interfacetable[-i]
-
-
-/* flag variables *************************************************************/
-
-extern bool cacao_initializing;
-
-
/* Synchronization ************************************************************/
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
-void cast_lock();
-void cast_unlock();
+#if defined(ENABLE_THREADS)
void compiler_lock();
void compiler_unlock();
#endif
-/**** Methods: called directly by cacao, which defines the callpath ***/
-#define MAINCLASS mainstring
-#define MAINMETH "main"
-#define MAINDESC "([Ljava/lang/String;)V"
-
-#define EXITCLASS "java/lang/System"
-#define EXITMETH "exit"
-#define EXITDESC "(I)V"
+/* global constants related to the verifier ***********************************/
-#if defined(USE_THREADS)
- #define THREADCLASS "java/lang/Thread"
- #define THREADMETH "<init>"
- #define THREADDESC "(Ljava/lang/VMThread;Ljava/lang/String;IZ)V"
+/* The verifier needs additional variables in the variable array. Since these */
+/* must be reserved and set by parse.c and stack.c, we define these numbers */
+/* here to avoid mysterious hard-coded constants. */
+/* stack.c needs an extra variable if the verifier is disabled. */
- #define THREADGROUPCLASS "java/lang/ThreadGroup"
- #define THREADGROUPMETH "addThread"
- #define THREADGROUPDESC "(Ljava/lang/Thread;)V"
+#if defined(ENABLE_VERIFIER)
+# define VERIFIER_EXTRA_LOCALS 1
+# define VERIFIER_EXTRA_VARS 1
+# define STACK_EXTRA_VARS 0
+#else
+# define VERIFIER_EXTRA_LOCALS 0
+# define VERIFIER_EXTRA_VARS 0
+# define STACK_EXTRA_VARS 1
#endif
#endif /* _GLOBAL_H */
* c-basic-offset: 4
* tab-width: 4
* End:
+ * vim:noexpandtab:sw=4:ts=4:
*/