retrieve line number information
[cacao.git] / src / vm / jit / jit.h
index 9a4dc6756be6a01c0d1117917cd745c12adde1db..d72017db9875fe578c93eb29a078db4f25c1e477 100644 (file)
@@ -29,7 +29,7 @@
 
    Changes: Christian Thalinger
 
-   $Id: jit.h 665 2003-11-21 18:36:43Z jowenn $
+   $Id: jit.h 941 2004-03-06 17:27:56Z jowenn $
 
 */
 
@@ -39,6 +39,8 @@
 
 #include "toolbox/chain.h"
 #include "global.h"
+#include "builtin.h"
+#include "typeinfo.h"
 
 /**************************** resolve typedef-cycles **************************/
 
@@ -59,11 +61,14 @@ typedef varinfo *varinfoptr;
 
 /* slot types */
 
-#define TYPE_INT   0            /* the stack slot types must numbered in the  */
-#define TYPE_LNG   1            /* same order as the ICMD_Ixxx to ICMD_Axxx   */
-#define TYPE_FLT   2            /* instructions (LOAD and STORE)              */
-#define TYPE_DBL   3            /* integer, long, float, double, address      */
-#define TYPE_ADR   4
+/* Unified these with longer names. Maybe someday use only
+ * one set of names? -Edwin
+ */
+/*#define TYPE_INT   0*/               /* the stack slot types must numbered in the  */
+#define TYPE_LNG   TYPE_LONG    /*1*/  /* same order as the ICMD_Ixxx to ICMD_Axxx   */
+#define TYPE_FLT   TYPE_FLOAT   /*2*/  /* instructions (LOAD and STORE)              */
+#define TYPE_DBL   TYPE_DOUBLE  /*3*/  /* integer, long, float, double, address      */
+#define TYPE_ADR   TYPE_ADDRESS /*4*/
 
 #define IS_INT_LNG_TYPE(a)      (!((a)&TYPE_FLT))
 #define IS_FLT_DBL_TYPE(a)      ((a)&TYPE_FLT)
