retrieve line number information
[cacao.git] / src / vm / global.h
index ad56924e69a0f7fbd87b9ed9ef13eef6fc49c163..d9cf9dd712e9bb8e9ffd5bca20a2e5574ce45a31 100644 (file)
@@ -31,7 +31,7 @@
             Philipp Tomsich
                        Edwin Steiner
 
-   $Id: global.h 727 2003-12-11 10:52:40Z edwin $
+   $Id: global.h 941 2004-03-06 17:27:56Z jowenn $
 
 */
 
 #ifndef _GLOBAL_H
 #define _GLOBAL_H
 
+#define _GNU_SOURCE
+
 #include "config.h"
 #include "types.h"
 #include "toolbox/list.h"
 
-
-#define _GNU_SOURCE
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#include <pthread.h>
+#endif
 
 #define STATISTICS          /* if enabled collects program statistics         */
 
  */
 #define CACAO_TYPECHECK
 
+/*
+ * 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 */
+
 /*
  * 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
@@ -164,6 +176,7 @@ 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
@@ -182,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;
 
 
@@ -276,6 +290,17 @@ struct literalstring {
 };
 
 
+/* data structure for storing information needed for a stacktrace across native functions*/
+struct native_stackframeinfo {
+       void *returnFromNative;
+       void *addrReturnFromNative;
+       methodinfo *method;
+       struct native_stackframeinfo *next;
+       struct native_stackframeinfo *prev;
+};
+
+typedef struct native_stackframeinfo native_stackframeinfo;
+
 /* data structure for calls from c code to java methods */
 
 struct jni_callblock {
@@ -466,7 +491,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.               */
        
@@ -513,14 +538,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                       */
@@ -542,8 +573,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        */
@@ -586,7 +622,7 @@ struct classinfo {                /* class structure                          */
        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                       */
@@ -631,10 +667,12 @@ 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                 */
+       java_objectheader *classloader;       /* 0 for bootstrap classloader */
 };
 
 /* check if class is an array class. Only use for linked classes! */
-#define CLASS_IS_ARRAY(clsinfo)  (clsinfo->vftbl->arraydesc != NULL)
+#define CLASS_IS_ARRAY(clsinfo)  ((clsinfo)->vftbl->arraydesc != NULL)
 
 
 /* virtual function table ******************************************************
@@ -731,7 +769,7 @@ 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                          */
 };
 
 
@@ -750,11 +788,37 @@ 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 *******************************************/
 
@@ -776,16 +840,17 @@ 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      */
 #ifdef TYPECHECK_VERBOSE_OPT
 extern bool typecheckverbose;
 #endif
 
-//extern int pClassHeir;
-//extern int pCallgraph;
-//extern int pOpcodes;
-//extern int pStats;
+/*extern int pClassHeir;*/
+/*extern int pCallgraph;*/
+/*extern int pOpcodes;*/
+/*extern int pStats;*/
 
-//extern void RT_jit_parse(methodinfo *m);
+/*extern void RT_jit_parse(methodinfo *m);*/
 
 
 /* statistic variables ********************************************************/
@@ -850,6 +915,18 @@ extern primitivetypeinfo primitivetype_table[PRIMITIVETYPE_COUNT];
                                if ((utf_ptr)[-1] != ';')                                                               \
                                        (errorflag) = true; }} while(0)
 
+
+/* 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();
+#endif
+
 #endif /* _GLOBAL_H */