* src/vm/jit/jit.c (jit_compile_intern): Perform inlining if
[cacao.git] / src / vm / jit / jit.h
index 392ed78c5a4a232beecb817de86e428c0d472315..de45e2d222e0dfd9bc6412fc91291e66660c45c5 100644 (file)
 
    Authors: Andreas Krall
             Reinhard Grafl
+            Christian Thalinger
+            Edwin Steiner
 
-   Changes: Christian Thalinger
-                       Edwin Steiner
-
-   $Id: jit.h 5921 2006-11-05 21:27:37Z edwin $
+   $Id: jit.h 6211 2006-12-16 22:53:24Z edwin $
 
 */
 
@@ -62,6 +61,7 @@ typedef struct exception_entry exception_entry;
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/stacktrace.h"
+#include "vm/jit/replace.h"
 
 #if defined(ENABLE_INLINING)
 # include "vm/jit/inline/inline.h"
@@ -133,6 +133,7 @@ struct jitdata {
                                                /* locals and keep the coalescing info for simplereg. */
                            /* local_map[local_index * 5 + local_type] =          */
                            /* new_index in rd->var or UNUSED                     */
+       s4               maxlocals;       /* max. number of javalocals            */
 
        interface_info  *interface_map;   /* interface variables (for simplereg)  */
        s4               maxinterfaces;   /* max. number of interface variables   */
@@ -157,6 +158,9 @@ struct jitdata {
 
 #define JITDATA_FLAG_IFCONV              0x00000008
 #define JITDATA_FLAG_REORDER             0x00000010
+#define JITDATA_FLAG_INLINE              0x00000020
+
+#define JITDATA_FLAG_COUNTDOWN           0x00000100
 
 #define JITDATA_FLAG_SHOWINTERMEDIATE    0x20000000
 #define JITDATA_FLAG_SHOWDISASSEMBLE     0x40000000
@@ -178,6 +182,12 @@ struct jitdata {
 #define JITDATA_HAS_FLAG_REORDER(jd) \
     ((jd)->flags & JITDATA_FLAG_REORDER)
 
+#define JITDATA_HAS_FLAG_INLINE(jd) \
+    ((jd)->flags & JITDATA_FLAG_INLINE)
+
+#define JITDATA_HAS_FLAG_COUNTDOWN(jd) \
+    ((jd)->flags & JITDATA_FLAG_COUNTDOWN)
+
 #define JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd) \
     ((jd)->flags & JITDATA_FLAG_SHOWINTERMEDIATE)
 
@@ -281,6 +291,7 @@ typedef union {
     ptrint                     constval;         /* for PUT*CONST             */
     s4                         tablelow;         /* for TABLESWITCH           */
     u4                         lookupcount;      /* for LOOKUPSWITCH          */
+       s4                         retaddrnr;        /* for ASTORE                */
 } s2_operand_t;
 
 /*** s3 operand ***/
@@ -325,7 +336,7 @@ typedef union {
 /*** flags (32 bits) ***/
 
 #define INS_FLAG_UNRESOLVED    0x01    /* contains unresolved field/meth/class*/
-#define INS_FLAG_CLASS         0x02    /* for ACONST with class               */
+#define INS_FLAG_CLASS         0x02    /* for ACONST, PUT*CONST with class    */
 #define INS_FLAG_ARRAY         0x04    /* for CHECKCAST/INSTANCEOF with array */
 #define INS_FLAG_CHECK         0x08    /* for *ALOAD|*ASTORE: check index     */
                                        /* for BUILTIN: check exception        */
@@ -333,6 +344,9 @@ typedef union {
 #define INS_FLAG_KILL_NEXT     0x04    /* for *STORE, invalidate next local   */
 #define INS_FLAG_RETADDR       0x08    /* for ASTORE: op is a returnAddress   */
 
+#define INS_FLAG_ID_SHIFT      4
+#define INS_FLAG_ID_MASK       (~0 << INS_FLAG_ID_SHIFT)
+
 typedef union {
     u4                  bits;
 } flags_operand_t;
@@ -401,15 +415,31 @@ struct instruction {
 /* for ICMD_INLINE_START and ICMD_INLINE_END */
 
 struct insinfo_inline {
-       methodinfo *method;         /* the inlined method starting/ending here    */
-       methodinfo *outer;          /* the outer method suspended/resumed here    */
-       s4          startmpc;       /* machine code offset of start of inlining   */          
-       s4          synclocal;      /* local index used for synchronization       */
-       bool        synchronize;    /* true if synchronization is needed          */
+       /* fields copied from the inlining tree ----------------------------------*/
+       insinfo_inline *parent;     /* insinfo of the surrounding inlining, if any*/
+       methodinfo     *method;     /* the inlined method starting/ending here    */
+       methodinfo     *outer;      /* the outer method suspended/resumed here    */
+       s4              synclocal;      /* local index used for synchronization   */
+       bool            synchronize;    /* true if synchronization is needed      */
+       s4              throughcount;   /* total # of pass-through variables      */
+       s4              paramcount;     /* number of parameters of original call  */
+       s4              stackvarscount; /* source stackdepth at INLINE_START      */
+       s4             *stackvars;      /* stack vars at INLINE_START             */
+
+       /* fields set by inlining ------------------------------------------------*/
+       s4         *javalocals_start; /* javalocals at start of inlined body      */
+       s4         *javalocals_end;   /* javalocals after inlined body            */
+
+       /* fields set by replacement point creation ------------------------------*/
+       rplpoint   *rp;             /* replacement point at INLINE_START          */
+
+       /* fields set by the codegen ---------------------------------------------*/
+       s4          startmpc;       /* machine code offset of start of inlining   */
 };
 
+
 /* basicblock *****************************************************************/
+
 /* flags */
 
 #define BBDELETED            -2
@@ -465,6 +495,7 @@ struct basicblock {
        basicblock   *original;     /* block of which this block is a clone       */
                                    /* NULL for the original block itself         */
        methodinfo   *method;       /* method this block belongs to               */
+       insinfo_inline *inlineinfo; /* inlineinfo for the start of this block     */
 
        s4            mpc;          /* machine code pc at start of block          */
 };
@@ -586,7 +617,6 @@ extern int stackreq[256];
 #define ICMD_ICONST            3        /* val.i = constant                   */
 
 #define JAVA_ICONST_1          4
-#define ICMD_CHECKNULL_POP     4
 
 #define JAVA_ICONST_2          5
 #define ICMD_IDIVPOW2          5        /* val.i = constant                   */
@@ -1210,7 +1240,7 @@ extern int stackreq[256];
 
 #define ICMD_INLINE_START     251       /* instruction before inlined method  */
 #define ICMD_INLINE_END       252       /* instruction after inlined method   */
-#define ICMD_INLINE_GOTO      253       /* jump to caller of inlined method   */
+#define ICMD_INLINE_BODY      253       /* start of inlined body              */
 
 #define ICMD_BUILTIN          255       /* internal opcode                    */
 
@@ -1245,6 +1275,10 @@ jitdata *jit_jitdata_new(methodinfo *m);
 u1 *jit_compile(methodinfo *m);
 u1 *jit_recompile(methodinfo *m);
 
+void jit_invalidate_code(methodinfo *m);
+codeinfo *jit_get_current_code(methodinfo *m);
+void jit_request_optimization(methodinfo *m);
+
 /* patch the method entrypoint */
 u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra);