1 /* src/vm/jit/jit.h - code generation header
3 Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
31 /* forward typedefs ***********************************************************/
33 typedef struct jitdata jitdata;
34 typedef struct stackelement stackelement;
35 typedef stackelement *stackptr;
36 typedef struct basicblock basicblock;
37 typedef struct instruction instruction;
38 typedef struct insinfo_inline insinfo_inline;
39 typedef struct exception_entry exception_entry;
45 #include "toolbox/chain.h"
47 #include "vm/global.h"
48 #include "vm/resolve.h"
50 #include "vm/jit/codegen-common.h"
51 #include "vm/jit/reg.h"
52 #include "vm/jit/replace.h"
53 #include "vm/jit/stacktrace.h"
55 #if defined(ENABLE_INLINING)
56 # include "vm/jit/inline/inline.h"
59 #include "vm/jit/ir/bytecode.h"
61 #if defined(ENABLE_LOOP)
62 # include "vm/jit/loop/loop.h"
64 #if defined(ENABLE_SSA)
65 # include "vm/jit/optimizing/lsra.h"
67 #if defined(ENABLE_LSRA)
68 # include "vm/jit/allocator/lsra.h"
71 #include "vm/jit/verify/typeinfo.h"
73 #include "vmcore/descriptor.h"
74 #include "vmcore/method.h"
75 #include "vmcore/references.h"
77 #if defined(ENABLE_STATISTICS)
78 # include "vmcore/statistics.h"
82 /* common jit/codegen macros **************************************************/
84 #if defined(ENABLE_STATISTICS)
85 # define COUNT(x) (x)++
86 # define COUNT_SPILLS /* use COUNT_(READ|WRITE)_SPILLS instead */
87 # define COUNT_READ_SPILLS(var) \
89 case TYPE_FLT: count_spills_read_flt++; break; \
90 case TYPE_DBL: count_spills_read_dbl++; break; \
91 default: count_spills_read_ila++; break; \
94 # define COUNT_WRITE_SPILLS(var) \
96 case TYPE_FLT: count_spills_write_flt++; break; \
97 case TYPE_DBL: count_spills_write_dbl++; break; \
98 default: count_spills_write_ila++; break; \
102 # define COUNT(x) /* nothing */
103 # define COUNT_SPILLS /* nothing */
104 # define COUNT_READ_SPILLS(x) /* nothing */
105 # define COUNT_WRITE_SPILLS(x) /* nothing */
108 typedef struct interface_info interface_info;
110 struct interface_info {
116 /* jitdata ********************************************************************/
119 methodinfo *m; /* methodinfo of the method compiled */
123 #if defined(ENABLE_LOOP)
126 #if defined(ENABLE_SSA) || defined(ENABLE_LSRA)
130 u4 flags; /* contains JIT compiler flags */
132 instruction *instructions; /* ICMDs, valid between parse and stack */
133 basicblock *basicblocks; /* start of basic block list */
134 stackelement *stack; /* XXX should become stack.c internal */
135 s4 instructioncount;/* XXX remove this? */
136 s4 basicblockcount; /* number of basic blocks */
137 s4 stackcount; /* number of stackelements to allocate */
138 /* (passed from parse to stack) */
140 varinfo *var; /* array of variables */
141 s4 vartop; /* next free index in var array */
143 s4 varcount; /* number of variables in var array */
144 s4 localcount; /* number of locals at start of var ar. */
145 s4 *local_map; /* map for renaming (de-coallescing) */
146 /* locals and keeping the coalescing info for simplereg. */
147 /* local_map[javaindex * 5 + type] = */
148 /* >= 0......index into jd->var, or */
149 /* UNUSED....this (javaindex,type) pair is not used */
151 s4 maxlocals; /* max. number of javalocals */
153 interface_info *interface_map; /* interface variables (for simplereg) */
154 s4 maxinterfaces; /* max. number of interface variables */
156 s4 exceptiontablelength; /* exceptiontable length */
157 exception_entry *exceptiontable; /* the exceptiontable */
159 basicblock *returnblock; /* block containing the *RETURN */
160 /* (only use if returncount==1) */
161 s4 returncount; /* number of return instructions */
162 bool branchtoentry; /* true if first block is a target */
163 bool branchtoend; /* true if end dummy is a target */
166 #define FOR_EACH_BASICBLOCK(jd, it) \
167 for ((it) = (jd)->basicblocks; (it) != NULL; (it) = (it)->next)
171 #define JITDATA_FLAG_PARSE 0x00000001
172 #define JITDATA_FLAG_VERIFY 0x00000002
174 #define JITDATA_FLAG_INSTRUMENT 0x00000004
176 #define JITDATA_FLAG_IFCONV 0x00000008
177 #define JITDATA_FLAG_REORDER 0x00000010
178 #define JITDATA_FLAG_INLINE 0x00000020
180 #define JITDATA_FLAG_COUNTDOWN 0x00000100
182 #define JITDATA_FLAG_SHOWINTERMEDIATE 0x20000000
183 #define JITDATA_FLAG_SHOWDISASSEMBLE 0x40000000
184 #define JITDATA_FLAG_VERBOSECALL 0x80000000
187 #define JITDATA_HAS_FLAG_PARSE(jd) \
188 ((jd)->flags & JITDATA_FLAG_PARSE)
190 #define JITDATA_HAS_FLAG_VERIFY(jd) \
191 ((jd)->flags & JITDATA_FLAG_VERIFY)
193 #define JITDATA_HAS_FLAG_INSTRUMENT(jd) \
194 ((jd)->flags & JITDATA_FLAG_INSTRUMENT)
196 #define JITDATA_HAS_FLAG_IFCONV(jd) \
197 ((jd)->flags & JITDATA_FLAG_IFCONV)
199 #define JITDATA_HAS_FLAG_REORDER(jd) \
200 ((jd)->flags & JITDATA_FLAG_REORDER)
202 #define JITDATA_HAS_FLAG_INLINE(jd) \
203 ((jd)->flags & JITDATA_FLAG_INLINE)
205 #define JITDATA_HAS_FLAG_COUNTDOWN(jd) \
206 ((jd)->flags & JITDATA_FLAG_COUNTDOWN)
208 #define JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd) \
209 ((jd)->flags & JITDATA_FLAG_SHOWINTERMEDIATE)
211 #define JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) \
212 ((jd)->flags & JITDATA_FLAG_SHOWDISASSEMBLE)
214 #define JITDATA_HAS_FLAG_VERBOSECALL(jd) \
215 ((jd)->flags & JITDATA_FLAG_VERBOSECALL)
218 /* exception_entry ************************************************************/
220 struct exception_entry {
224 classref_or_classinfo catchtype; /* catchtype of exc. (NULL == catchall) */
225 exception_entry *next; /* next in list of exceptions when */
226 /* loops are copied */
227 exception_entry *down; /* next exception_entry */
231 /* stack element structure ****************************************************/
235 #define SAVEDVAR 1 /* variable has to survive method invocations */
236 #define INMEMORY 2 /* variable stored in memory */
237 #define SAVREG 4 /* allocated to a saved register */
238 #define ARGREG 8 /* allocated to an arg register */
239 #define PASSTHROUGH 32 /* stackslot was passed-through by an ICMD */
240 #define PREALLOC 64 /* preallocated var like for ARGVARS. Used */
241 /* with the new var system */
242 #define INOUT 128 /* variable is an invar or/and an outvar */
244 #define IS_SAVEDVAR(x) ((x) & SAVEDVAR)
245 #define IS_INMEMORY(x) ((x) & INMEMORY)
250 #define UNDEFVAR 0 /* stack slot will become temp during regalloc*/
251 #define TEMPVAR 1 /* stack slot is temp register */
252 #define STACKVAR 2 /* stack slot is numbered stack slot */
253 #define LOCALVAR 3 /* stack slot is local variable */
254 #define ARGVAR 4 /* stack slot is argument variable */
257 struct stackelement {
258 stackptr prev; /* pointer to next element towards bottom */
259 instruction *creator; /* instruction that created this element */
260 s4 type; /* slot type of stack element */
261 s4 flags; /* flags (SAVED, INMEMORY) */
262 s4 varkind; /* kind of variable or register */
263 s4 varnum; /* number of variable */
266 /* macros for accessing variables *********************************************
268 Use VAROP for s1, s2, s3 and dst operands (eg. VAROP(iptr->s1)),
269 use VAR if you have the variable index (eg. VAR(iptr->sx.s23.s2.args[0])).
271 ******************************************************************************/
273 #define VAROP(v) (jd->var + (v).varindex)
274 #define VAR(i) (jd->var + (i))
276 static inline bool var_is_local(const jitdata *jd, s4 i) {
277 return (i < jd->localcount);
280 static inline bool var_is_prealloc(const jitdata *jd, s4 i) {
281 return ((i >= jd->localcount) && (jd->var[i].flags & PREALLOC));
284 static inline bool var_is_inout(const jitdata *jd, s4 i) {
285 const varinfo *v = jd->var + i;
286 return ((i >= jd->localcount) && !(v->flags & PREALLOC) && (v->flags & INOUT));
289 static inline bool var_is_temp(const jitdata *jd, s4 i) {
290 const varinfo *v = jd->var + i;
291 return ((i >= jd->localcount) && !(v->flags & PREALLOC) && !(v->flags & INOUT));
294 static inline bool var_is_saved(const jitdata *jd, s4 i) {
295 return (jd->var[i].flags & SAVEDVAR);
299 /**************************** instruction structure ***************************/
301 /* branch_target_t: used in TABLESWITCH tables */
304 s4 insindex; /* used in parse */
305 basicblock *block; /* valid after parse */
308 /* lookup_target_t: used in LOOKUPSWITCH tables */
311 s4 value; /* case value */
312 branch_target_t target; /* branch target, see above */
327 classref_or_classinfo c;
328 unresolved_class *uc;
329 ptrint constval; /* for PUT*CONST */
330 s4 tablelow; /* for TABLESWITCH */
331 u4 lookupcount; /* for LOOKUPSWITCH */
332 s4 retaddrnr; /* for ASTORE */
340 classref_or_classinfo c;
341 constant_FMIref *fmiref;
342 unresolved_method *um;
343 unresolved_field *uf;
344 insinfo_inline *inlineinfo; /* for INLINE_START/END */
345 s4 tablehigh; /* for TABLESWITCH */
346 branch_target_t lookupdefault; /* for LOOKUPSWITCH */
347 branch_target_t jsrtarget; /* for JSR */
348 s4 javaindex; /* for *STORE */
349 struct builtintable_entry *bte;
352 /*** val operand ***/
360 java_handle_t *stringconst; /* for ACONST with string */
361 classref_or_classinfo c; /* for ACONST with class */
364 /*** dst operand ***/
368 basicblock *block; /* valid after parse */
369 branch_target_t *table; /* for TABLESWITCH */
370 lookup_target_t *lookup; /* for LOOKUPSWITCH */
371 s4 insindex; /* used in parse */
374 /*** flags (32 bits) ***/
376 #define INS_FLAG_BASICBLOCK 0x01 /* marks a basic block start */
377 #define INS_FLAG_UNRESOLVED 0x02 /* contains unresolved field/meth/class*/
378 #define INS_FLAG_CLASS 0x04 /* for ACONST, PUT*CONST with class */
379 #define INS_FLAG_ARRAY 0x08 /* for CHECKCAST/INSTANCEOF with array */
380 #define INS_FLAG_CHECK 0x10 /* for *ALOAD|*ASTORE: check index */
381 /* for BUILTIN: check exception */
382 #define INS_FLAG_KILL_PREV 0x04 /* for *STORE, invalidate prev local */
383 #define INS_FLAG_KILL_NEXT 0x08 /* for *STORE, invalidate next local */
384 #define INS_FLAG_RETADDR 0x10 /* for ASTORE: op is a returnAddress */
386 #define INS_FLAG_ID_SHIFT 5
387 #define INS_FLAG_ID_MASK (~0 << INS_FLAG_ID_SHIFT)
393 /*** instruction ***/
395 /* The instruction format for the intermediate representation: */
399 u2 line; /* line number */
400 #if SIZEOF_VOID_P == 8
401 flags_operand_t flags; /* 4 bytes */
403 s1_operand_t s1; /* pointer-size */
406 s2_operand_t s2; /* pointer-size */
407 s3_operand_t s3; /* pointer-size */
409 val_operand_t val; /* long-size */
411 dst_operand_t dst; /* pointer-size */
412 #if SIZEOF_VOID_P == 4
413 flags_operand_t flags; /* 4 bytes */
418 #define INSTRUCTION_STARTS_BASICBLOCK(iptr) \
419 ((iptr)->flags.bits & INS_FLAG_BASICBLOCK)
421 #define INSTRUCTION_IS_RESOLVED(iptr) \
422 (!((iptr)->flags.bits & INS_FLAG_UNRESOLVED))
424 #define INSTRUCTION_IS_UNRESOLVED(iptr) \
425 ((iptr)->flags.bits & INS_FLAG_UNRESOLVED)
427 #define INSTRUCTION_MUST_CHECK(iptr) \
428 ((iptr)->flags.bits & INS_FLAG_CHECK)
430 #define INSTRUCTION_GET_FIELDREF(iptr,fref) \
432 if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
433 fref = iptr->sx.s23.s3.uf->fieldref; \
435 fref = iptr->sx.s23.s3.fmiref; \
438 #define INSTRUCTION_GET_METHODREF(iptr,mref) \
440 if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
441 mref = iptr->sx.s23.s3.um->methodref; \
443 mref = iptr->sx.s23.s3.fmiref; \
446 #define INSTRUCTION_GET_METHODDESC(iptr, md) \
448 if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
449 md = iptr->sx.s23.s3.um->methodref->parseddesc.md; \
451 md = iptr->sx.s23.s3.fmiref->parseddesc.md; \
454 /* additional info structs for special instructions ***************************/
456 /* for ICMD_INLINE_START and ICMD_INLINE_END */
458 struct insinfo_inline {
459 /* fields copied from the inlining tree ----------------------------------*/
460 insinfo_inline *parent; /* insinfo of the surrounding inlining, if any*/
461 methodinfo *method; /* the inlined method starting/ending here */
462 methodinfo *outer; /* the outer method suspended/resumed here */
463 s4 synclocal; /* local index used for synchronization */
464 bool synchronize; /* true if synchronization is needed */
465 s4 throughcount; /* total # of pass-through variables */
466 s4 paramcount; /* number of parameters of original call */
467 s4 stackvarscount; /* source stackdepth at INLINE_START */
468 s4 *stackvars; /* stack vars at INLINE_START */
470 /* fields set by inlining ------------------------------------------------*/
471 s4 *javalocals_start; /* javalocals at start of inlined body */
472 s4 *javalocals_end; /* javalocals after inlined body */
474 /* fields set by replacement point creation ------------------------------*/
475 #if defined(ENABLE_REPLACEMENT)
476 rplpoint *rp; /* replacement point at INLINE_START */
479 /* fields set by the codegen ---------------------------------------------*/
480 s4 startmpc; /* machine code offset of start of inlining */
484 /* basicblock *****************************************************************/
493 #define BBTYPECHECK_UNDEF 2
494 #define BBTYPECHECK_REACHED 3
496 #define BBTYPE_STD 0 /* standard basic block type */
497 #define BBTYPE_EXH 1 /* exception handler basic block type */
498 #define BBTYPE_SBR 2 /* subroutine basic block type */
500 #define BBFLAG_REPLACEMENT 0x01 /* put a replacement point at the start */
502 /* XXX basicblock wastes quite a lot of memory by having four flag fields */
503 /* (flags, bitflags, type and lflags). Probably the last three could be */
504 /* combined without loss of efficiency. The first one could be combined with */
505 /* the others by using bitfields. */
507 /* XXX "flags" should probably be called "state", as it is an integer state */
510 s4 nr; /* basic block number */
511 s4 flags; /* used during stack analysis, init with -1 */
512 s4 bitflags; /* OR of BBFLAG_... constants, init with 0 */
513 s4 type; /* basic block type (std, xhandler, subroutine*/
514 s4 lflags; /* used during loop copying, init with 0 */
516 s4 icount; /* number of intermediate code instructions */
517 instruction *iinstr; /* pointer to intermediate code instructions */
519 varinfo *inlocals; /* copy of locals on block entry */
520 s4 *javalocals; /* map from java locals to cacao variables[+] */
521 s4 *invars; /* array of in-variables at begin of block */
522 s4 *outvars; /* array of out-variables at end of block */
523 s4 indepth; /* stack depth at begin of basic block */
524 s4 outdepth; /* stack depth end of basic block */
525 s4 varstart; /* index of first non-invar block variable */
526 s4 varcount; /* number of non-invar block variables */
530 basicblock **predecessors; /* array of predecessor basic blocks */
531 basicblock **successors; /* array of successor basic blocks */
533 branchref *branchrefs; /* list of branches to be patched */
535 basicblock *next; /* used to build a BB list (instead of array) */
536 basicblock *copied_to; /* points to the copy of this basic block */
537 /* when loop nodes are copied */
538 basicblock *original; /* block of which this block is a clone */
539 /* NULL for the original block itself */
540 methodinfo *method; /* method this block belongs to */
541 insinfo_inline *inlineinfo; /* inlineinfo for the start of this block */
543 s4 mpc; /* machine code pc at start of block */
545 /* TODO: those fields are probably usefull for other passes as well. */
547 #if defined(ENABLE_SSA)
548 basicblock *idom; /* Immediate dominator, parent in dominator tree */
549 basicblock **domsuccessors;/* Children in dominator tree */
550 s4 domsuccessorcount;
552 basicblock **domfrontier; /* Dominance frontier */
555 basicblock **exhandlers; /* Exception handlers for this block */
557 basicblock **expredecessors; /* Blocks this block is exception handler for */
558 s4 expredecessorcount;
559 s4 exouts; /* Number of exceptional exits */
561 basicblock *subbasicblocks;
563 void *vp; /* Freely used by different passes */
567 #define FOR_EACH_SUCCESSOR(bptr, it) \
568 for ((it) = (bptr)->successors; (it) != (bptr)->successors + (bptr)->successorcount; ++(it))
570 #define FOR_EACH_PREDECESSOR(bptr, it) \
572 (it) = (bptr)->predecessors; \
573 (it) != (bptr)->predecessors + ((bptr)->predecessorcount < 0 ? 0 : (bptr)->predecessorcount); \
577 #define FOR_EACH_INSTRUCTION(bptr, it) \
578 for ((it) = (bptr)->iinstr; (it) != (bptr)->iinstr + (bptr)->icount; ++(it))
580 #if defined(ENABLE_SSA)
582 #define FOR_EACH_EXHANDLER(bptr, it) \
583 for ((it) = (bptr)->exhandlers; (it) != (bptr)->exhandlers + (bptr)->exhandlercount; ++(it))
585 #define FOR_EACH_EXPREDECESSOR(bptr, it) \
586 for ((it) = (bptr)->expredecessors; (it) != (bptr)->expredecessors + (bptr)->expredecessorcount; ++(it))
590 /* [+]...the javalocals array: This array is indexed by the javaindex (the */
591 /* local variable index ocurring in the original bytecode). An element */
592 /* javalocals[javaindex] encodes where to find the contents of the */
593 /* original variable at this point in the program. */
594 /* There are three cases for javalocals[javaindex]: */
595 /* >= 0.......it's an index into the jd->var array, where the */
596 /* CACAO variable corresponding to the original local */
598 /* UNUSED.....the original variable is not live at this point */
599 /* < UNUSED...the original variable contains a returnAddress at */
600 /* this point. The number of the block to return to can */
601 /* be calculated using RETADDR_FROM_JAVALOCAL: */
603 /* javalocals[javaindex] == JAVALOCAL_FROM_RETADDR(nr) */
604 /* RETADDR_FROM_JAVALOCAL(javalocals[javaindex]) == nr */
606 #define JAVALOCAL_FROM_RETADDR(nr) (UNUSED - (1 + (nr)))
607 #define RETADDR_FROM_JAVALOCAL(jl) (UNUSED - (1 + (jl)))
610 /* Macro for initializing newly allocated basic block's. It does not
611 need to zero fields, as we zero out the whole basic block array. */
613 #define BASICBLOCK_INIT(bptr,m) \
617 bptr->type = BBTYPE_STD; \
618 bptr->method = (m); \
621 static inline bool basicblock_reached(const basicblock *bptr) {
622 return (bptr->flags >= BBREACHED);
625 /* data-flow constants for the ICMD table ************************************/
632 #define DF_DST_BASE 4 /* from this value on, iptr->dst is a variable */
634 #define DF_0_TO_1 (DF_DST_BASE + 0)
635 #define DF_1_TO_1 (DF_DST_BASE + 1)
636 #define DF_2_TO_1 (DF_DST_BASE + 2)
637 #define DF_3_TO_1 (DF_DST_BASE + 3)
638 #define DF_N_TO_1 (DF_DST_BASE + 4)
640 #define DF_INVOKE (DF_DST_BASE + 5)
641 #define DF_BUILTIN (DF_DST_BASE + 6)
643 #define DF_COPY (DF_DST_BASE + 7)
644 #define DF_MOVE (DF_DST_BASE + 8)
650 #define DF_DUP2_X1 -1
651 #define DF_DUP2_X2 -1
654 /* special data-flow recognized by verify/generate.pl: */
655 #define DF_LOAD DF_COPY
656 #define DF_STORE DF_MOVE
657 #define DF_IINC DF_1_TO_1
658 #define DF_POP DF_1_TO_0
659 #define DF_POP2 DF_2_TO_0
662 /* control-flow constants for the ICMD table *********************************/
667 #define CF_END_BASE 2 /* from here on, they mark the end of a superblock */
669 #define CF_END (CF_END_BASE + 0)
670 #define CF_GOTO (CF_END_BASE + 1)
671 #define CF_TABLE (CF_END_BASE + 2)
672 #define CF_LOOKUP (CF_END_BASE + 3)
673 #define CF_JSR (CF_END_BASE + 4)
674 #define CF_RET (CF_END_BASE + 5)
677 /* flag constants for the ICMD table *****************************************/
679 #define ICMDTABLE_PEI 0x0001 /* ICMD may throw an exception */
680 #define ICMDTABLE_CALLS 0x0002 /* needs registers to be saved, may call */
683 /* ICMD table entry **********************************************************/
685 typedef struct icmdtable_entry_t icmdtable_entry_t;
687 struct icmdtable_entry_t {
689 char *name; /* name, without ICMD_ prefix */
691 s4 dataflow; /* a DF_ constant, see above */
692 s4 controlflow; /* a CF_ constant, see above */
693 s4 flags; /* a combination of ICMDTABLE_ flags */
697 /* the ICMD table ************************************************************/
699 extern icmdtable_entry_t icmd_table[256];
702 /********** JavaVM operation codes (sorted) and instruction lengths ***********/
707 ICMD_ACONST = BC_aconst_null,
711 ICMD_ICONST = BC_iconst_0,
722 ICMD_LCONST = BC_lconst_0,
726 ICMD_FCONST = BC_fconst_0,
731 ICMD_DCONST = BC_dconst_0,
741 /* Order of LOAD instructions must be equal to order of TYPE_*
744 ICMD_ILOAD = BC_iload,
745 ICMD_LLOAD = BC_lload,
746 ICMD_FLOAD = BC_fload,
747 ICMD_DLOAD = BC_dload,
748 ICMD_ALOAD = BC_aload,
759 ICMD_IUSHRCONST = 34,
772 ICMD_LUSHRCONST = 44,
776 ICMD_IALOAD = BC_iaload,
777 ICMD_LALOAD = BC_laload,
778 ICMD_FALOAD = BC_faload,
779 ICMD_DALOAD = BC_daload,
780 ICMD_AALOAD = BC_aaload,
781 ICMD_BALOAD = BC_baload,
782 ICMD_CALOAD = BC_caload,
783 ICMD_SALOAD = BC_saload,
785 /* Order of STORE instructions must be equal to order of TYPE_*
788 ICMD_ISTORE = BC_istore,
789 ICMD_LSTORE = BC_lstore,
790 ICMD_FSTORE = BC_fstore,
791 ICMD_DSTORE = BC_dstore,
792 ICMD_ASTORE = BC_astore,
817 ICMD_IASTORE = BC_iastore,
818 ICMD_LASTORE = BC_lastore,
819 ICMD_FASTORE = BC_fastore,
820 ICMD_DASTORE = BC_dastore,
821 ICMD_AASTORE = BC_aastore,
822 ICMD_BASTORE = BC_bastore,
823 ICMD_CASTORE = BC_castore,
824 ICMD_SASTORE = BC_sastore,
829 ICMD_DUP_X1 = BC_dup_x1,
830 ICMD_DUP_X2 = BC_dup_x2,
832 ICMD_DUP2_X1 = BC_dup2_x1,
833 ICMD_DUP2_X2 = BC_dup2_x2,
870 ICMD_IUSHR = BC_iushr,
871 ICMD_LUSHR = BC_lushr,
895 ICMD_INT2BYTE = BC_int2byte,
896 ICMD_INT2CHAR = BC_int2char,
897 ICMD_INT2SHORT = BC_int2short,
900 ICMD_FCMPL = BC_fcmpl,
901 ICMD_FCMPG = BC_fcmpg,
902 ICMD_DCMPL = BC_dcmpl,
903 ICMD_DCMPG = BC_dcmpg,
912 ICMD_IF_ICMPEQ = BC_if_icmpeq,
913 ICMD_IF_ICMPNE = BC_if_icmpne,
914 ICMD_IF_ICMPLT = BC_if_icmplt,
915 ICMD_IF_ICMPGE = BC_if_icmpge,
916 ICMD_IF_ICMPGT = BC_if_icmpgt,
917 ICMD_IF_ICMPLE = BC_if_icmple,
918 ICMD_IF_ACMPEQ = BC_if_acmpeq,
919 ICMD_IF_ACMPNE = BC_if_acmpne,
925 ICMD_TABLESWITCH = BC_tableswitch,
926 ICMD_LOOKUPSWITCH = BC_lookupswitch,
928 ICMD_IRETURN = BC_ireturn,
929 ICMD_LRETURN = BC_lreturn,
930 ICMD_FRETURN = BC_freturn,
931 ICMD_DRETURN = BC_dreturn,
932 ICMD_ARETURN = BC_areturn,
933 ICMD_RETURN = BC_return,
935 ICMD_GETSTATIC = BC_getstatic,
936 ICMD_PUTSTATIC = BC_putstatic,
937 ICMD_GETFIELD = BC_getfield,
938 ICMD_PUTFIELD = BC_putfield,
940 ICMD_INVOKEVIRTUAL = BC_invokevirtual,
941 ICMD_INVOKESPECIAL = BC_invokespecial,
942 ICMD_INVOKESTATIC = BC_invokestatic,
943 ICMD_INVOKEINTERFACE = BC_invokeinterface,
948 ICMD_NEWARRAY = BC_newarray,
949 ICMD_ANEWARRAY = BC_anewarray,
951 ICMD_ARRAYLENGTH = BC_arraylength,
953 ICMD_ATHROW = BC_athrow,
955 ICMD_CHECKCAST = BC_checkcast,
956 ICMD_INSTANCEOF = BC_instanceof,
958 ICMD_MONITORENTER = BC_monitorenter,
959 ICMD_MONITOREXIT = BC_monitorexit,
963 ICMD_MULTIANEWARRAY = BC_multianewarray,
965 ICMD_IFNULL = BC_ifnull,
966 ICMD_IFNONNULL = BC_ifnonnull,
972 ICMD_IASTORECONST = 204,
973 ICMD_LASTORECONST = 205,
974 ICMD_FASTORECONST = 206,
975 ICMD_DASTORECONST = 207,
976 ICMD_AASTORECONST = 208,
977 ICMD_BASTORECONST = 209,
978 ICMD_CASTORECONST = 210,
979 ICMD_SASTORECONST = 211,
981 ICMD_PUTSTATICCONST = 212,
982 ICMD_PUTFIELDCONST = 213,
987 ICMD_INLINE_START = 251, /* instruction before inlined method */
988 ICMD_INLINE_END = 252, /* instruction after inlined method */
989 ICMD_INLINE_BODY = 253, /* start of inlined body */
991 ICMD_BUILTIN = 255 /* internal opcode */
994 /* Additional instruction accessors */
996 methoddesc *instruction_call_site(const instruction *iptr);
998 static inline bool instruction_has_dst(const instruction *iptr) {
1000 (icmd_table[iptr->opc].dataflow == DF_INVOKE) ||
1001 (icmd_table[iptr->opc].dataflow == DF_BUILTIN)
1003 return instruction_call_site(iptr)->returntype.type != TYPE_VOID;
1005 return icmd_table[iptr->opc].dataflow >= DF_DST_BASE;
1009 /***************************** register types *********************************/
1011 #define REG_RES 0 /* reserved register for OS or code generator */
1012 #define REG_RET 1 /* return value register */
1013 #define REG_EXC 2 /* exception value register */
1014 #define REG_SAV 3 /* (callee) saved register */
1015 #define REG_TMP 4 /* scratch temporary register (caller saved) */
1016 #define REG_ARG 5 /* argument register (caller saved) */
1018 #define REG_END -1 /* last entry in tables */
1020 #define PARAMMODE_NUMBERED 0
1021 #define PARAMMODE_STUFFED 1
1024 /* function prototypes ********************************************************/
1026 /* compiler initialisation */
1027 void jit_init(void);
1029 /* compiler finalisation */
1030 void jit_close(void);
1032 /* create a new jitdata */
1033 jitdata *jit_jitdata_new(methodinfo *m);
1035 /* compile a method with jit compiler */
1036 u1 *jit_compile(methodinfo *m);
1037 u1 *jit_recompile(methodinfo *m);
1039 void jit_invalidate_code(methodinfo *m);
1040 codeinfo *jit_get_current_code(methodinfo *m);
1041 void jit_request_optimization(methodinfo *m);
1043 /* patch the method entrypoint */
1044 #if !defined(JIT_COMPILER_VIA_SIGNAL)
1045 u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra);
1047 void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr);
1049 s4 jit_complement_condition(s4 opcode);
1051 void jit_renumber_basicblocks(jitdata *jd);
1052 #if !defined(NDEBUG)
1053 void jit_check_basicblock_numbers(jitdata *jd);
1057 /* machine dependent functions ************************************************/
1059 #if defined(ENABLE_JIT)
1063 #if defined(ENABLE_INTRP)
1064 void intrp_md_init(void);
1067 void *md_jit_method_patch_address(void *pv, void *ra, void *mptr);
1073 * These are local overrides for various environment variables in Emacs.
1074 * Please do not remove this and leave it at the end of the file, where
1075 * Emacs will automagically detect them.
1076 * ---------------------------------------------------------------------
1079 * indent-tabs-mode: t
1083 * vim:noexpandtab:sw=4:ts=4: