Unified variables changes for common/i386.
[cacao.git] / src / vm / jit / jit.h
index 55c3346d34fc9d5a48cbd66e77dc7cf25341a44e..9418bbca53f94cfc4daf78d95845fd3ef6a27ee1 100644 (file)
@@ -30,7 +30,7 @@
    Changes: Christian Thalinger
                        Edwin Steiner
 
-   $Id: jit.h 5332 2006-09-05 19:38:28Z twisti $
+   $Id: jit.h 5404 2006-09-07 13:29:05Z christian $
 
 */
 
@@ -38,6 +38,8 @@
 #ifndef _JIT_H
 #define _JIT_H
 
+#define NEW_VAR
+
 /* forward typedefs ***********************************************************/
 
 typedef struct jitdata jitdata;
@@ -114,8 +116,22 @@ struct jitdata {
        s4               new_basicblockcount;
        s4               new_stackcount;
        s4               new_c_debug_nr;
+
+#if defined(NEW_VAR)
+       varinfo *var;
+       s4      vartop;
+    
+       s4      varcount;
+       s4      localcount;
+    s4      *local_map; /* internal structure to rename(de-coallesc) locals  */
+                           /* and keep the coalescing info for simplereg.       */
+                           /* local_map[local_index * 5 + local_type] =         */
+                           /* new_index in rd->var or LOCAL_UNUSED              */
+       s4      *interface_map; /* like local_map for interfaces */
+#endif
 };
 
+#define UNUSED                     -1
 
 #define JITDATA_FLAG_PARSE               0x00000001
 #define JITDATA_FLAG_VERIFY              0x00000002
@@ -155,7 +171,7 @@ struct jitdata {
     ((jd)->flags & JITDATA_FLAG_VERBOSECALL)
 
 
-/************************** stack element structure ***************************/
+/* stack element structure ****************************************************/
 
 /* flags */
 
@@ -167,6 +183,13 @@ struct jitdata {
                                 /* using the same register/memory location    */
 #define STKEEP    32            /* to prevent reg_mark_copy to free this      */
                                 /* stackslot */
+#define PREALLOC  64            /* preallocated var like for ARGVARS. Used    */
+                                /* with the new var system */
+#define OUTVAR   128            /* STACKVR flag for new var system */
+
+#define IS_SAVEDVAR(x)    ((x) & SAVEDVAR)
+#define IS_INMEMORY(x)    ((x) & INMEMORY)
+
 
 /* variable kinds */
 
@@ -209,16 +232,25 @@ typedef struct {
 /*** s1 operand ***/
 
 typedef union {
+#if defined(NEW_VAR)
+       s4                         varindex;
+#else
     stackptr                   var;
     s4                         localindex;
+#endif
     s4                         argcount;
 } s1_operand_t;
 
 /*** s2 operand ***/
 
 typedef union {
+#if defined(NEW_VAR)
+       s4                         varindex;
+       s4                         *args;
+#else
     stackptr                   var;
     stackptr                  *args;
+#endif
     classref_or_classinfo      c;
     unresolved_class          *uc;
     ptrint                     constval;         /* for PUT*CONST             */
@@ -229,7 +261,11 @@ typedef union {
 /*** s3 operand ***/
 
 typedef union {
+#if defined(NEW_VAR)
+       s4                         varindex;
+#else
     stackptr                   var;
+#endif
     ptrint                     constval;
     classref_or_classinfo      c;
     constant_FMIref           *fmiref;
@@ -257,13 +293,21 @@ typedef union {
 /*** dst operand ***/
 
 typedef union {
+#if defined(NEW_VAR)
+       s4                         varindex;
+#else
     stackptr                   var;
     s4                         localindex;
+#endif
     basicblock                *block;       /* valid after stack analysis     */
     branch_target_t           *table;       /* for TABLESWITCH                */
     lookup_target_t           *lookup;      /* for LOOKUPSWITCH               */
     s4                         insindex;    /* used between parse and stack   */
+#if defined(NEW_VAR)
+       s4                        *dupslots;    /* for SWAP, DUP* except DUP      */
+#else
        stackptr                  *dupslots;    /* for SWAP, DUP* except DUP      */
+#endif
 } dst_operand_t;
 
 /*** flags (32 bits) ***/
@@ -271,7 +315,8 @@ typedef union {
 #define INS_FLAG_UNRESOLVED    0x01    /* contains unresolved field/meth/class*/
 #define INS_FLAG_CLASS         0x02    /* for ACONST with class               */
 #define INS_FLAG_ARRAY         0x04    /* for CHECKCAST/INSTANCEOF with array */
-#define INS_FLAG_NOCHECK       0x08
+#define INS_FLAG_CHECK         0x08    /* for *ALOAD|*ASTORE: check index     */
+                                       /* for BUILTIN: check exception        */
 
 typedef union {
     u4                  bits;
@@ -332,7 +377,7 @@ struct instruction {
        ((iptr)->flags.bits & INS_FLAG_UNRESOLVED)
 
 #define INSTRUCTION_MUST_CHECK(iptr) \
-       (!((iptr)->flags.bits & INS_FLAG_NOCHECK))
+       ((iptr)->flags.bits & INS_FLAG_CHECK)
 
 #define INSTRUCTION_GET_FIELDREF(iptr,fref) \
        do { \
@@ -403,9 +448,14 @@ struct basicblock {
        s4            icount;       /* number of intermediate code instructions   */
        s4            mpc;          /* machine code pc at start of block          */
        stackptr      instack;      /* stack at begin of basic block              */
-       stackptr     *invars;       /* array of in-variables at begin of block    */
        stackptr      outstack;     /* stack at end of basic block                */
+#if defined(NEW_VAR)
+       s4           *invars;       /* array of in-variables at begin of block    */
+       s4           *outvars;      /* array of out-variables at end of block     */
+#else
+       stackptr     *invars;       /* array of in-variables at begin of block    */
        stackptr     *outvars;      /* array of out-variables at end of block     */
+#endif
        s4            indepth;      /* stack depth at begin of basic block        */
        s4            outdepth;     /* stack depth end of basic block             */