X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fglobal.h;h=eb2f080f021a7a2e40a58ebedd46e9c9dc26c1d6;hb=d75b6037acf17c342166b9c9bd6e657dfdd12cd9;hp=9edecdf37f596027c5f00ef2ced5e2d9c38969a6;hpb=636624c18e5b37f90a2f43bfbf450bb78d057733;p=cacao.git diff --git a/src/vm/global.h b/src/vm/global.h index 9edecdf37..eb2f080f0 100644 --- a/src/vm/global.h +++ b/src/vm/global.h @@ -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. @@ -30,8 +30,9 @@ Changes: Mark Probst Philipp Tomsich Edwin Steiner + Joseph Wenninger - $Id: global.h 1187 2004-06-19 12:26:33Z twisti $ + $Id: global.h 1735 2004-12-07 14:33:27Z twisti $ */ @@ -39,16 +40,53 @@ #ifndef _GLOBAL_H #define _GLOBAL_H - #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" #if defined(USE_THREADS) && defined(NATIVE_THREADS) #include +#include #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 */ /* @@ -67,7 +105,7 @@ * categories for stack manipulations (POP,POP2,SWAP,DUP,DUP2,DUP_X1, * DUP2_X1,DUP_X2,DUP2_X2). */ -/* #define TYPECHECK_STACK_COMPCAT */ +#define TYPECHECK_STACK_COMPCAT /* * Macros for configuration of the typechecking code @@ -80,37 +118,28 @@ * 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*/ +/*#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 ******************************************************/ - -typedef void *voidptr; /* generic pointer */ - -typedef int bool; /* boolean data type */ - -#define true 1 -#define false 0 - - /* immediate data union */ typedef union { - s4 i; - s8 l; - float f; - double d; - void *a; - u1 b[8]; + s4 i; + s8 l; + float f; + double d; + void *a; + functionptr fp; + u1 b[8]; } imm_union; @@ -129,8 +158,6 @@ typedef union { #define PRIMITIVETYPE_BOOLEAN 7 #define PRIMITIVETYPE_VOID 8 -typedef void (*functionptr) (); /* generic function pointer */ - #define MAX_ALIGN 8 /* most generic alignment for JavaVM values */ @@ -179,20 +206,7 @@ typedef void (*functionptr) (); /* generic function pointer */ #define ACC_NATIVE 0x0100 #define ACC_INTERFACE 0x0200 #define ACC_ABSTRACT 0x0400 -#define ACC_STRICT 0x0800 - -/* 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; -typedef struct lineinfo lineinfo; -typedef struct arraydescriptor arraydescriptor; +#define ACC_STRICT 0x0800 /* constant pool entries ******************************************************* @@ -287,10 +301,17 @@ 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 @@ -302,7 +323,8 @@ struct native_stackframeinfo { #endif }; -typedef struct native_stackframeinfo native_stackframeinfo; + +typedef struct stacktraceelement stacktraceelement; struct stacktraceelement { #if POINTERSIZE == 8 @@ -313,7 +335,17 @@ struct stacktraceelement { methodinfo *method; }; -typedef struct stacktraceelement stacktraceelement; + +typedef struct stackTraceBuffer stackTraceBuffer; + +struct stackTraceBuffer { + s4 needsFree; + stacktraceelement *start; + s4 size; + s4 full; +}; + + /* data structure for calls from c code to java methods */ @@ -378,9 +410,9 @@ typedef struct { /* NameAndType (Field or Method) */ */ 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) - long monitorBits; + void *monitorPtr; #endif }; @@ -482,13 +514,12 @@ typedef struct primitivetypeinfo { 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_t *arrayvftbl; /* vftbl of primitive array class */ } primitivetypeinfo; /* field, method and class structures *****************************************/ -#include "jit/sets.h" typedef struct xtafldinfo { bool fieldChecked; classinfo *fldClassType; @@ -515,37 +546,28 @@ struct fieldinfo { /* field of a class */ 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 */ @@ -555,7 +577,7 @@ typedef struct xtainfo { methSet *calls; /* methods this method calls */ methSet *calledBy; /* methods that call this method */ - methSet *marked; //not in Dez /* methods that marked by this method */ + 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 */ @@ -564,54 +586,75 @@ typedef struct 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 */ + + 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 declared to be thrown by a method*/ - classinfo **thrownexceptions; /*array of classinfos of declared exceptions*/ + 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 (start_pc,line_number)*/ + u2 linenumbercount; /* number of linenumber attributes */ + lineinfo *linenumbers; /* array of lineinfo items */ - 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 */ + 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 nativelyoverloaded; /*used in header.c and only valid there*/ + s4 subRedefs; + s4 subRedefsUsed; + s4 nativelyoverloaded; /* used in header.c and only valid there */ }; @@ -620,8 +663,8 @@ struct methodinfo { /* method structure */ 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; @@ -660,34 +703,34 @@ 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 */ 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 */ + 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! */ @@ -750,7 +793,7 @@ struct classinfo { /* class structure */ *******************************************************************************/ -struct vftbl { +struct _vftbl { methodptr *interfacetable[1]; /* interface table (access via macro) */ classinfo *class; /* class, the vtbl belongs to */ @@ -782,27 +825,20 @@ struct vftbl { *******************************************************************************/ struct arraydescriptor { - vftbl *componentvftbl; /* vftbl of the component type, NULL for primit. */ - vftbl *elementvftbl; /* vftbl of the element type, NULL for primitive */ - short arraytype; /* ARRAYTYPE_* constant */ - 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 */ + 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 cacao_initializing; -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*/ -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 @@ -815,21 +851,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_