/* 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 This file is part of CACAO. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Contact: cacao@complang.tuwien.ac.at Authors: Andreas Krall Reinhard Grafl Changes: Christian Thalinger $Id: jit.h 557 2003-11-02 22:51:59Z twisti $ */ #ifndef _JIT_H #define _JIT_H #include "global.h" #include "toolbox/chain.h" /**************************** 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; /************************** stack element structure ***************************/ /* 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 #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) /* flags */ #define SAVEDVAR 1 /* variable has to survive method invocations */ #define INMEMORY 2 /* variable stored in memory */ #define SAVEDTMP 4 /* temporary variable using a saved register */ /* variable kinds */ #define UNDEFVAR 0 /* stack slot will become temp during regalloc*/ #define TEMPVAR 1 /* stack slot is temp register */ #define STACKVAR 2 /* stack slot is numbered stack slot */ #define LOCALVAR 3 /* stack slot is local variable */ #define ARGVAR 4 /* stack slot is argument variable */ struct stackelement { stackptr prev; /* pointer to next element towards bottom */ int type; /* slot type of stack element */ int flags; /* flags (SAVED, INMEMORY) */ int varkind; /* kind of variable or register */ int varnum; /* number of variable */ int regoff; /* register number or memory offset */ }; /**************************** instruction structure ***************************/ struct instruction { 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 */ }; /**************************** basic block structure ***************************/ /* flags */ #define BBDELETED -2 #define BBUNDEF -1 #define BBREACHED 0 #define BBFINISHED 1 #define BBTYPE_STD 0 /* standard basic block type */ #define BBTYPE_EXH 1 /* exception handler basic block type */ #define BBTYPE_SBR 2 /* subroutine basic block type */ 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 icount; /* number of intermediate code instructions */ int mpc; /* machine code pc at start of block */ stackptr instack; /* stack at begin of basic block */ stackptr outstack; /* stack at end of basic block */ 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 */ basicblock *next; /* used to build a BB list (instead of array) */ int lflags; /* used during loop copying, init with 0 */ basicblock *copied_to; /* points to the copy of this basic block */ /* when loop nodes are copied */ int debug_nr; }; /************************* pseudo variable structure **************************/ struct varinfo { int type; /* basic type of variable */ int flags; /* flags (SAVED, INMEMORY) */ int regoff; /* register number or memory offset */ }; typedef varinfo varinfo5[5]; /***************** forward references in branch instructions ******************/ struct branchref { s4 branchpos; /* patching position in code segment */ 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 dataref { u1 *pos; /* patching position in generated code */ dataref *next; /* next element in dataref list */ }; /********** JavaVM operation codes (sorted) and instruction lengths ***********/ extern char *icmd_names[256]; extern char *opcode_names[256]; extern int jcommandsize[256]; #define JAVA_NOP 0 #define ICMD_NOP 0 #define JAVA_ACONST_NULL 1 #define ICMD_ACONST 1 /* val.a = constant */ #define JAVA_ICONST_M1 2 #define ICMD_NULLCHECKPOP 2 #define JAVA_ICONST_0 3 #define ICMD_ICONST 3 /* val.i = constant */ #define JAVA_ICONST_1 4 #define ICMD_IREM0X10001 4 #define JAVA_ICONST_2 5 #define ICMD_IDIVPOW2 5 /* val.i = constant */ #define JAVA_ICONST_3 6 #define ICMD_LDIVPOW2 6 /* val.l = constant */ #define JAVA_ICONST_4 7 #define JAVA_ICONST_5 8 #define ICMD_LREM0X10001 8 #define JAVA_LCONST_0 9 #define ICMD_LCONST 9 /* val.l = constant */ #define JAVA_LCONST_1 10 #define ICMD_LCMPCONST 10 /* val.l = constant */ #define JAVA_FCONST_0 11 #define ICMD_FCONST 11 /* val.f = constant */ #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_XXX defines */ #define JAVA_ILOAD 21 #define ICMD_ILOAD 21 /* op1 = local variable */ #define JAVA_LLOAD 22 #define ICMD_LLOAD 22 /* op1 = local variable */ #define JAVA_FLOAD 23 #define ICMD_FLOAD 23 /* op1 = local variable */ #define JAVA_DLOAD 24 #define ICMD_DLOAD 24 /* op1 = local variable */ #define JAVA_ALOAD 25 #define ICMD_ALOAD 25 /* op1 = local variable */ #define JAVA_ILOAD_0 26 #define ICMD_IADDCONST 26 /* val.i = constant */ #define JAVA_ILOAD_1 27 #define ICMD_ISUBCONST 27 /* val.i = constant */ #define JAVA_ILOAD_2 28 #define ICMD_IMULCONST 28 /* val.i = constant */ #define JAVA_ILOAD_3 29 #define ICMD_IANDCONST 29 /* val.i = constant */ #define JAVA_LLOAD_0 30 #define ICMD_IORCONST 30 /* val.i = constant */ #define JAVA_LLOAD_1 31 #define ICMD_IXORCONST 31 /* val.i = constant */ #define JAVA_LLOAD_2 32 #define ICMD_ISHLCONST 32 /* val.i = constant */ #define JAVA_LLOAD_3 33 #define ICMD_ISHRCONST 33 /* val.i = constant */ #define JAVA_FLOAD_0 34 #define ICMD_IUSHRCONST 34 /* val.i = constant */ #define JAVA_FLOAD_1 35 #define ICMD_IREMPOW2 35 /* val.i = constant */ #define JAVA_FLOAD_2 36 #define ICMD_LADDCONST 36 /* val.l = constant */ #define JAVA_FLOAD_3 37 #define ICMD_LSUBCONST 37 /* val.l = constant */ #define JAVA_DLOAD_0 38 #define ICMD_LMULCONST 38 /* val.l = constant */ #define JAVA_DLOAD_1 39 #define ICMD_LANDCONST 39 /* val.l = constant */ #define JAVA_DLOAD_2 40 #define ICMD_LORCONST 40 /* val.l = constant */ #define JAVA_DLOAD_3 41 #define ICMD_LXORCONST 41 /* val.l = constant */ #define JAVA_ALOAD_0 42 #define ICMD_LSHLCONST 42 /* val.l = constant */ #define JAVA_ALOAD_1 43 #define ICMD_LSHRCONST 43 /* val.l = constant */ #define JAVA_ALOAD_2 44 #define ICMD_LUSHRCONST 44 /* val.l = constant */ #define JAVA_ALOAD_3 45 #define ICMD_LREMPOW2 45 /* val.l = constant */ #define JAVA_IALOAD 46 #define ICMD_IALOAD 46 #define JAVA_LALOAD 47 #define ICMD_LALOAD 47 #define JAVA_FALOAD 48 #define ICMD_FALOAD 48 #define JAVA_DALOAD 49 #define ICMD_DALOAD 49 #define JAVA_AALOAD 50 #define ICMD_AALOAD 50 #define JAVA_BALOAD 51 #define ICMD_BALOAD 51 #define JAVA_CALOAD 52 #define ICMD_CALOAD 52 #define JAVA_SALOAD 53 #define ICMD_SALOAD 53 /* order of STORE instructions must be*/ /* equal to order of TYPE_XXX defines */ #define JAVA_ISTORE 54 #define ICMD_ISTORE 54 /* op1 = local variable */ #define JAVA_LSTORE 55 #define ICMD_LSTORE 55 /* op1 = local variable */ #define JAVA_FSTORE 56 #define ICMD_FSTORE 56 /* op1 = local variable */ #define JAVA_DSTORE 57 #define ICMD_DSTORE 57 /* op1 = local variable */ #define JAVA_ASTORE 58 #define ICMD_ASTORE 58 /* op1 = local variable */ #define JAVA_ISTORE_0 59 #define ICMD_IF_LEQ 59 /* op1 = target JavaVM pc, val.l */ #define JAVA_ISTORE_1 60 #define ICMD_IF_LNE 60 /* op1 = target JavaVM pc, val.l */ #define JAVA_ISTORE_2 61 #define ICMD_IF_LLT 61 /* op1 = target JavaVM pc, val.l */ #define JAVA_ISTORE_3 62 #define ICMD_IF_LGE 62 /* op1 = target JavaVM pc, val.l */ #define JAVA_LSTORE_0 63 #define ICMD_IF_LGT 63 /* op1 = target JavaVM pc, val.l */ #define JAVA_LSTORE_1 64 #define ICMD_IF_LLE 64 /* op1 = target JavaVM pc, val.l */ #define JAVA_LSTORE_2 65 #define ICMD_IF_LCMPEQ 65 /* op1 = target JavaVM pc */ #define JAVA_LSTORE_3 66 #define ICMD_IF_LCMPNE 66 /* op1 = target JavaVM pc */ #define JAVA_FSTORE_0 67 #define ICMD_IF_LCMPLT 67 /* op1 = target JavaVM pc */ #define JAVA_FSTORE_1 68 #define ICMD_IF_LCMPGE 68 /* op1 = target JavaVM pc */ #define JAVA_FSTORE_2 69 #define ICMD_IF_LCMPGT 69 /* op1 = target JavaVM pc */ #define JAVA_FSTORE_3 70 #define ICMD_IF_LCMPLE 70 /* op1 = target JavaVM pc */ #define JAVA_DSTORE_0 71 #define JAVA_DSTORE_1 72 #define JAVA_DSTORE_2 73 #define JAVA_DSTORE_3 74 #define JAVA_ASTORE_0 75 #define JAVA_ASTORE_1 76 #define JAVA_ASTORE_2 77 #define JAVA_ASTORE_3 78 #define JAVA_IASTORE 79 #define ICMD_IASTORE 79 #define JAVA_LASTORE 80 #define ICMD_LASTORE 80 #define JAVA_FASTORE 81 #define ICMD_FASTORE 81 #define JAVA_DASTORE 82 #define ICMD_DASTORE 82 #define JAVA_AASTORE 83 #define ICMD_AASTORE 83 #define JAVA_BASTORE 84 #define ICMD_BASTORE 84 #define JAVA_CASTORE 85 #define ICMD_CASTORE 85 #define JAVA_SASTORE 86 #define ICMD_SASTORE 86 #define JAVA_POP 87 #define ICMD_POP 87 #define JAVA_POP2 88 #define ICMD_POP2 88 #define JAVA_DUP 89 #define ICMD_DUP 89 #define JAVA_DUP_X1 90 #define ICMD_DUP_X1 90 #define JAVA_DUP_X2 91 #define ICMD_DUP_X2 91 #define JAVA_DUP2 92 #define ICMD_DUP2 92 #define JAVA_DUP2_X1 93 #define ICMD_DUP2_X1 93 #define JAVA_DUP2_X2 94 #define ICMD_DUP2_X2 94 #define JAVA_SWAP 95 #define ICMD_SWAP 95 #define JAVA_IADD 96 #define ICMD_IADD 96 #define JAVA_LADD 97 #define ICMD_LADD 97 #define JAVA_FADD 98 #define ICMD_FADD 98 #define JAVA_DADD 99 #define ICMD_DADD 99 #define JAVA_ISUB 100 #define ICMD_ISUB 100 #define JAVA_LSUB 101 #define ICMD_LSUB 101 #define JAVA_FSUB 102 #define ICMD_FSUB 102 #define JAVA_DSUB 103 #define ICMD_DSUB 103 #define JAVA_IMUL 104 #define ICMD_IMUL 104 #define JAVA_LMUL 105 #define ICMD_LMUL 105 #define JAVA_FMUL 106 #define ICMD_FMUL 106 #define JAVA_DMUL 107 #define ICMD_DMUL 107 #define JAVA_IDIV 108 #define ICMD_IDIV 108 #define JAVA_LDIV 109 #define ICMD_LDIV 109 #define JAVA_FDIV 110 #define ICMD_FDIV 110 #define JAVA_DDIV 111 #define ICMD_DDIV 111 #define JAVA_IREM 112 #define ICMD_IREM 112 #define JAVA_LREM 113 #define ICMD_LREM 113 #define JAVA_FREM 114 #define ICMD_FREM 114 #define JAVA_DREM 115 #define ICMD_DREM 115 #define JAVA_INEG 116 #define ICMD_INEG 116 #define JAVA_LNEG 117 #define ICMD_LNEG 117 #define JAVA_FNEG 118 #define ICMD_FNEG 118 #define JAVA_DNEG 119 #define ICMD_DNEG 119 #define JAVA_ISHL 120 #define ICMD_ISHL 120 #define JAVA_LSHL 121 #define ICMD_LSHL 121 #define JAVA_ISHR 122 #define ICMD_ISHR 122 #define JAVA_LSHR 123 #define ICMD_LSHR 123 #define JAVA_IUSHR 124 #define ICMD_IUSHR 124 #define JAVA_LUSHR 125 #define ICMD_LUSHR 125 #define JAVA_IAND 126 #define ICMD_IAND 126 #define JAVA_LAND 127 #define ICMD_LAND 127 #define JAVA_IOR 128 #define ICMD_IOR 128 #define JAVA_LOR 129 #define ICMD_LOR 129 #define JAVA_IXOR 130 #define ICMD_IXOR 130 #define JAVA_LXOR 131 #define ICMD_LXOR 131 #define JAVA_IINC 132 #define ICMD_IINC 132 /* op1 = local variable, val.i = constant */ #define JAVA_I2L 133 #define ICMD_I2L 133 #define JAVA_I2F 134 #define ICMD_I2F 134 #define JAVA_I2D 135 #define ICMD_I2D 135 #define JAVA_L2I 136 #define ICMD_L2I 136 #define JAVA_L2F 137 #define ICMD_L2F 137 #define JAVA_L2D 138 #define ICMD_L2D 138 #define JAVA_F2I 139 #define ICMD_F2I 139 #define JAVA_F2L 140 #define ICMD_F2L 140 #define JAVA_F2D 141 #define ICMD_F2D 141 #define JAVA_D2I 142 #define ICMD_D2I 142 #define JAVA_D2L 143 #define ICMD_D2L 143 #define JAVA_D2F 144 #define ICMD_D2F 144 #define JAVA_INT2BYTE 145 #define ICMD_INT2BYTE 145 #define JAVA_INT2CHAR 146 #define ICMD_INT2CHAR 146 #define JAVA_INT2SHORT 147 #define ICMD_INT2SHORT 147 #define JAVA_LCMP 148 #define ICMD_LCMP 148 #define JAVA_FCMPL 149 #define ICMD_FCMPL 149 #define JAVA_FCMPG 150 #define ICMD_FCMPG 150 #define JAVA_DCMPL 151 #define ICMD_DCMPL 151 #define JAVA_DCMPG 152 #define ICMD_DCMPG 152 #define JAVA_IFEQ 153 #define ICMD_IFEQ 153 /* op1 = target JavaVM pc, val.i */ #define JAVA_IFNE 154 #define ICMD_IFNE 154 /* op1 = target JavaVM pc, val.i */ #define JAVA_IFLT 155 #define ICMD_IFLT 155 /* op1 = target JavaVM pc, val.i */ #define JAVA_IFGE 156 #define ICMD_IFGE 156 /* op1 = target JavaVM pc, val.i */ #define JAVA_IFGT 157 #define ICMD_IFGT 157 /* op1 = target JavaVM pc, val.i */ #define JAVA_IFLE 158 #define ICMD_IFLE 158 /* op1 = target JavaVM pc, val.i */ #define JAVA_IF_ICMPEQ 159 #define ICMD_IF_ICMPEQ 159 /* op1 = target JavaVM pc */ #define JAVA_IF_ICMPNE 160 #define ICMD_IF_ICMPNE 160 /* op1 = target JavaVM pc */ #define JAVA_IF_ICMPLT 161 #define ICMD_IF_ICMPLT 161 /* op1 = target JavaVM pc */ #define JAVA_IF_ICMPGE 162 #define ICMD_IF_ICMPGE 162 /* op1 = target JavaVM pc */ #define JAVA_IF_ICMPGT 163 #define ICMD_IF_ICMPGT 163 /* op1 = target JavaVM pc */ #define JAVA_IF_ICMPLE 164 #define ICMD_IF_ICMPLE 164 /* op1 = target JavaVM pc */ #define JAVA_IF_ACMPEQ 165 #define ICMD_IF_ACMPEQ 165 /* op1 = target JavaVM pc */ #define JAVA_IF_ACMPNE 166 #define ICMD_IF_ACMPNE 166 /* op1 = target JavaVM pc */ #define JAVA_GOTO 167 #define ICMD_GOTO 167 /* op1 = target JavaVM pc */ #define JAVA_JSR 168 #define ICMD_JSR 168 /* op1 = target JavaVM pc */ #define JAVA_RET 169 #define ICMD_RET 169 /* op1 = local variable */ #define JAVA_TABLESWITCH 170 #define ICMD_TABLESWITCH 170 /* val.a = pointer to s4 table */ /* length must be computed */ #define JAVA_LOOKUPSWITCH 171 #define ICMD_LOOKUPSWITCH 171 /* val.a = pointer to s4 table */ /* length must be computed */ #define JAVA_IRETURN 172 #define ICMD_IRETURN 172 #define JAVA_LRETURN 173 #define ICMD_LRETURN 173 #define JAVA_FRETURN 174 #define ICMD_FRETURN 174 #define JAVA_DRETURN 175 #define ICMD_DRETURN 175 #define JAVA_ARETURN 176 #define ICMD_ARETURN 176 #define JAVA_RETURN 177 #define ICMD_RETURN 177 #define JAVA_GETSTATIC 178 #define ICMD_GETSTATIC 178 /* op1 = type, val.a = field address */ #define JAVA_PUTSTATIC 179 #define ICMD_PUTSTATIC 179 /* op1 = type, val.a = field address */ #define JAVA_GETFIELD 180 #define ICMD_GETFIELD 180 /* op1 = type, val.i = field offset */ #define JAVA_PUTFIELD 181 #define ICMD_PUTFIELD 181 /* op1 = type, val.i = field offset */ #define JAVA_INVOKEVIRTUAL 182 #define ICMD_INVOKEVIRTUAL 182 /* val.a = method info pointer */ #define JAVA_INVOKESPECIAL 183 #define ICMD_INVOKESPECIAL 183 /* val.a = method info pointer */ #define JAVA_INVOKESTATIC 184 #define ICMD_INVOKESTATIC 184 /* val.a = method info pointer */ #define JAVA_INVOKEINTERFACE 185 #define ICMD_INVOKEINTERFACE 185 /* val.a = method info pointer */ #define ICMD_CHECKASIZE 186 /* */ #define JAVA_NEW 187 #define ICMD_NEW 187 /* op1 = 1, val.a = class pointer */ #define JAVA_NEWARRAY 188 #define ICMD_NEWARRAY 188 /* op1 = basic type */ #define JAVA_ANEWARRAY 189 #define ICMD_ANEWARRAY 189 /* op1 = 0, val.a = array pointer */ /* op1 = 1, val.a = class pointer */ #define JAVA_ARRAYLENGTH 190 #define ICMD_ARRAYLENGTH 190 #define JAVA_ATHROW 191 #define ICMD_ATHROW 191 #define JAVA_CHECKCAST 192 #define ICMD_CHECKCAST 192 /* op1 = 0, val.a = array pointer */ /* op1 = 1, val.a = class pointer */ #define JAVA_INSTANCEOF 193 #define ICMD_INSTANCEOF 193 /* op1 = 0, val.a = array pointer */ /* op1 = 1, val.a = class pointer */ #define JAVA_MONITORENTER 194 #define ICMD_MONITORENTER 194 #define JAVA_MONITOREXIT 195 #define ICMD_MONITOREXIT 195 #define JAVA_WIDE 196 #define JAVA_MULTIANEWARRAY 197 #define ICMD_MULTIANEWARRAY 197 /* op1 = dimension, val.a = array */ /* pointer */ #define JAVA_IFNULL 198 #define ICMD_IFNULL 198 /* op1 = target JavaVM pc */ #define JAVA_IFNONNULL 199 #define ICMD_IFNONNULL 199 /* op1 = target JavaVM pc */ #define JAVA_GOTO_W 200 #define JAVA_JSR_W 201 #define JAVA_BREAKPOINT 202 #define ICMD_BUILTIN3 253 /* internal opcode */ #define ICMD_BUILTIN2 254 /* internal opcode */ #define ICMD_BUILTIN1 255 /* internal opcode */ #define ICMD_READONLY_ARG 1024 /* used for inlining, opcodes 1024-1028 are used */ #define ICMD_CLEAR_ARGREN 1029 /* indicates the start of a new inlined method argument renaming must be reset */ /******************* description of JavaVM instructions ***********************/ #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; static stdopdescriptor builtintable[] = { { ICMD_LCMP, TYPE_LONG, TYPE_LONG, TYPE_INT, ICMD_BUILTIN2, (functionptr) builtin_lcmp , SUPPORT_LONG && SUPPORT_LONG_CMP, false }, { ICMD_LAND, TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2, (functionptr) builtin_land , SUPPORT_LONG && SUPPORT_LONG_LOG, false }, { ICMD_LOR, TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2, (functionptr) builtin_lor , SUPPORT_LONG && SUPPORT_LONG_LOG, false }, { ICMD_LXOR, TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2, (functionptr) builtin_lxor , SUPPORT_LONG && SUPPORT_LONG_LOG, false }, { ICMD_LSHL, TYPE_LONG, TYPE_INT, TYPE_LONG, ICMD_BUILTIN2, (functionptr) builtin_lshl , SUPPORT_LONG && SUPPORT_LONG_SHIFT, false }, { ICMD_LSHR, TYPE_LONG, TYPE_INT, TYPE_LONG, ICMD_BUILTIN2, (functionptr) builtin_lshr, SUPPORT_LONG && SUPPORT_LONG_SHIFT, false }, { ICMD_LUSHR, TYPE_LONG, TYPE_INT, TYPE_LONG, ICMD_BUILTIN2, (functionptr) builtin_lushr, SUPPORT_LONG && SUPPORT_LONG_SHIFT, false }, { ICMD_LADD, TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2, (functionptr) builtin_ladd , SUPPORT_LONG && SUPPORT_LONG_ADD, false }, { ICMD_LSUB, TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2, (functionptr) builtin_lsub , SUPPORT_LONG && SUPPORT_LONG_ADD, false }, { ICMD_LNEG, TYPE_LONG, TYPE_VOID, TYPE_LONG, ICMD_BUILTIN1, (functionptr) builtin_lneg, SUPPORT_LONG && SUPPORT_LONG_ADD, true }, { ICMD_LMUL, TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2, (functionptr) builtin_lmul , SUPPORT_LONG && SUPPORT_LONG_MULDIV, false }, { ICMD_FREM, TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, ICMD_BUILTIN2, (functionptr) builtin_frem, SUPPORT_FLOAT && SUPPORT_FMOD, true }, { ICMD_DREM, TYPE_DOUBLE, TYPE_DOUBLE, TYPE_DOUBLE, ICMD_BUILTIN2, (functionptr) builtin_drem, SUPPORT_DOUBLE && SUPPORT_FMOD, true }, { ICMD_I2F, TYPE_INT, TYPE_VOID, TYPE_FLOAT, ICMD_BUILTIN1, (functionptr) builtin_i2f, SUPPORT_FLOAT && SUPPORT_IFCVT, true }, { ICMD_I2D, TYPE_INT, TYPE_VOID, TYPE_DOUBLE, ICMD_BUILTIN1, (functionptr) builtin_i2d, SUPPORT_DOUBLE && SUPPORT_IFCVT, true }, { ICMD_L2F, TYPE_LONG, TYPE_VOID, TYPE_FLOAT, ICMD_BUILTIN1, (functionptr) builtin_l2f, SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_LONG_FCVT, true }, { ICMD_L2D, TYPE_LONG, TYPE_VOID, TYPE_DOUBLE, ICMD_BUILTIN1, (functionptr) builtin_l2d, SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_LONG_FCVT, true }, { ICMD_F2L, TYPE_FLOAT, TYPE_VOID, TYPE_LONG, ICMD_BUILTIN1, (functionptr) builtin_f2l, SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_LONG_FCVT, true }, { ICMD_D2L, TYPE_DOUBLE, TYPE_VOID, TYPE_LONG, ICMD_BUILTIN1, (functionptr) builtin_d2l, SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_LONG_FCVT, true }, { ICMD_F2I, TYPE_FLOAT, TYPE_VOID, TYPE_INT, ICMD_BUILTIN1, (functionptr) builtin_f2i, SUPPORT_FLOAT && SUPPORT_FICVT, true }, { ICMD_D2I, TYPE_DOUBLE, TYPE_VOID, TYPE_INT, ICMD_BUILTIN1, (functionptr) builtin_d2i, SUPPORT_DOUBLE && SUPPORT_FICVT, true }, }; #endif /* USEBUILTINTABLE */ /***************************** register types *********************************/ #define REG_RES 0 /* reserved register for OS or code generator */ #define REG_RET 1 /* return value register */ #define REG_EXC 2 /* exception value register */ #define REG_SAV 3 /* (callee) saved register */ #define REG_TMP 4 /* scratch temporary register (caller saved) */ #define REG_ARG 5 /* argument register (caller saved) */ #define REG_END -1 /* last entry in tables */ #define PARAMMODE_NUMBERED 0 #define PARAMMODE_STUFFED 1 /***************************** register info block ****************************/ extern int nregdescint[]; /* description of integer registers */ extern int nregdescfloat[]; /* description of floating point registers */ extern int nreg_parammode; /* 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 count_pcmd_activ; extern int count_pcmd_drop; extern int count_pcmd_zero; extern int count_pcmd_const_store; extern int count_pcmd_const_alu; extern int count_pcmd_const_bra; extern int count_pcmd_load; extern int count_pcmd_move; extern int count_load_instruction; extern int count_pcmd_store; extern int count_pcmd_store_comb; extern int count_dup_instruction; extern int count_pcmd_op; extern int count_pcmd_mem; extern int count_pcmd_met; extern int count_pcmd_bra; extern int count_pcmd_table; extern int count_pcmd_return; extern int count_pcmd_returnx; extern int count_check_null; extern int count_check_bound; extern int count_max_basic_blocks; extern int count_basic_blocks; extern int count_max_javainstr; extern int count_javainstr; extern int count_javacodesize; extern int count_javaexcsize; extern int count_calls; extern int count_tryblocks; extern int count_code_len; extern int count_data_len; extern int count_cstub_len; extern int count_nstub_len; extern int count_max_new_stack; extern int count_upper_bound_new_stack; extern int *count_block_stack; extern int *count_analyse_iterations; extern int *count_method_bb_distribution; extern int *count_block_size_distribution; extern int *count_store_length; extern int *count_store_depth; /* global compiler variables */ extern classinfo *class; /* class the compiled method belongs to */ extern methodinfo *method; /* pointer to method info of compiled method */ extern int mparamcount; /* number of parameters (incl. this) */ extern u1 *mparamtypes; /* types of all parameters (TYPE_INT, ...) */ extern int maxstack; /* maximal JavaVM stack size */ 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 */ extern int exceptiontablelength;/* length of exception table */ extern xtable *extable; /* pointer to start of exception table */ extern exceptiontable *raw_extable; extern int block_count; /* number of basic blocks */ extern basicblock *block; /* points to basic block array */ extern int *block_index; /* a table which contains for every byte of */ /* JavaVM code a basic block index if at this */ /* byte there is the start of a basic block */ extern int instr_count; /* number of JavaVM instructions */ extern instruction *instr; /* points to intermediate code instructions */ extern int stack_count; /* number of stack elements */ extern stackelement *stack; /* points to intermediate code instructions */ extern bool isleafmethod; /* true if a method doesn't call subroutines */ extern basicblock *last_block; /* points to the end of the BB list */ /* 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]; /* function prototypes */ methodptr 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); #endif /* _JIT_H */ /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where * Emacs will automagically detect them. * --------------------------------------------------------------------- * Local variables: * mode: c * indent-tabs-mode: t * c-basic-offset: 4 * tab-width: 4 * End: */