Include options.h instead of main.h.
[cacao.git] / global.h
index d9cf9dd712e9bb8e9ffd5bca20a2e5574ce45a31..fab87a4c9aed2b860ff69eac91ef5ccd6c8bca5a 100644 (file)
--- a/global.h
+++ b/global.h
@@ -31,7 +31,7 @@
             Philipp Tomsich
                        Edwin Steiner
 
-   $Id: global.h 941 2004-03-06 17:27:56Z jowenn $
+   $Id: global.h 1230 2004-06-30 19:41:23Z twisti $
 
 */
 
 #ifndef _GLOBAL_H
 #define _GLOBAL_H
 
-#define _GNU_SOURCE
 
 #include "config.h"
 #include "types.h"
 #include "toolbox/list.h"
 
+
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
 #include <pthread.h>
 #endif
@@ -134,10 +134,6 @@ typedef void (*functionptr) (); /* generic function pointer */
 
 #define MAX_ALIGN 8             /* most generic alignment for JavaVM values   */
 
-/* shutdown function **********************************************************/
-
-void cacao_shutdown(s4 status);
-
 
 /* basic data types ***********************************************************/
 
@@ -154,8 +150,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
@@ -194,6 +190,7 @@ typedef struct classinfo classinfo;
 typedef struct vftbl vftbl;
 typedef u1* methodptr;
 typedef struct fieldinfo  fieldinfo; 
+typedef struct exceptiontable exceptiontable;
 typedef struct methodinfo methodinfo; 
 typedef struct lineinfo lineinfo; 
 typedef struct arraydescriptor arraydescriptor;
