-/* jit/jit.h - code generation header
+/* src/vm/jit/jit.h - code generation header
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
- R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
- M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
- P. Tomsich, J. Wenninger
+ Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
+ R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
+ C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
+ Institut f. Computersprachen - TU Wien
This file is part of CACAO.
Changes: Christian Thalinger
- $Id: jit.h 1274 2004-07-05 17:24:40Z twisti $
+ $Id: jit.h 2181 2005-04-01 16:53:33Z edwin $
*/
#ifndef _JIT_H
#define _JIT_H
-#include "toolbox/chain.h"
-#include "global.h"
-#include "builtin.h"
-#include "typeinfo.h"
-
-/**************************** resolve typedef-cycles **************************/
+/* resolve typedef cycles *****************************************************/
typedef struct stackelement stackelement;
typedef stackelement *stackptr;
typedef struct basicblock basicblock;
typedef struct instruction instruction;
typedef struct subroutineinfo subroutineinfo;
-typedef struct varinfo varinfo;
-typedef struct branchref branchref;
-typedef struct jumpref jumpref;
-typedef struct dataref dataref;
-typedef varinfo *varinfoptr;
-typedef struct linenumberref linenumberref;
+#include "toolbox/chain.h"
+#include "vm/global.h"
+#include "vm/references.h"
+#include "vm/method.h"
+#include "vm/jit/codegen.inc.h"
+#include "vm/jit/verify/typeinfo.h"
+
+
+/**************************** resolve typedef-cycles **************************/
+
/************************** stack element structure ***************************/
/* slot types */
#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)
-#define IS_2_WORD_TYPE(a) ((a)&TYPE_LNG)
+#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 IS_ADR_TYPE(a) ((a) & TYPE_ADR)
/* flags */
struct stackelement {
stackptr prev; /* pointer to next element towards bottom */
- int type; /* slot type of stack element */
+ s4 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 */
- int regoff; /* register number or memory offset */
+ s4 flags; /* flags (SAVED, INMEMORY) */
+ s4 varkind; /* kind of variable or register */
+ s4 varnum; /* number of variable */
+ s4 regoff; /* register number or memory offset */
};
u2 line; /* line number in source file */
methodinfo *method; /* needed for inlining. can't be done on */
/* basic block level, since an inlined */
- /* function doesn't start necessarily start */
+ /* function doesn't necessarily start */
/* a new block */
};
+#define INSTRUCTION_PUTCONST_TYPE(iptr) \
+ ((iptr)[0].op1)
+
+#define INSTRUCTION_PUTCONST_VALUE_ADR(iptr) \
+ ((iptr)[0].val.a)
+
+#define INSTRUCTION_PUTCONST_FIELDINFO(iptr) \
+ ((fieldinfo *)((iptr)[1].val.a))
+
+#define INSTRUCTION_PUTCONST_FIELDREF(iptr) \
+ ((constant_FMIref *)((iptr)[1].val.a))
+
/**************************** basic block structure ***************************/
/* flags */
-#define BBDELETED -2
-#define BBUNDEF -1
-#define BBREACHED 0
-#define BBFINISHED 1
+#define BBDELETED -2
+#define BBUNDEF -1
+#define BBREACHED 0
+#define BBFINISHED 1
#define BBTYPECHECK_UNDEF 2
#define BBTYPECHECK_REACHED 3
#define BBTYPE_EXH 1 /* exception handler basic block type */
#define BBTYPE_SBR 2 /* subroutine basic block type */
-struct basicblock {
+
+struct basicblock {
int flags; /* used during stack analysis, init with -1 */
int type; /* basic block type (std, xhandler, subroutine*/
instruction *iinstr; /* pointer to intermediate code instructions */
int indepth; /* stack depth at begin of basic block */
int outdepth; /* stack depth end of basic block */
int pre_count; /* count of predecessor basic blocks */
- branchref *branchrefs; /* list of branches to be patched */
+ struct branchref *branchrefs; /* list of branches to be patched */
basicblock *next; /* used to build a BB list (instead of array) */
int lflags; /* used during loop copying, init with 0 */
};
-/************************* pseudo variable structure **************************/
-
-struct varinfo {
- int type; /* basic type of variable */
- int flags; /* flags (SAVED, INMEMORY) */
- int regoff; /* register number or memory offset */
-};
-
-
-/***************** forward references in branch instructions ******************/
-
-struct branchref {
- s4 branchpos; /* patching position in code segment */
- s4 reg; /* used for ArrayIndexOutOfBounds index reg */
- branchref *next; /* next element in branchref list */
-};
-
-
-/******************** forward references in tables ***************************/
-
-struct jumpref {
- s4 tablepos; /* patching position in data segment */
- basicblock *target; /* target basic block */
- jumpref *next; /* next element in jumpref list */
-};
-
-struct linenumberref {
- s4 tablepos; /* patching position in data segment */
- int targetmpc; /* machine code program counter of first instruction for given line*/
- u2 linenumber; /* line number, used for inserting into the table and for validty checking*/
- linenumberref *next; /* next element in linenumberref list */
-};
-
-
-struct dataref {
- u1 *pos; /* patching position in generated code */
- dataref *next; /* next element in dataref list */
-};
-
-
/********** op1 values for ACONST instructions ********************************/
#define ACONST_LOAD 0 /* ACONST_NULL or LDC instruction */
#define ICMD_SASTORECONST 211
+#define ICMD_PUTSTATICCONST 212
+
+#define ICMD_PUTFIELDCONST 213
+
+#define ICMD_IMULPOW2 214
+
+#define ICMD_LMULPOW2 215
+
+#define ICMD_INLINE_START 251 /* before the first instruction of an inlined method */
+#define ICMD_INLINE_END 252 /* after the last instruction of an inlined method */
#define ICMD_BUILTIN3 253 /* internal opcode */
#define ICMD_BUILTIN2 254 /* internal opcode */
#define ICMD_BUILTIN1 255 /* internal opcode */
/******************* description of JavaVM instructions ***********************/
-#if defined(USEBUILTINTABLE)
-
-builtin_descriptor *find_builtin(int opcode);
-
-#endif /* USEBUILTINTABLE */
/***************************** register types *********************************/
/***************************** register info block ****************************/
-extern int nregdescint[]; /* description of integer registers */
-extern int nregdescfloat[]; /* description of floating point registers */
-
-extern int nreg_parammode;
-
-
extern int stackreq[256];
-#if defined(__I386__)
-extern bool method_uses_ecx;
-extern bool method_uses_edx;
-#endif
-
+/* function prototypes ********************************************************/
-/* function prototypes */
-
-methodptr jit_compile (methodinfo *m); /* compile a method with jit compiler */
+functionptr jit_compile(methodinfo *m); /* compile a method with jit compiler */
void jit_init(); /* compiler initialisation */
void jit_close(); /* compiler finalisation */
-u1 *createcompilerstub(methodinfo *m);
-u1 *createnativestub(functionptr f, methodinfo *m);
-
-void removecompilerstub(u1 *stub);
-void removenativestub(u1 *stub);
+void compile_all_class_methods(classinfo *c);
#endif /* _JIT_H */