the cleaner part of the code for stub created exceptions, the rest will follow soon
[cacao.git] / src / vm / global.h
index b9f3b49cfd4888c011fc8ac08fe9ab3b8e348907..8a42b80f8aa8a19b9be4327a6b283d30a9c3dd38 100644 (file)
@@ -31,7 +31,7 @@
             Philipp Tomsich
                        Edwin Steiner
 
-   $Id: global.h 815 2003-12-31 13:22:44Z edwin $
+   $Id: global.h 1082 2004-05-26 15:04:54Z jowenn $
 
 */
 
@@ -39,6 +39,8 @@
 #ifndef _GLOBAL_H
 #define _GLOBAL_H
 
+#define _GNU_SOURCE
+
 #include "config.h"
 #include "types.h"
 #include "toolbox/list.h"
@@ -47,9 +49,6 @@
 #include <pthread.h>
 #endif
 
-
-#define _GNU_SOURCE
-
 #define STATISTICS          /* if enabled collects program statistics         */
 
 /* 
@@ -73,6 +72,7 @@
 /*
  * 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 activates all debug messages
  */
 #ifdef CACAO_TYPECHECK
-#define TYPEINFO_DEBUG
-#define TYPECHECK_DEBUG
+/*#define TYPECHECK_STATISTICS*/
+/*#define TYPEINFO_DEBUG*/
+/*#define TYPECHECK_DEBUG*/
 /*#define TYPEINFO_DEBUG_TEST*/
-#define TYPECHECK_VERBOSE
+/*#define TYPECHECK_VERBOSE*/
 /*#define TYPECHECK_VERBOSE_IMPORTANT*/
 #if defined(TYPECHECK_VERBOSE) || defined(TYPECHECK_VERBOSE_IMPORTANT)
 #define TYPECHECK_VERBOSE_OPT
@@ -194,6 +195,7 @@ typedef struct vftbl vftbl;
 typedef u1* methodptr;
 typedef struct fieldinfo  fieldinfo; 
 typedef struct methodinfo methodinfo; 
+typedef struct lineinfo lineinfo; 
 typedef struct arraydescriptor arraydescriptor;
 
 
@@ -288,6 +290,35 @@ 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 {
@@ -352,6 +383,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
 };
 
 
@@ -478,7 +512,7 @@ struct fieldinfo {        /* field of a class                                 */
 
        imm_union value;      /* storage for static values (class variables)      */
 
-       classinfo *class;     /* XXX needed by typechecker. Could be optimized    */
+       classinfo *class;     /* needed by typechecker. Could be optimized        */
                              /* away by using constant_FMIref instead of         */
                              /* fieldinfo throughout the compiler.               */
        
@@ -490,7 +524,7 @@ struct basicblock;
 
 /* exceptiontable *************************************************************/
 
-typedef struct xtable { /* exceptiontable entry in a method           */ 
+typedef struct xtable {         /* exceptiontable entry in a method           */
        s4         startpc;         /* start pc of guarded area (inclusive)       */
        struct basicblock *start;
 
@@ -507,7 +541,7 @@ typedef struct xtable { /* exceptiontable entry in a method           */
 } xtable;
 
 
-typedef struct exceptiontable { /* exceptiontable entry in a method           */ 
+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                    */
@@ -525,14 +559,20 @@ typedef struct xtainfo {
 
        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 ?          */
 } xtainfo; 
 
 
+/* lineinfo *****************************************************************/
+struct lineinfo {
+       u2 start_pc;
+       u2 line_number;
+};
+
 /* methodinfo *****************************************************************/
 
 struct methodinfo {                 /* method structure                       */
@@ -554,8 +594,13 @@ struct methodinfo {                 /* method structure                       */
        u1        *jcode;               /* pointer to JavaVM code                 */
 
        s4         exceptiontablelength;/* exceptiontable length                  */
-       exceptiontable *exceptiontable; 
-                                    /* the exceptiontable                     */
+       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         linenumbercount;     /*number of linenumber attributes*/
+       lineinfo  *linenumbers;         /*array of lineinfo items (start_pc,line_number)*/
 
        u1        *stubroutine;         /* stub for compiling or calling natives  */    
        s4         mcodelength;         /* legth of generated machine code        */
@@ -592,13 +637,12 @@ 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                               */ 
+       utf        *name;             /* class name                               */
 
        s4          cpcount;          /* number of entries in constant pool       */
        u1         *cptags;           /* constant pool tags                       */
@@ -619,11 +663,11 @@ struct classinfo {                /* class structure                          */
 
        listnode    listnode;         /* linkage                                  */
 
-       bool        initialized;      /* true, if class already initialised       */ 
+       bool        initialized;      /* true, if class already initialised       */
        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 
@@ -643,6 +687,9 @@ struct classinfo {                /* class structure                          */
        s4          classUsed;        /* 0= not used 1 = used   CO-RT             */
 
        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 */
 };
 
 /* check if class is an array class. Only use for linked classes! */
@@ -743,47 +790,15 @@ struct arraydescriptor {
        short  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                  */
-       short  elementtype;      /* ARRAYTYPE_* constant (XXX optimize away?)     */
+       short  elementtype;      /* ARRAYTYPE_* constant                          */
 };
 
 
-/* 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;
-extern classinfo *pseudo_class_Arraystub;
-extern classinfo *pseudo_class_Null;
-extern classinfo *pseudo_class_New;
-extern vftbl *pseudo_class_Arraystub_vftbl;
-
-
-/* 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 verboseexception;         
 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*/
@@ -867,11 +882,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 */