@@ -88,6 +93,9 @@ typedef varinfo *varinfoptr;
 struct stackelement {
        stackptr prev;              /* pointer to next element towards bottom     */
        int type;                   /* slot type of stack element                 */
+#ifdef CACAO_TYPECHECK
+       typeinfo typeinfo;          /* info on reference types                    */
+#endif
        int flags;                  /* flags (SAVED, INMEMORY)                    */
        int varkind;                /* kind of variable or register               */
        int varnum;                 /* number of variable                         */
@@ -101,18 +109,11 @@ struct instruction {
        stackptr dst;               /* stack index of destination operand stack   */
        u2  opc;                    /* opcode of intermediate code command        */
        s4  op1;                    /* first operand, usually variable number     */
-
-       union {
-               s4 i;                   /* integer operand    */
-               s8 l;                   /* long operand       */
-               float f;                /* float operand      */
-               double d;               /* double operand     */
-               void *a;                /* address operand    */
-       } val;                  /* immediate constant */
-
-       void *target;                           /* used for targets of branches and jumps         */
-                                                               /* and as address for list of targets for         */
-                                                               /* statements                                                             */
+       imm_union val;              /* immediate constant                         */
+       void *target;                   /* used for targets of branches and jumps         */
+                                       /* and as address for list of targets for         */
+                                       /* statements                                   */
+       u2 line                         /* line number in source file */
 };
 
 
@@ -124,6 +125,8 @@ struct instruction {
 #define BBUNDEF    -1
 #define BBREACHED  0
 #define BBFINISHED 1
+#define BBTYPECHECK_UNDEF    2
+#define BBTYPECHECK_REACHED  3
 
 #define BBTYPE_STD 0            /* standard basic block type                  */
 #define BBTYPE_EXH 1            /* exception handler basic block type         */
@@ -165,6 +168,7 @@ typedef varinfo varinfo5[5];
 
 struct branchref {
        s4 branchpos;               /* patching position in code segment          */
+       s4 reg;                     /* used for ArrayIndexOutOfBounds index reg   */
        branchref *next;            /* next element in branchref list             */
 };
 
@@ -184,6 +188,11 @@ struct dataref {
 };
 
 
+/********** op1 values for ACONST instructions ********************************/
+
+#define ACONST_LOAD     0  /* ACONST_NULL or LDC instruction                  */
+#define ACONST_BUILTIN  1  /* constant argument for a builtin function call   */
+
 /********** JavaVM operation codes (sorted) and instruction lengths ***********/
 
 extern char *icmd_names[256];
@@ -800,21 +809,7 @@ extern int jcommandsize[256];
 
 #if defined(USEBUILTINTABLE)
 
-typedef struct {
-       u1 opcode;
-       u1 type_s1;
-       u1 type_s2;
-       u1 type_d;      
-       int icmd;
-       functionptr builtin;
-       bool supported;
-       bool isfloat;
-} stdopdescriptor;
-
-
-extern stdopdescriptor builtintable[];
-
-stdopdescriptor *find_builtin(int icmd);
+builtin_descriptor *find_builtin(int opcode);
 
 #endif /* USEBUILTINTABLE */
 
@@ -844,33 +839,6 @@ extern int nreg_parammode;
 
 /* compiler switches (set by main function) ***********************************/
 
-extern bool runverbose;         /* trace all method invocation                */
-extern bool compileverbose;     /* trace compiler actions                     */
-extern bool showdisassemble;    /* generate disassembler listing              */
-extern bool showddatasegment;   /* generate data segment listing              */
-extern bool showintermediate;   /* generate intermediate code listing         */
-extern int  optimizelevel;      /* optimzation level  (0 = no optimization)   */
-
-extern bool useinlining;        /* use method inlining                        */
-extern bool inlinevirtuals;     /* inline unique virtual methods              */
-extern bool inlineexceptions;   /* inline methods, that contain excptions     */
-extern bool inlineparamopt;     /* optimize parameter passing to inlined methods */
-extern bool inlineoutsiders;    /* inline methods, that are not member of the invoker's class */
-
-
-extern bool checkbounds;        /* check array bounds                         */
-extern bool opt_loops;          /* optimize array accesses in loops           */
-extern bool checknull;          /* check null pointers                        */
-extern bool opt_noieee;         /* don't implement ieee compliant floats      */
-extern bool checksync;          /* do synchronization                         */
-
-extern bool getcompilingtime;   /* compute compile time                       */
-extern long compilingtime;      /* accumulated compile time                   */
-
-extern int  has_ext_instr_set;  /* has instruction set extensions */
-
-extern bool statistics;         
-
 extern int count_jit_calls;
 extern int count_methods;
 extern int count_spills;
@@ -928,6 +896,8 @@ extern int maxstack;            /* maximal JavaVM stack size                  */
 extern int maxlocals;           /* maximal number of local JavaVM variables   */
 extern int jcodelength;         /* length of JavaVM-codes                     */
 extern u1 *jcode;               /* pointer to start of JavaVM-code            */
+lineinfo *jlinenumbers;         /* line information array                     */
+u2 jlinenumbercount;            /* number of entries in the linenumber array  */
 extern int exceptiontablelength;/* length of exception table                  */
 extern xtable *extable;         /* pointer to start of exception table        */
 extern exceptiontable *raw_extable;
@@ -948,6 +918,9 @@ extern bool isleafmethod;       /* true if a method doesn't call subroutines  */
 
 extern basicblock *last_block;  /* points to the end of the BB list           */
 
+extern bool regs_ok;            /* true if registers have been allocated      */
+
+
 /* list of all classes used by the compiled method which have to be           */
 /* initialised (if not already done) before execution of this method          */
 extern chain *uninitializedclasses;
@@ -955,6 +928,12 @@ extern chain *uninitializedclasses;
 extern int stackreq[256];
 
 
+#if defined(__I386__)
+extern bool method_uses_ecx;
+extern bool method_uses_edx;
+#endif
+
+
 /* function prototypes */
 
 methodptr jit_compile (methodinfo *m);  /* compile a method with jit compiler */
@@ -968,6 +947,16 @@ u1 *createnativestub(functionptr f, methodinfo *m);
 void removecompilerstub(u1 *stub);
 void removenativestub(u1 *stub);
 
+void typecheck();
+
+/* debug helpers (in stack.c) */
+
+void icmd_print_stack(stackptr s);
+char *icmd_builtin_name(functionptr bptr);
+void show_icmd_block(basicblock *bptr);
+void show_icmd(instruction *iptr,bool deadcode);
+void show_icmd_method();
+
 #endif /* _JIT_H */