GNU header update.
[cacao.git] / src / vm / global.h
index 8f444cd832da8bb3536fa2af3a9578ad66d30822..eb2f080f021a7a2e40a58ebedd46e9c9dc26c1d6 100644 (file)
@@ -1,9 +1,9 @@
 /* global.h - global definitions
 
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-   R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
-   M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
-   P. Tomsich, J. Wenninger
+   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
 
    This file is part of CACAO.
 
 
    Changes: Mark Probst
             Philipp Tomsich
+                       Edwin Steiner
+            Joseph Wenninger
 
-   $Id: global.h 655 2003-11-20 14:52:00Z carolyn $
+   $Id: global.h 1735 2004-12-07 14:33:27Z twisti $
 
 */
 
 
 #include "config.h"
 #include "types.h"
+
+
+/* resolve typedef cycles *****************************************************/
+
+typedef struct utf utf;
+typedef struct literalstring literalstring;
+typedef struct java_objectheader java_objectheader; 
+typedef struct classinfo classinfo; 
+typedef struct _vftbl vftbl_t;
+typedef u1* methodptr;
+typedef struct fieldinfo  fieldinfo; 
+typedef struct exceptiontable exceptiontable;
+typedef struct methodinfo methodinfo; 
+typedef struct lineinfo lineinfo; 
+typedef struct arraydescriptor arraydescriptor;
+
+
+/* additional data types ******************************************************/
+
+typedef void *voidptr;                  /* generic pointer                    */
+typedef void (*functionptr) ();         /* generic function pointer           */
+
+typedef int   bool;                     /* boolean data type                  */
+
+#define true  1
+#define false 0
+
+
+/* additional includes ********************************************************/
+
 #include "toolbox/list.h"
+#include "vm/jit/inline/sets.h"
 
 
-#define _GNU_SOURCE
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#include <pthread.h>
+#include <semaphore.h>
+#endif
+
+/* define path to rt.jar plus ending : ****************************************/
+
+#define CACAO_LIBRARY_PATH    "/jre/lib/"ARCH_DIR"/"
+#define CACAO_RT_JAR_PATH     "/jre/lib/rt.jar:"
+
 
 #define STATISTICS          /* if enabled collects program statistics         */
 
  */
 #define SIZE_FROM_CLASSINFO
 
+/*
+ * CACAO_TYPECHECK activates typechecking (part of bytecode verification)
+ */
+#define CACAO_TYPECHECK
 
-/* additional data types ******************************************************/
+/*
+ * 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
 
-typedef void *voidptr;          /* generic pointer */
+/*
+ * Macros for configuration of the typechecking code
+ *
+ * TYPECHECK_STATISTICS activates gathering statistical information.
+ * TYPEINFO_DEBUG activates debug checks and debug helpers in typeinfo.c
+ * TYPECHECK_DEBUG activates debug checks in typecheck.c
+ * TYPEINFO_DEBUG_TEST activates the typeinfo test at startup.
+ * TYPECHECK_VERBOSE_IMPORTANT activates important debug messages
+ * TYPECHECK_VERBOSE activates all debug messages
+ */
+#ifdef CACAO_TYPECHECK
+/*#define TYPECHECK_STATISTICS
+#define TYPEINFO_DEBUG
+#define TYPECHECK_DEBUG
+#define TYPEINFO_DEBUG_TEST
+#define TYPECHECK_VERBOSE
+#define TYPECHECK_VERBOSE_IMPORTANT*/
+#if defined(TYPECHECK_VERBOSE) || defined(TYPECHECK_VERBOSE_IMPORTANT)
+#define TYPECHECK_VERBOSE_OPT
+#endif
+#endif
 
-typedef int   bool;             /* boolean data type */
 
-#define true  1
-#define false 0
+/* immediate data union */
 
-#define PRIMITIVETYPE_COUNT  9  /* number of primitive types */
+typedef union {
+       s4          i;
+       s8          l;
+       float       f;
+       double      d;
+       void       *a;
+       functionptr fp;
+       u1          b[8];
+} imm_union;
 