@@ -292,19 +289,37 @@ struct literalstring {
 
 /* data structure for storing information needed for a stacktrace across native functions*/
 struct native_stackframeinfo {
+       void *oldThreadspecificHeadValue;
+       void **addressOfThreadspecificHead;
+       methodinfo *method;
+       void *returnToFromNative;
+
+#if 0
        void *returnFromNative;
        void *addrReturnFromNative;
        methodinfo *method;
        struct native_stackframeinfo *next;
        struct native_stackframeinfo *prev;
+#endif
 };
 
 typedef struct native_stackframeinfo native_stackframeinfo;
 
+struct stacktraceelement {
+#if POINTERSIZE == 8
+       u8 linenumber;
+#else
+       u4 linenumber;
+#endif
+       methodinfo *method;
+};
+
+typedef struct stacktraceelement stacktraceelement;
+
 /* data structure for calls from c code to java methods */
 
 struct jni_callblock {
-       u1 itemtype;
+       u8 itemtype;
        u8 item;
 };
 
@@ -365,6 +380,9 @@ typedef struct {            /* NameAndType (Field or Method)                  */
 
 struct java_objectheader {              /* header for all objects             */
        vftbl *vftbl;                       /* pointer to virtual function table  */
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+       long monitorBits;
+#endif
 };
 
 
@@ -471,7 +489,7 @@ typedef struct primitivetypeinfo {
 
 /* field, method and class structures *****************************************/
 
-#include "sets.h"
+#include "jit/sets.h"
 typedef        struct xtafldinfo {
        bool       fieldChecked;                
        classinfo *fldClassType;
@@ -498,12 +516,10 @@ struct fieldinfo {              /* field of a class                                 */
        xtafldinfo *xta;
 };
 
-struct basicblock;
-
 
 /* exceptiontable *************************************************************/
 
-typedef struct xtable { /* exceptiontable entry in a method           */ 
+struct exceptiontable {         /* exceptiontable entry in a method           */
        s4         startpc;         /* start pc of guarded area (inclusive)       */
        struct basicblock *start;
 
@@ -514,21 +530,14 @@ typedef struct xtable { /* exceptiontable entry in a method           */
        struct basicblock *handler;
 
        classinfo *catchtype;       /* catchtype of exception (NULL == catchall)  */
-       struct xtable *next;        /* used to build a list of exception when     */
+       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                 */ 
@@ -547,11 +556,13 @@ typedef struct xtainfo {
 
 
 /* lineinfo *****************************************************************/
+
 struct lineinfo {
        u2 start_pc;
        u2 line_number;
 };
 
+
 /* methodinfo *****************************************************************/
 
 struct methodinfo {                 /* method structure                       */
@@ -563,7 +574,9 @@ struct methodinfo {                 /* method structure                       */
        s4         paramcount;          /* only temporary valid, parameter count  */
        u1        *paramtypes;          /* only temporary valid, parameter types  */
        classinfo **paramclass;         /* pointer to classinfo for a parameter   */ /*XTA*/
-       
+
+       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)            */
@@ -572,16 +585,31 @@ struct methodinfo {                 /* method structure                       */
        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 declared to be thrown by a method*/
-       classinfo **thrownexceptions;  /*array of classinfos of declared exceptions*/
+       u2        thrownexceptionscount;/*number of exceptions declared to be thrown by a method*/
+       classinfo **thrownexceptions;   /*array of classinfos of declared exceptions*/
+
+       u2         linenumbercount;     /* number of linenumber attributes        */
+       lineinfo  *linenumbers;         /* array of lineinfo items                */
 
-       u2      linenumbercount;        /*number of linenumber attributes*/
-       lineinfo *linenumbers;          /*array of lineinfo items (start_pc,line_number)*/
+       struct registerdata *registerdata; /* struct with all regalloc stuff      */
 
-       u1        *stubroutine;         /* stub for compiling or calling natives  */    
+       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            */
@@ -594,6 +622,7 @@ struct methodinfo {                 /* method structure                       */
         /* should # method def'd and used be kept after static parse (will it be used?) */
        s4        subRedefs;
        s4        subRedefsUsed;
+       s4        nativelyoverloaded;           /*used in header.c and only valid there*/
 };
 
 
@@ -616,10 +645,9 @@ struct classinfo {                /* class structure                          */
        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 initializing_thread;       /* gnu classpath                            */
+       s4 erroneous_state;           /* gnu classpath                            */
+       struct gnu_classpath_RawData* vmData; /* gnu classpath                    */
 
        s4          flags;            /* ACC flags                                */
        utf        *name;             /* class name                               */
@@ -643,11 +671,12 @@ struct classinfo {                /* class structure                          */
 
        listnode    listnode;         /* linkage                                  */
 
-       bool        initialized;      /* true, if class already initialised       */ 
+       bool        initialized;      /* true, if class already initialised       */
+       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)                             */ 
+                                        (interfaces)                             */
        s4          instancesize;     /* size of an instance of this class        */
 #ifdef SIZE_FROM_CLASSINFO
        s4          alignedsize;      /* size of an instance, aligned to the 
@@ -668,6 +697,7 @@ struct classinfo {                /* class structure                          */
 
        classSetNode *impldBy;        /* implemented by class set                 */
        utf        *packagename;      /* full name of the package                 */
+       utf        *sourcefile;       /* classfile name containing this class     */
        java_objectheader *classloader;       /* 0 for bootstrap classloader */
 };
 
@@ -773,74 +803,10 @@ struct arraydescriptor {
 };
 
 
-/* references to some system classes ******************************************/
-
-extern classinfo *class_java_lang_Object;
-extern classinfo *class_java_lang_String;
-extern classinfo *class_java_lang_Throwable;
-extern classinfo *class_java_lang_Cloneable;
-extern classinfo *class_java_io_Serializable;
-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;
-
-/* pseudo classes for the type checker ****************************************/
-
-/*
- * pseudo_class_Arraystub
- *     (extends Object implements Cloneable, java.io.Serializable)
- *
- *     If two arrays of incompatible component types are merged,
- *     the resulting reference has no accessible components.
- *     The result does, however, implement the interfaces Cloneable
- *     and java.io.Serializable. This pseudo class is used internally
- *     to represent such results. (They are *not* considered arrays!)
- *
- * pseudo_class_Null
- *
- *     This pseudo class is used internally to represent the
- *     null type.
- *
- * pseudo_class_New
- *
- *     This pseudo class is used internally to represent the
- *     the 'uninitialized object' type.
- */
-
-extern classinfo *pseudo_class_Arraystub;
-extern classinfo *pseudo_class_Null;
-extern classinfo *pseudo_class_New;
-extern vftbl *pseudo_class_Arraystub_vftbl;
-
-extern utf *array_packagename;
-
-
-/* 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;
-
-
 /* 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 bool opt_verify;         /* true if classfiles should be verified      */
+extern bool cacao_initializing;
+
 #ifdef TYPECHECK_VERBOSE_OPT
 extern bool typecheckverbose;
 #endif
@@ -853,21 +819,6 @@ extern bool typecheckverbose;
 /*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;
-
-
 /* table of primitive types ***************************************************/
 
 /* This array can be indexed by the PRIMITIVETYPE_ and ARRAYTYPE_
@@ -919,12 +870,10 @@ extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT];
 /* Synchronization ************************************************************/
 
 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
-extern pthread_mutex_t compiler_mutex;
-extern int cast_counter;
-
 void cast_lock();
-void cast_lock2();
 void cast_unlock();
+void compiler_lock();
+void compiler_unlock();
 #endif
 
 #endif /* _GLOBAL_H */