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 $
*/
#include "toolbox/chain.h"
#include "global.h"
+#include "builtin.h"
+#include "typeinfo.h"
/**************************** resolve typedef-cycles **************************/
/* 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)
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 */
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 */
};
#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 */
struct branchref {
s4 branchpos; /* patching position in code segment */
+ s4 reg; /* used for ArrayIndexOutOfBounds index reg */
branchref *next; /* next element in branchref list */
};
};
+/********** 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];
#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 */
/* 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;
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;
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;
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 */
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 */