-typedef void (*functionptr) (); /* generic function pointer */
 
+#define PRIMITIVETYPE_COUNT  9  /* number of primitive types */
 
-#define MAX_ALIGN 8             /* most generic alignment for JavaVM values   */
+/* CAUTION: Don't change the numerical values! These constants are
+ * used as indices into the primitive type table.
+ */
+#define PRIMITIVETYPE_INT     0
+#define PRIMITIVETYPE_LONG    1
+#define PRIMITIVETYPE_FLOAT   2
+#define PRIMITIVETYPE_DOUBLE  3
+#define PRIMITIVETYPE_BYTE    4
+#define PRIMITIVETYPE_CHAR    5
+#define PRIMITIVETYPE_SHORT   6
+#define PRIMITIVETYPE_BOOLEAN 7
+#define PRIMITIVETYPE_VOID    8
 
-/* shutdown function **********************************************************/
 
-void cacao_shutdown(s4 status);
+#define MAX_ALIGN 8             /* most generic alignment for JavaVM values   */
 
 
 /* basic data types ***********************************************************/
 
+/* 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)              */
@@ -89,8 +177,8 @@ void cacao_shutdown(s4 status);
 /* Java class file constants **************************************************/
 
 #define MAGIC         0xcafebabe
-#define MINOR_VERSION 3
-#define MAJOR_VERSION 45
+#define MINOR_VERSION 0
+#define MAJOR_VERSION 48
 
 #define CONSTANT_Class                 7
 #define CONSTANT_Fieldref              9
@@ -104,7 +192,6 @@ void cacao_shutdown(s4 status);
 #define CONSTANT_NameAndType          12
 #define CONSTANT_Utf8                  1
 
-#define CONSTANT_Arraydescriptor      13
 #define CONSTANT_UNUSED                0
 
 #define ACC_PUBLIC                0x0001
@@ -112,24 +199,14 @@ void cacao_shutdown(s4 status);
 #define ACC_PROTECTED             0x0004
 #define ACC_STATIC                0x0008
 #define ACC_FINAL                 0x0010
+#define ACC_SUPER                 0x0020
 #define ACC_SYNCHRONIZED          0x0020
 #define ACC_VOLATILE              0x0040
 #define ACC_TRANSIENT             0x0080
 #define ACC_NATIVE                0x0100
 #define ACC_INTERFACE             0x0200
 #define ACC_ABSTRACT              0x0400
-
-
-/* resolve typedef cycles *****************************************************/
-
-typedef struct utf utf;
-typedef struct literalstring literalstring;
-typedef struct java_objectheader java_objectheader; 
-typedef struct classinfo classinfo; 
-typedef struct vftbl vftbl;
-typedef u1* methodptr;
-typedef struct fieldinfo  fieldinfo; 
-typedef struct methodinfo methodinfo; 
+#define ACC_STRICT                0x0800
 
 
 /* constant pool entries *******************************************************
@@ -151,7 +228,6 @@ typedef struct methodinfo methodinfo;
     CONSTANT_Double              constant_double                    yes
     CONSTANT_NameAndType         constant_nameandtype               yes
     CONSTANT_Utf8                unicode                             no
-    CONSTANT_Arraydescriptor     constant_arraydescriptor           yes
     CONSTANT_UNUSED              -
 
 *******************************************************************************/
@@ -224,6 +300,63 @@ struct literalstring {
 };
 
 
