Merged revisions 8245-8298 via svnmerge from
[cacao.git] / src / vm / global.h
index cf4d928433cebcae7d50efabb36bb14d7ac69694..07963d38f52aa19ffe58b744bad7397afd0a8a67 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/global.h - global definitions
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   Copyright (C) 1996-2005, 2007, 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
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Reinhard Grafl
-            Andreas Krall
-            Mark Probst
-            Philipp Tomsich
-            Edwin Steiner
-            Joseph Wenninger
-            Christian Thalinger
-
-   $Id: global.h 7601 2007-03-28 23:02:50Z michi $
+   $Id: global.h 8299 2007-08-13 08:41:18Z michi $
 
 */
 
@@ -81,9 +71,17 @@ typedef union {
 } imm_union;
 
 
+/* alignment macros ***********************************************************/
+
+#define ALIGN_EVEN(a)                   ((a) = (((a) + 1) & ~1))
+#define ALIGN_ODD(a)                    ((a) =   (a) | 1       )
+
+#define ALIGN_2(a)                      ALIGN_EVEN(a)
+
+
 /* forward typedefs ***********************************************************/
 
-typedef struct java_objectheader java_objectheader
+typedef struct java_object_t java_object_t
 typedef struct java_objectarray java_objectarray;
 
 
@@ -120,29 +118,6 @@ typedef struct java_objectarray java_objectarray;
 #define IS_VOID_TYPE(a)         ((a) == TYPE_VOID)
 
 
-/* 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. */
-
-#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. */
-
-#define PRIMITIVETYPE_INT     TYPE_INT
-#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 PRIMITIVETYPE_SHORT   7
-#define PRIMITIVETYPE_BOOLEAN 8
-#define PRIMITIVETYPE_DUMMY2  9            /* not used! */
-#define PRIMITIVETYPE_VOID    TYPE_VOID
-
 /* some Java related defines **************************************************/
 
 #define JAVA_VERSION    "1.5.0"         /* this version is supported by CACAO */
@@ -203,21 +178,25 @@ typedef struct java_objectarray java_objectarray;
 #define ACC_CLASS_REFLECT_MASK      0x0000ffff/* flags reported by reflection */
 
 #define ACC_CLASS_PRIMITIVE         0x00010000/* class is a primitive class   */
+
 #define ACC_CLASS_HAS_POINTERS      0x00020000/* instance contains pointers   */
-#define ACC_CLASS_SOFT_REFERENCE    0x00040000
-#define ACC_CLASS_WEAK_REFERENCE    0x00080000
-#define ACC_CLASS_PHANTOM_REFERENCE 0x00100000
+
+#define ACC_CLASS_REFERENCE_MASK    0x001c0000
+#define ACC_CLASS_REFERENCE_SOFT    0x00040000
+#define ACC_CLASS_REFERENCE_WEAK    0x00080000
+#define ACC_CLASS_REFERENCE_PHANTOM 0x00100000
 
 
 /* special flags used in methodinfo *******************************************/
 
-#define ACC_METHOD_IMPLEMENTED 0x00010000     /* there is an implementation   */
-#define ACC_METHOD_MONOMORPHIC 0x00020000     /* currently monomorphic method */
+#define ACC_METHOD_BUILTIN     0x00010000     /* use for descriptor parsing   */
+#define ACC_METHOD_IMPLEMENTED 0x00020000     /* there is an implementation   */
+#define ACC_METHOD_MONOMORPHIC 0x00040000     /* currently monomorphic method */
 
 
 /* data structures of the runtime system **************************************/
 
-/* java_objectheader ***********************************************************
+/* java_object_t ***************************************************************
 
    All objects (and arrays) which resides on the heap need the
    following header at the beginning of the data structure.
@@ -234,7 +213,7 @@ typedef struct java_objectarray java_objectarray;
 #define HDRFLAG_HASH_ATTACHED 0x20
 #define HDRFLAG_REFERENCING   0x40
 
-struct java_objectheader {             /* header for all objects              */
+struct java_object_t {                 /* header for all objects              */
        struct _vftbl            *vftbl;   /* pointer to virtual function table   */
 #if defined(ENABLE_THREADS)
        struct lock_record_t *monitorPtr;
@@ -245,6 +224,15 @@ struct java_objectheader {             /* header for all objects              */
 };
 
 
+#if 0
+typedef struct java_handle_t {
+       java_object_t *heap_object;
+} java_handle_t;
+#else
+typedef java_object_t java_handle_t;
+#endif
+
+
 /* arrays **********************************************************************
 
        All arrays are objects (they need the object header with a pointer
@@ -253,22 +241,8 @@ struct java_objectheader {             /* header for all objects              */
        which is referenced by the vftbl.
 */
 
-/* CAUTION: Don't change the numerical values! These constants (with
- * the exception of ARRAYTYPE_OBJECT) are used as indices in the
- * primitive type table.
- */
-#define ARRAYTYPE_INT      PRIMITIVETYPE_INT
-#define ARRAYTYPE_LONG     PRIMITIVETYPE_LONG
-#define ARRAYTYPE_FLOAT    PRIMITIVETYPE_FLOAT
-#define ARRAYTYPE_DOUBLE   PRIMITIVETYPE_DOUBLE
-#define ARRAYTYPE_BYTE     PRIMITIVETYPE_BYTE
-#define ARRAYTYPE_CHAR     PRIMITIVETYPE_CHAR
-#define ARRAYTYPE_SHORT    PRIMITIVETYPE_SHORT
-#define ARRAYTYPE_BOOLEAN  PRIMITIVETYPE_BOOLEAN
-#define ARRAYTYPE_OBJECT   PRIMITIVETYPE_VOID     /* don't use as index! */
-
 typedef struct java_arrayheader {       /* header for all arrays              */
-       java_objectheader objheader;        /* object header                      */
+       java_object_t objheader;            /* object header                      */
        s4 size;                            /* array size                         */
 } java_arrayheader;
 
@@ -323,19 +297,11 @@ typedef struct java_doublearray {
     use the same machine code */
 
 struct java_objectarray {
-       java_arrayheader   header;
-       java_objectheader *data[1];
+       java_arrayheader  header;
+       java_object_t    *data[1];
 };
 
 
-/* Synchronization ************************************************************/
-
-#if defined(ENABLE_THREADS)
-void compiler_lock();
-void compiler_unlock();
-#endif
-
-
 /* global constants related to the verifier ***********************************/
 
 /* The verifier needs additional variables in the variable array. Since these */