Philipp Tomsich
Edwin Steiner
- $Id: global.h 669 2003-11-23 14:04:20Z edwin $
+ $Id: global.h 888 2004-01-19 12:16:11Z edwin $
*/
#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 SIZE_FROM_CLASSINFO
-/* standard includes **********************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-#include "toolbox/memory.h"
-#include "toolbox/chain.h"
-#include "toolbox/list.h"
-#include "toolbox/loging.h"
+/*
+ * CACAO_TYPECHECK activates typechecking (part of bytecode verification)
+ */
+#define CACAO_TYPECHECK
-/* system dependent 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 */
-#include "types.h"
+/*
+ * 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
/* additional data types ******************************************************/
#define true 1
#define false 0
+
+/* immediate data union */
+
+typedef union {
+ s4 i;
+ s8 l;
+ float f;
+ double d;
+ void *a;
+ u1 b[8];
+} imm_union;
+
+
#define PRIMITIVETYPE_COUNT 9 /* number of primitive types */
/* CAUTION: Don't change the numerical values! These constants are
/* 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) */
#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
/* 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 */
java_objectheader *data[1];
} java_objectarray;
+
/* 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 *arrayname; /* name of primitive array 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 *arrayvftbl; /* vftbl of primitive array class */
+ vftbl *arrayvftbl; /* vftbl of primitive array class */
} primitivetypeinfo;
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 */
/* 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*/
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;
+
/* methodinfo *****************************************************************/
struct methodinfo { /* method structure */
};
-
/* innerclassinfo *************************************************************/
typedef struct innerclassinfo {
s4 flags; /* ACC flags */
} innerclassinfo;
+
/* classinfo ******************************************************************/
struct classinfo { /* class structure */
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 */
listnode listnode; /* linkage */
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
+ 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 */
+ allocation size on the heap */
#endif
vftbl *vftbl; /* pointer to virtual function table */
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 */
};
/* 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 ******************************************************
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 */
};
+
/* references to some system classes ******************************************/
extern classinfo *class_java_lang_Object;
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 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 ********************************************************/
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_
/* macros for descriptor parsing **********************************************/
-/* utf_ptr must point to the 'L' or the '[' of a field descriptor.
+/* 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.
+ * descriptor. Better use SKIP_FIELDDESCRIPTOR_SAFE.
*/
-#define SKIP_FIELDDESCRIPTOR(utf_ptr) \
- { while (*(utf_ptr)=='[') (utf_ptr)++; \
- if (*(utf_ptr)++=='L') \
- while(*(utf_ptr)++ != ';') /* skip */; }
-/* Input:
+#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!
* 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) \
- { 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; }}
-
+#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)
+extern pthread_mutex_t compiler_mutex;
+extern int cast_counter;
+
+void cast_lock();
+void cast_lock2();
+void cast_unlock();
+#endif
-extern classinfo *class_array;
+#endif /* _GLOBAL_H */
-#endif
/*
* These are local overrides for various environment variables in Emacs.