+/* data structure for storing information needed for a stacktrace across native functions*/
+
+typedef struct native_stackframeinfo native_stackframeinfo;
+
+struct native_stackframeinfo {
+       void *oldThreadspecificHeadValue;
+       void **addressOfThreadspecificHead;
+       methodinfo *method;
+#ifdef __ALPHA__
+       void *savedpv;
+#endif
+       void *beginOfJavaStackframe; /*only used if != 0*/
+       void *returnToFromNative;
+
+#if 0
+       void *returnFromNative;
+       void *addrReturnFromNative;
+       methodinfo *method;
+       struct native_stackframeinfo *next;
+       struct native_stackframeinfo *prev;
+#endif
+};
+
+
+typedef struct stacktraceelement stacktraceelement;
+
+struct stacktraceelement {
+#if POINTERSIZE == 8
+       u8 linenumber;
+#else
+       u4 linenumber;
+#endif
+       methodinfo *method;
+};
+
+
+typedef struct stackTraceBuffer stackTraceBuffer;
+
+struct stackTraceBuffer {
+       s4                 needsFree;
+       stacktraceelement *start;
+       s4                 size;
+       s4                 full;
+};
+
+
+
+/* data structure for calls from c code to java methods */
+
+struct jni_callblock {
+       u8 itemtype;
+       u8 item;
+};
+
+typedef struct jni_callblock jni_callblock;
+
+
 /* data structure for accessing hashtables ************************************/
 
 typedef struct {            
@@ -235,7 +368,7 @@ typedef struct {
 
 /* data structures of remaining constant pool entries *************************/
 
-typedef struct {                /* Fieldref, Methodref and InterfaceMethodref     */
+typedef struct {            /* Fieldref, Methodref and InterfaceMethodref     */
        classinfo *class;       /* class containing this field/method/interface   */
        utf       *name;        /* field/method/interface name                    */
        utf       *descriptor;  /* field/method/interface type descriptor string  */
@@ -268,21 +401,6 @@ typedef struct {            /* NameAndType (Field or Method)                  */
 } constant_nameandtype;
 
 
-/* 
-   arraydescriptor describes array types. Basic array types contain their
-   type in the arraytype field, objectclass contains a class pointer for
-   arrays of objects (arraytype == ARRAYTYPE_OBJECT), elementdescriptor
-   contains a pointer to an arraydescriptor which describes the element
-   types in the case of arrays of arrays (arraytype == ARRAYTYPE_ARRAY).
-*/
-
-typedef struct constant_arraydescriptor {
-       int arraytype;
-       classinfo *objectclass;
-       struct constant_arraydescriptor *elementdescriptor;
-} constant_arraydescriptor;
-
-
 /* data structures of the runtime system **************************************/
 
 /* objects *********************************************************************
@@ -292,29 +410,35 @@ typedef struct constant_arraydescriptor {
 */
 
 struct java_objectheader {              /* header for all objects             */
-       vftbl *vftbl;                       /* pointer to virtual function table  */
+       vftbl_t *vftbl;                     /* pointer to virtual function table  */
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+       void *monitorPtr;
+#endif
 };
 
 
 
 /* arrays **********************************************************************
 
-       All arrays are objects (they need the object header with a pointer to a
-       vvftbl (array class table). There is only one class for all arrays. The
-       type of an array is stored directly in the array object. Following types
-       are defined:
+       All arrays are objects (they need the object header with a pointer
+       to a vftbl (array class table). There is one class for each array
+       type. The array type is described by an arraydescriptor struct
+       which is referenced by the vftbl.
 */
 
-#define ARRAYTYPE_INT      0
-#define ARRAYTYPE_LONG     1
-#define ARRAYTYPE_FLOAT    2
-#define ARRAYTYPE_DOUBLE   3
-#define ARRAYTYPE_BYTE     4
-#define ARRAYTYPE_CHAR     5
-#define ARRAYTYPE_SHORT    6
-#define ARRAYTYPE_BOOLEAN  7
-#define ARRAYTYPE_OBJECT   8
-#define ARRAYTYPE_ARRAY    9
+/* 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                      */
@@ -322,7 +446,6 @@ typedef struct java_arrayheader {       /* header for all arrays              */
 #ifdef SIZE_FROM_CLASSINFO
        s4 alignedsize; /* phil */
 #endif
-       s4 arraytype;                       /* array type from previous list      */
 } java_arrayheader;
 
 
@@ -377,31 +500,26 @@ typedef struct java_longarray {
 
 typedef struct java_objectarray {
        java_arrayheader header;
-       classinfo *elementtype;
        java_objectheader *data[1];
 } java_objectarray;
 
-typedef struct java_arrayarray {
-       java_arrayheader header;
-       constant_arraydescriptor *elementdescriptor;
-       java_arrayheader *data[1];
-} java_arrayarray;
-
 
 /* structure for primitive classes ********************************************/
 
 typedef struct primitivetypeinfo {
        classinfo *class_wrap;               /* class for wrapping primitive type */
        classinfo *class_primitive;          /* primitive class                   */
-       char *wrapname;                      /* name of class for wrapping        */
-       char typesig;                        /* one character type signature      */
-       char *name;                          /* name of primitive class           */
+       char      *wrapname;                 /* name of class for wrapping        */
+       char      typesig;                   /* one character type signature      */
+       char      *name;                     /* name of primitive class           */
+       char      *arrayname;                /* name of primitive array class     */
+       classinfo *arrayclass;               /* primitive array class             */
+       vftbl_t     *arrayvftbl;             /* vftbl of primitive array class    */
 } primitivetypeinfo;
 
 
 /* field, method and class structures *****************************************/
 
-#include "sets.h"
 typedef        struct xtafldinfo {
        bool       fieldChecked;                
        classinfo *fldClassType;
@@ -419,120 +537,152 @@ struct fieldinfo {            /* field of a class                                 */
        
        s4  offset;           /* offset from start of object (instance variables) */
 
-       union {               /* storage for static values (class variables)      */
-               s4 i; 
-               s8 l;
-               float f;
-               double d;
-               void *a; 
-       } value;
+       imm_union value;      /* storage for static values (class variables)      */
+
+       classinfo *class;     /* needed by typechecker. Could be optimized        */
+                             /* away by using constant_FMIref instead of         */
+                             /* fieldinfo throughout the compiler.               */
        
        xtafldinfo *xta;
 };
 
-struct basicblock;
 
 /* exceptiontable *************************************************************/
 
-typedef struct xtable { /* exceptiontable entry in a method           */ 
-       s4         startpc;         /* start pc of guarded area (inclusive)       */
+struct exceptiontable {         /* exceptiontable entry in a method           */
+       s4              startpc;    /* start pc of guarded area (inclusive)       */
        struct basicblock *start;
 
-       s4         endpc;           /* end pc of guarded area (exklusive)         */
+       s4              endpc;      /* end pc of guarded area (exklusive)         */
        struct basicblock *end;
 
-       s4         handlerpc;       /* pc of exception handler                    */
+       s4              handlerpc;  /* pc of exception handler                    */
        struct basicblock *handler;
 
-       classinfo *catchtype;       /* catchtype of exception (NULL == catchall)  */
-       struct xtable *next;        /* used to build a list of exception when     */
+       classinfo      *catchtype;  /* catchtype of exception (NULL == catchall)  */
+       exceptiontable *next;       /* used to build a list of exception when     */
                                    /* loops are copied */
-       struct xtable *down;        /* instead of the old array, a list is used   */
-} xtable;
-
-
-typedef struct exceptiontable { /* exceptiontable entry in a method           */ 
-       s4         startpc;         /* start pc of guarded area (inclusive)       */
-       s4         endpc;           /* end pc of guarded area (exklusive)         */
-       s4         handlerpc;       /* pc of exception handler                    */
-       classinfo *catchtype;       /* catchtype of exception (NULL == catchall)  */
-} exceptiontable;
+       exceptiontable *down;       /* instead of the old array, a list is used   */
+};
 
 
 /* methodinfo  static info ****************************************************/
+
 typedef struct xtainfo {
-        s4             XTAmethodUsed;  /* XTA if used in callgraph -    not used /used */
-       classSet        *XTAclassSet;      /* method class type set                 */ 
+       s4          XTAmethodUsed;     /* XTA if used in callgraph - not used /used */
+       classSet    *XTAclassSet;      /* method class type set                 */ 
        /*classSet      *PartClassSet */   /* method class type set                 */ 
 
-       classSetNode    *paramClassSet;     /* cone set of methods parameters       */
+       classSetNode    *paramClassSet; /* cone set of methods parameters       */
 
-       methSet         *calls;            /* methods this method calls             */ 
+       methSet         *calls;            /* methods this method calls                 */ 
        methSet         *calledBy;         /* methods that call this method         */ 
-       methSet         *marked;           /* methods that marked by this method    */ 
-       /*methSet         *markedBy*/
+       methSet         *marked;  /*not in Dez*/         /* methods that marked by this method    */ 
+       methSet         *markedBy;
        fldSet          *fldsUsed;         /* fields used by this method             */ 
        /*methSetNode  *interfaceCalls*/   /* methods this method calls as interface */ 
-       bool             chgdSinceLastParse; /* Changed since last parse ?          */
+       bool           chgdSinceLastParse; /* Changed since last parse ?          */
 } xtainfo; 
 
+
+/* lineinfo *****************************************************************/
+
+struct lineinfo {
+       u2 start_pc;
+       u2 line_number;
+};
+
+
 /* methodinfo *****************************************************************/
 
 struct methodinfo {                 /* method structure                       */
-       s4             flags;               /* ACC flags                              */
-       utf       *name;                /* name of method                         */
-       utf       *descriptor;          /* JavaVM descriptor string of method     */
-       s4         returntype;          /* only temporary valid, return type      */
-       classinfo *returnclass;         /* pointer to classinfo for the rtn type  */ /*XTA*/ 
-       s4         paramcount;          /* only temporary valid, parameter count  */
-       u1        *paramtypes;          /* only temporary valid, parameter types  */
+       java_objectheader header;       /* we need this in jit's monitorenter     */
+       s4          flags;              /* ACC flags                              */
+       utf        *name;               /* name of method                         */
+       utf        *descriptor;         /* JavaVM descriptor string of method     */
+       s4          returntype;         /* only temporary valid, return type      */
+       classinfo  *returnclass;        /* pointer to classinfo for the rtn type  */ /*XTA*/ 
+       s4          paramcount;         /* only temporary valid, parameter count  */
+       u1         *paramtypes;         /* only temporary valid, parameter types  */
        classinfo **paramclass;         /* pointer to classinfo for a parameter   */ /*XTA*/
-       
-       classinfo *class;               /* class, the method belongs to           */
-       s4         vftblindex;          /* index of method in virtual function table
-                                          (if it is a virtual method)            */
-       s4         maxstack;            /* maximum stack depth of method          */
-       s4         maxlocals;           /* maximum number of local variables      */
-       s4         jcodelength;         /* length of JavaVM code                  */
-       u1        *jcode;               /* pointer to JavaVM code                 */
-
-       s4         exceptiontablelength;/* exceptiontable length                  */
-       exceptiontable *exceptiontable; 
-                                    /* the exceptiontable                     */
-
-       u1        *stubroutine;         /* stub for compiling or calling natives  */    
-       s4         mcodelength;         /* legth of generated machine code        */
-       u1        *mcode;               /* pointer to machine code                */
-       u1        *entrypoint;          /* entry point in machine code            */
+
+       bool        isleafmethod;       /* does method call subroutines           */
+
+       classinfo  *class;              /* class, the method belongs to           */
+       s4          vftblindex;         /* index of method in virtual function    */
+                                       /* table (if it is a virtual method)      */
+       s4          maxstack;           /* maximum stack depth of method          */
+       s4          maxlocals;          /* maximum number of local variables      */
+       s4          jcodelength;        /* length of JavaVM code                  */
+       u1         *jcode;              /* pointer to JavaVM code                 */
+
+       s4          basicblockcount;    /* number of basic blocks                 */
+       struct basicblock *basicblocks; /* points to basic block array            */
+       s4         *basicblockindex;    /* a table which contains for every byte  */
+                                       /* of JavaVM code a basic block index if  */
+                                       /* at this byte is the start of a basic   */
+                                       /* block                                  */
+
+       s4          instructioncount;   /* number of JavaVM instructions          */
+       struct instruction *instructions; /* points to intermediate code instructions */
+
+       s4          stackcount;         /* number of stack elements               */
+       struct stackelement *stack;     /* points to intermediate code instructions */
+
+       s4          exceptiontablelength;/* exceptiontable length                 */
+       exceptiontable *exceptiontable; /* the exceptiontable                     */
+
+       u2          thrownexceptionscount;/* number of exceptions attribute       */
+       classinfo **thrownexceptions;   /* checked exceptions a method may throw  */
+
+       u2          linenumbercount;    /* number of linenumber attributes        */
+       lineinfo   *linenumbers;        /* array of lineinfo items                */
+
+       int       c_debug_nr;           /* a counter to number all BB with an     */
+                                       /* unique value                           */
+
+       u1         *stubroutine;        /* stub for compiling or calling natives  */
+       s4          mcodelength;        /* legth of generated machine code        */
+       functionptr mcode;              /* pointer to machine code                */
+       functionptr entrypoint;         /* entry point in machine code            */
 
        /*rtainfo   rta;*/
        xtainfo    *xta;
 
-       s4        methodUsed;           /* marked (might be used later) /not used /used */
-       s4        monoPoly;             /* call is mono or poly or unknown        */ /*RT stats */
+       s4          methodUsed;         /* marked (might be used later) /not used /used */
+       s4          monoPoly;           /* call is mono or poly or unknown        */ /*RT stats */
         /* should # method def'd and used be kept after static parse (will it be used?) */
-       s4        subRedefs;
-       s4        subRedefsUsed;
+       s4              subRedefs;
+       s4              subRedefsUsed;
+       s4              nativelyoverloaded; /* used in header.c and only valid there  */
 };
 
 
-
 /* innerclassinfo *************************************************************/
 
 typedef struct innerclassinfo {
        classinfo *inner_class;       /* inner class pointer                      */
        classinfo *outer_class;       /* outer class pointer                      */
-       utf *name;                    /* innerclass name                          */ 
-       s4 flags;                     /* ACC flags                                */
+       utf       *name;              /* innerclass name                          */
+       s4         flags;             /* ACC flags                                */
 } innerclassinfo;
 
+
 /* classinfo ******************************************************************/
 
 struct classinfo {                /* class structure                          */
        java_objectheader header;     /* classes are also objects                 */
+       java_objectarray* signers;
+       struct java_security_ProtectionDomain* pd;
+       struct java_lang_VMClass* vmClass;
+       struct java_lang_reflect_Constructor* constructor;
+
+       s4 initializing_thread;       /* gnu classpath                            */
+       s4 erroneous_state;           /* gnu classpath                            */
+       struct gnu_classpath_RawData* vmData; /* gnu classpath                    */
 
        s4          flags;            /* ACC flags                                */
-       utf        *name;             /* class name                               */ 
+       utf        *name;             /* class name                               */
 
        s4          cpcount;          /* number of entries in constant pool       */
        u1         *cptags;           /* constant pool tags                       */
@@ -553,31 +703,39 @@ struct classinfo {                /* class structure                          */
 
        listnode    listnode;         /* linkage                                  */
 
-       bool        initialized;      /* true, if class already initialised       */ 
+       bool        initialized;      /* true, if class already initialized       */
+       bool        initializing;     /* flag for the compiler                    */
+       bool        loaded;           /* true, if class already loaded            */
        bool        linked;           /* true, if class already linked            */
-       s4          index;            /* hierarchy depth (classes) or index
-                                        (interfaces)                             */ 
+       s4          index;            /* hierarchy depth (classes) or index       */
+                                     /* (interfaces)                             */
        s4          instancesize;     /* size of an instance of this class        */
 #ifdef SIZE_FROM_CLASSINFO
-       s4          alignedsize;      /* size of an instance, aligned to the 
-                                                     allocation size on the heap */
+       s4          alignedsize;      /* size of an instance, aligned to the      */
+                                     /* allocation size on the heap              */
 #endif
 
-       vftbl      *vftbl;            /* pointer to virtual function table        */
+       vftbl_t    *vftbl;            /* pointer to virtual function table        */
 
        methodinfo *finalizer;        /* finalizer method                         */
 
-    u2             innerclasscount;   /* number of inner classes              */
+    u2          innerclasscount;  /* number of inner classes                  */
     innerclassinfo *innerclass;
 
-    classinfo      *hashlink;         /* link for external hash chain         */
+    classinfo  *hashlink;         /* link for external hash chain             */
        bool        classvftbl;       /* has its own copy of the Class vtbl       */
 
-        s4          classUsed;        /* 0= not used 1 = used   CO-RT             */
+       s4          classUsed;        /* 0= not used 1 = used   CO-RT             */
 
-       classSetNode *impldBy;          /* implemented by class set */
+       classSetNode *impldBy;        /* implemented by class set                 */
+       utf        *packagename;      /* full name of the package                 */
+       utf        *sourcefile;       /* classfile name containing this class     */
+       java_objectheader *classloader; /* NULL for bootstrap classloader         */
 };
 
+/* check if class is an array class. Only use for linked classes! */
+#define CLASS_IS_ARRAY(clsinfo)  ((clsinfo)->vftbl->arraydesc != NULL)
+
 
 /* virtual function table ******************************************************
 
@@ -635,15 +793,18 @@ struct classinfo {                /* class structure                          */
 
 *******************************************************************************/
 
-struct vftbl {
+struct _vftbl {
        methodptr   *interfacetable[1];    /* interface table (access via macro)  */
 
        classinfo   *class;                /* class, the vtbl belongs to          */
 
+       arraydescriptor *arraydesc;        /* for array classes, otherwise NULL   */
+
        s4           vftbllength;          /* virtual function table length       */
        s4           interfacetablelength; /* interface table length              */
 
        s4           baseval;              /* base for runtime type check         */
+                                          /* (-index for interfaces)             */
        s4           diffval;              /* high - base for runtime type check  */
 
        s4          *interfacevftbllength; /* length of interface vftbls          */
@@ -654,66 +815,99 @@ struct vftbl {
 #define VFTBLINTERFACETABLE(v,i)       (v)->interfacetable[-i]
 
 
-/* references to some system classes ******************************************/
+/* arraydescriptor ************************************************************
 
-extern classinfo *class_java_lang_Object;
-extern classinfo *class_java_lang_String;
-extern classinfo *class_java_lang_ClassCastException;
-extern classinfo *class_java_lang_NullPointerException;
-extern classinfo *class_java_lang_ArrayIndexOutOfBoundsException;
-extern classinfo *class_java_lang_NegativeArraySizeException;
-extern classinfo *class_java_lang_OutOfMemoryError;
-extern classinfo *class_java_lang_ArithmeticException;
-extern classinfo *class_java_lang_ArrayStoreException;
-extern classinfo *class_java_lang_ThreadDeath;
-extern classinfo *class_array;
+    For every array class an arraydescriptor is allocated which
+    describes the array class.
+       The arraydescriptor is referenced from the vftbl of the array
+       class.
 
-/* instances of some system classes *******************************************/
+*******************************************************************************/
 
-extern java_objectheader *proto_java_lang_ClassCastException;
-extern java_objectheader *proto_java_lang_NullPointerException;
-extern java_objectheader *proto_java_lang_ArrayIndexOutOfBoundsException;
-extern java_objectheader *proto_java_lang_NegativeArraySizeException;
-extern java_objectheader *proto_java_lang_OutOfMemoryError;
-extern java_objectheader *proto_java_lang_ArithmeticException;
-extern java_objectheader *proto_java_lang_ArrayStoreException;
-extern java_objectheader *proto_java_lang_ThreadDeath;
+struct arraydescriptor {
+       vftbl_t *componentvftbl; /* vftbl of the component type, NULL for primit. */
+       vftbl_t *elementvftbl;   /* vftbl of the element type, NULL for primitive */
+       s2       arraytype;      /* ARRAYTYPE_* constant                          */
+       s2       dimension;      /* dimension of the array (always >= 1)          */
+       s4       dataoffset;     /* offset of the array data from object pointer  */
+       s4       componentsize;  /* size of a component in bytes                  */
+       s2       elementtype;    /* ARRAYTYPE_* constant                          */
+};
 
 
 /* flag variables *************************************************************/
 
-extern bool compileall;
-extern bool runverbose;         
-extern bool verbose;         
-extern bool opt_rt;             /* Rapid Type Analysis for better inlining CO-RT*/
-extern bool opt_xta;            /* X Type Analysis for better inlining    CO-XTA*/
-extern bool opt_vta;            /* Variable Type Analysis for better inlining    CO-VTA*/
-
-//extern int pClassHeir;
-//extern int pCallgraph;
-//extern int pOpcodes;
-//extern int pStats;
-
-//extern void RT_jit_parse(methodinfo *m);
-
-/* statistic variables ********************************************************/
-
-extern int count_class_infos;
-extern int count_const_pool_len;
-extern int count_vftbl_len;
-extern int count_utf_len;
-extern int count_all_methods;
-extern int count_vmcode_len;
-extern int count_extable_len;
-extern int count_class_loads;
-extern int count_class_inits;
-extern int count_utf_new;
-extern int count_utf_new_found;
+extern bool cacao_initializing;
+
+#ifdef TYPECHECK_VERBOSE_OPT
+extern bool typecheckverbose;
+#endif
+
+/*extern int pClassHeir;*/
+/*extern int pCallgraph;*/
+/*extern int pOpcodes;*/
+/*extern int pStats;*/
+
+/*extern void RT_jit_parse(methodinfo *m);*/
+
 
 /* table of primitive types ***************************************************/
 
+/* This array can be indexed by the PRIMITIVETYPE_ and ARRAYTYPE_
+ * constants (except ARRAYTYPE_OBJECT).
+ */
 extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT];
 
+
+/* macros for descriptor parsing **********************************************/
+
+/* SKIP_FIELDDESCRIPTOR:
+ * utf_ptr must point to the first character of a field descriptor.
+ * After the macro call utf_ptr points to the first character after
+ * the field descriptor.
+ *
+ * CAUTION: This macro does not check for an unexpected end of the
+ * descriptor. Better use SKIP_FIELDDESCRIPTOR_SAFE.
+ */
+#define SKIP_FIELDDESCRIPTOR(utf_ptr)                                                  \
+       do { while (*(utf_ptr)=='[') (utf_ptr)++;                                       \
+               if (*(utf_ptr)++=='L')                                                                  \
+                       while(*(utf_ptr)++ != ';') /* skip */; } while(0)
+
+/* SKIP_FIELDDESCRIPTOR_SAFE:
+ * utf_ptr must point to the first character of a field descriptor.
+ * After the macro call utf_ptr points to the first character after
+ * the field descriptor.
+ *
+ * Input:
+ *     utf_ptr....points to first char of descriptor
+ *     end_ptr....points to first char after the end of the string
+ *     errorflag..must be initialized (to false) by the caller!
+ * Output:
+ *     utf_ptr....points to first char after the descriptor
+ *     errorflag..set to true if the string ended unexpectedly
+ */
+#define SKIP_FIELDDESCRIPTOR_SAFE(utf_ptr,end_ptr,errorflag)                   \
+       do { while ((utf_ptr) != (end_ptr) && *(utf_ptr)=='[') (utf_ptr)++;     \
+               if ((utf_ptr) == (end_ptr))                                                                             \
+                       (errorflag) = true;                                                                                     \
+               else                                                                                                                    \
+                       if (*(utf_ptr)++=='L') {                                                                        \
+                               while((utf_ptr) != (end_ptr) && *(utf_ptr)++ != ';')    \
+                                       /* skip */;                                                                                     \
+                               if ((utf_ptr)[-1] != ';')                                                               \
+                                       (errorflag) = true; }} while(0)
+
+
+/* Synchronization ************************************************************/
+
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+void cast_lock();
+void cast_unlock();
+void compiler_lock();
+void compiler_unlock();
+#endif
+
 #endif /* _GLOBAL_H */