Changes: Christian Thalinger
Edwin Steiner
- $Id: jit.h 5026 2006-06-12 18:50:13Z edwin $
+ $Id: jit.h 5238 2006-08-16 11:18:05Z christian $
*/
#if defined(ENABLE_LOOP)
# include "vm/jit/loop/loop.h"
#endif
+#if defined(ENABLE_SSA)
+# include "vm/jit/optimizing/lsra.h"
+#endif
+#if defined(ENABLE_LSRA)
+# include "vm/jit/allocator/lsra.h"
+#endif
#include "vm/jit/verify/typeinfo.h"
-
/* common jit/codegen macros **************************************************/
#if defined(ENABLE_STATISTICS)
/* jitdata ********************************************************************/
-#define JITDATA_FLAG_IFCONV 0x00000001
-
struct jitdata {
- methodinfo *m; /* methodinfo of the method compiled */
- codeinfo *code;
- codegendata *cd;
- registerdata *rd;
+ methodinfo *m; /* methodinfo of the method compiled */
+ codeinfo *code;
+ codegendata *cd;
+ registerdata *rd;
#if defined(ENABLE_LOOP)
- loopdata *ld;
+ loopdata *ld;
#endif
- u4 flags; /* contains JIT compiler flags */
+#if defined(ENABLE_SSA) || defined(ENABLE_LSRA)
+ lsradata *ls;
+#endif
+ u4 flags; /* contains JIT compiler flags */
+ bool isleafmethod; /* does method call subroutines */
new_instruction *new_instructions;
basicblock *new_basicblocks;
};
-/************************** stack element structure ***************************/
+#define JITDATA_FLAG_PARSE 0x00000001
+#define JITDATA_FLAG_VERIFY 0x00000002
-/* slot types */
+#define JITDATA_FLAG_INSTRUMENT 0x00000004
-/* 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 JITDATA_FLAG_IFCONV 0x00000008
+#define JITDATA_FLAG_REORDER 0x00000010
+
+#define JITDATA_FLAG_SHOWINTERMEDIATE 0x20000000
+#define JITDATA_FLAG_SHOWDISASSEMBLE 0x40000000
+#define JITDATA_FLAG_VERBOSECALL 0x80000000
+
+
+#define JITDATA_HAS_FLAG_PARSE(jd) \
+ ((jd)->flags & JITDATA_FLAG_PARSE)
+
+#define JITDATA_HAS_FLAG_VERIFY(jd) \
+ ((jd)->flags & JITDATA_FLAG_VERIFY)
+
+#define JITDATA_HAS_FLAG_INSTRUMENT(jd) \
+ ((jd)->flags & JITDATA_FLAG_INSTRUMENT)
+
+#define JITDATA_HAS_FLAG_IFCONV(jd) \
+ ((jd)->flags & JITDATA_FLAG_IFCONV)
+
+#define JITDATA_HAS_FLAG_REORDER(jd) \
+ ((jd)->flags & JITDATA_FLAG_REORDER)
-#define IS_INT_LNG_TYPE(a) (!((a) & TYPE_FLT))
-#define IS_FLT_DBL_TYPE(a) ((a) & TYPE_FLT)
-#define IS_2_WORD_TYPE(a) ((a) & TYPE_LNG)
+#define JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd) \
+ ((jd)->flags & JITDATA_FLAG_SHOWINTERMEDIATE)
-#define IS_INT_TYPE(a) ((a) == TYPE_INT)
-#define IS_LNG_TYPE(a) ((a) == TYPE_LNG)
-#define IS_ADR_TYPE(a) ((a) == TYPE_ADR)
+#define JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) \
+ ((jd)->flags & JITDATA_FLAG_SHOWDISASSEMBLE)
+#define JITDATA_HAS_FLAG_VERBOSECALL(jd) \
+ ((jd)->flags & JITDATA_FLAG_VERBOSECALL)
+
+
+/************************** stack element structure ***************************/
/* flags */
#define INSTRUCTION_IS_UNRESOLVED(iptr) \
((ptrint)(iptr)->target & 0x01) /* XXX target used temporarily as flag */
+#define NEW_INSTRUCTION_IS_RESOLVED(iptr) \
+ (!((iptr)->flags.bits & INS_FLAG_UNRESOLVED))
+
+#define NEW_INSTRUCTION_IS_UNRESOLVED(iptr) \
+ ((iptr)->flags.bits & INS_FLAG_UNRESOLVED)
+
+#define NEW_INSTRUCTION_MUST_CHECK(iptr) \
+ (!((iptr)->flags.bits & INS_FLAG_NOCHECK))
+
#define NEW_INSTRUCTION_GET_FIELDREF(iptr,fref) \
do { \
if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
md = ((constant_FMIref *)(iptr)->val.a)->parseddesc.md; \
} while (0)
+#define INSTRUCTION_UNRESOLVED_CLASS(iptr) \
+ ((unresolved_class *) (iptr)->val.a)
+
#define INSTRUCTION_UNRESOLVED_METHOD(iptr) \
((unresolved_method *) (iptr)->val.a)
/* the others by using bitfields. */
struct basicblock {
- s4 debug_nr; /* basic block number */
- s4 flags; /* used during stack analysis, init with -1 */
- s4 bitflags; /* OR of BBFLAG_... constants, init with 0 */
- s4 type; /* basic block type (std, xhandler, subroutine*/
- instruction *iinstr; /* pointer to intermediate code instructions */
- 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 outstack; /* stack at end of basic block */
- s4 indepth; /* stack depth at begin of basic block */
- s4 outdepth; /* stack depth end of basic block */
- s4 pre_count; /* count of predecessor basic blocks */
- branchref *branchrefs; /* list of branches to be patched */
-
- basicblock *next; /* used to build a BB list (instead of array) */
- s4 lflags; /* used during loop copying, init with 0 */
- basicblock *copied_to; /* points to the copy of this basic block */
+ s4 nr; /* basic block number */
+ s4 flags; /* used during stack analysis, init with -1 */
+ s4 bitflags; /* OR of BBFLAG_... constants, init with 0 */
+ s4 type; /* basic block type (std, xhandler, subroutine*/
+ instruction *iinstr; /* pointer to intermediate code instructions */
+ 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 outstack; /* stack at end of basic block */
+ s4 indepth; /* stack depth at begin of basic block */
+ s4 outdepth; /* stack depth end of basic block */
+
+ s4 predecessorcount;
+ s4 successorcount;
+ basicblock **predecessors; /* array of predecessor basic blocks */
+ basicblock **successors; /* array of successor basic blocks */
+
+ branchref *branchrefs; /* list of branches to be patched */
+
+ basicblock *next; /* used to build a BB list (instead of array) */
+ s4 lflags; /* used during loop copying, init with 0 */
+ basicblock *copied_to; /* points to the copy of this basic block */
/* when loop nodes are copied */
- stackptr stack; /* start of stack array for this block */
+ stackptr stack; /* start of stack array for this block */
/* (see doc/stack.txt) */
- methodinfo *method; /* method this block belongs to */
+ methodinfo *method; /* method this block belongs to */
};
-/* macro for initializing newly allocated basicblock:s */
-
-#define BASICBLOCK_INIT(bptr,m) \
- do { \
- bptr->mpc = -1; \
- bptr->flags = -1; \
- bptr->bitflags = 0; \
- bptr->lflags = 0; \
- bptr->type = BBTYPE_STD; \
- bptr->branchrefs = NULL; \
- bptr->pre_count = 0; \
- bptr->method = (m); \
- bptr->debug_nr = (m)->c_debug_nr++; \
- } while (0)
+
+/* Macro for initializing newly allocated basic block's. It does not
+ need to zero fields, as we zero out the whole basic block array. */
+
+#define BASICBLOCK_INIT(bptr,m) \
+ do { \
+ bptr->mpc = -1; \
+ bptr->flags = -1; \
+ bptr->type = BBTYPE_STD; \
+ bptr->method = (m); \
+ bptr->nr = (m)->c_debug_nr++; \
+ } while (0)
/* branchref *****************************************************************/
#define JAVA_FCONST_1 12
#define JAVA_FCONST_2 13
-#define ICMD_ELSE_ICONST 13
#define JAVA_DCONST_0 14
#define ICMD_DCONST 14 /* val.d = constant */
#define JAVA_DCONST_1 15
-#define ICMD_IFEQ_ICONST 15
#define JAVA_BIPUSH 16
-#define ICMD_IFNE_ICONST 16
#define JAVA_SIPUSH 17
-#define ICMD_IFLT_ICONST 17
#define JAVA_LDC1 18
-#define ICMD_IFGE_ICONST 18
#define JAVA_LDC2 19
-#define ICMD_IFGT_ICONST 19
#define JAVA_LDC2W 20
-#define ICMD_IFLE_ICONST 20
/* order of LOAD instructions must be */
/* equal to order of TYPE_* defines */
#define ICMD_BUILTIN 255 /* internal opcode */
-/* define some ICMD masks *****************************************************/
-
-#define ICMD_OPCODE_MASK 0x00ff /* mask to get the opcode */
-#define ICMD_CONDITION_MASK 0xff00 /* mask to get the condition */
-
/******************* description of JavaVM instructions ***********************/
/***************************** register info block ****************************/
extern int stackreq[256];
-
+/* extern int op_needs_saved[256]; */
+/* extern int op_is_pei[256]; */
+#define NEEDS_SAVED 0
+#define PEI 1
+#define OP_DATA_SIZE 2
+extern int op_data[256][OP_DATA_SIZE];
+/* [0..255][NEEDS_SAVED] ... if ICMD needs a SAVEDVAR */
+/* [0..255][PEI] ... if ICMD could throw an exception */
/* function prototypes ********************************************************/
/* compile a method with jit compiler */
u1 *jit_compile(methodinfo *m);
+u1 *jit_recompile(methodinfo *m);
/* patch the method entrypoint */
u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra);
+s4 jit_complement_condition(s4 opcode);
+
/* machine dependent functions */
#if defined(ENABLE_JIT)
void md_init(void);