1 /* src/vm/jit/jit.h - code generation header
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 /* forward typedefs ***********************************************************/
31 typedef struct jitdata jitdata;
32 typedef struct basicblock basicblock;
33 typedef struct instruction instruction;
34 typedef struct insinfo_inline insinfo_inline;
35 typedef struct exception_entry exception_entry;
41 #include "toolbox/chain.h"
43 #include "vm/global.h"
44 #include "vm/resolve.h"
46 #include "vm/jit/codegen-common.h"
47 #include "vm/jit/reg.h"
48 #include "vm/jit/replace.h"
49 #include "vm/jit/stack.h"
50 #include "vm/jit/stacktrace.h"
52 #if defined(ENABLE_INLINING)
53 # include "vm/jit/inline/inline.h"
56 #include "vm/jit/ir/bytecode.h"
58 #if defined(ENABLE_LOOP)
59 # include "vm/jit/loop/loop.h"
61 #if defined(ENABLE_SSA)
62 # include "vm/jit/optimizing/lsra.h"
64 #if defined(ENABLE_LSRA)
65 # include "vm/jit/allocator/lsra.h"
68 #include "vm/jit/verify/typeinfo.h"
70 #include "vmcore/method.h"
71 #include "vmcore/references.h"
73 #if defined(ENABLE_STATISTICS)
74 # include "vmcore/statistics.h"
78 /* common jit/codegen macros **************************************************/
80 #if defined(ENABLE_STATISTICS)
81 # define COUNT(x) (x)++
82 # define COUNT_SPILLS /* use COUNT_(READ|WRITE)_SPILLS instead */
83 # define COUNT_READ_SPILLS(var) \
85 case TYPE_FLT: count_spills_read_flt++; break; \
86 case TYPE_DBL: count_spills_read_dbl++; break; \
87 default: count_spills_read_ila++; break; \
90 # define COUNT_WRITE_SPILLS(var) \
92 case TYPE_FLT: count_spills_write_flt++; break; \
93 case TYPE_DBL: count_spills_write_dbl++; break; \
94 default: count_spills_write_ila++; break; \
98 # define COUNT(x) /* nothing */
99 # define COUNT_SPILLS /* nothing */
100 # define COUNT_READ_SPILLS(x) /* nothing */
101 # define COUNT_WRITE_SPILLS(x) /* nothing */
104 typedef struct interface_info interface_info;
106 struct interface_info {
112 /* jitdata ********************************************************************/
115 methodinfo *m; /* methodinfo of the method compiled */
119 #if defined(ENABLE_LOOP)
122 #if defined(ENABLE_SSA) || defined(ENABLE_LSRA)
126 u4 flags; /* contains JIT compiler flags */
128 instruction *instructions; /* ICMDs, valid between parse and stack */
129 basicblock *basicblocks; /* start of basic block list */
130 stackelement_t *stack; /* XXX should become stack.c internal */
131 s4 instructioncount;/* XXX remove this? */
132 s4 basicblockcount; /* number of basic blocks */
133 s4 stackcount; /* number of stackelements to allocate */
134 /* (passed from parse to stack) */
136 varinfo *var; /* array of variables */
137 s4 vartop; /* next free index in var array */
139 s4 varcount; /* number of variables in var array */
140 s4 localcount; /* number of locals at start of var ar. */
141 s4 *local_map; /* map for renaming (de-coallescing) */
142 /* locals and keeping the coalescing info for simplereg. */
143 /* local_map[javaindex * 5 + type] = */
144 /* >= 0......index into jd->var, or */
145 /* UNUSED....this (javaindex,type) pair is not used */
147 s4 *reverselocalmap; /* map from CACAO varindex to javaindex */
148 /* (varindex must be < localcount) */
150 s4 maxlocals; /* max. number of javalocals */
152 interface_info *interface_map; /* interface variables (for simplereg) */
153 s4 maxinterfaces; /* max. number of interface variables */
155 s4 exceptiontablelength; /* exceptiontable length */
156 exception_entry *exceptiontable; /* the exceptiontable */
158 basicblock *returnblock; /* block containing the *RETURN */
159 /* (only use if returncount==1) */
160 s4 returncount; /* number of return instructions */
161 bool branchtoentry; /* true if first block is a target */
162 bool branchtoend; /* true if end dummy is a target */
165 #define FOR_EACH_BASICBLOCK(jd, it) \
166 for ((it) = (jd)->basicblocks; (it) != NULL; (it) = (it)->next)
170 #define JITDATA_FLAG_PARSE 0x00000001
171 #define JITDATA_FLAG_VERIFY 0x00000002
173 #define JITDATA_FLAG_INSTRUMENT 0x00000004
175 #define JITDATA_FLAG_IFCONV 0x00000008
176 #define JITDATA_FLAG_REORDER 0x00000010
177 #define JITDATA_FLAG_INLINE 0x00000020
179 #define JITDATA_FLAG_COUNTDOWN 0x00000100
181 #define JITDATA_FLAG_SHOWINTERMEDIATE 0x20000000
182 #define JITDATA_FLAG_SHOWDISASSEMBLE 0x40000000
183 #define JITDATA_FLAG_VERBOSECALL 0x80000000
186 #define JITDATA_HAS_FLAG_PARSE(jd) \
187 ((jd)->flags & JITDATA_FLAG_PARSE)
189 #define JITDATA_HAS_FLAG_VERIFY(jd) \
190 ((jd)->flags & JITDATA_FLAG_VERIFY)
192 #define JITDATA_HAS_FLAG_INSTRUMENT(jd) \
193 ((jd)->flags & JITDATA_FLAG_INSTRUMENT)
195 #define JITDATA_HAS_FLAG_IFCONV(jd) \
196 ((jd)->flags & JITDATA_FLAG_IFCONV)
198 #define JITDATA_HAS_FLAG_REORDER(jd) \
199 ((jd)->flags & JITDATA_FLAG_REORDER)
201 #define JITDATA_HAS_FLAG_INLINE(jd) \
202 ((jd)->flags & JITDATA_FLAG_INLINE)
204 #define JITDATA_HAS_FLAG_COUNTDOWN(jd) \
205 ((jd)->flags & JITDATA_FLAG_COUNTDOWN)
207 #define JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd) \
208 ((jd)->flags & JITDATA_FLAG_SHOWINTERMEDIATE)
210 #define JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) \
211 ((jd)->flags & JITDATA_FLAG_SHOWDISASSEMBLE)
213 #define JITDATA_HAS_FLAG_VERBOSECALL(jd) \
214 ((jd)->flags & JITDATA_FLAG_VERBOSECALL)
217 /* exception_entry ************************************************************/
219 struct exception_entry {
223 classref_or_classinfo catchtype; /* catchtype of exc. (NULL == catchall) */
224 exception_entry *next; /* next in list of exceptions when */
225 /* loops are copied */
226 exception_entry *down; /* next exception_entry */
230 /* macros for accessing variables *********************************************
232 Use VAROP for s1, s2, s3 and dst operands (eg. VAROP(iptr->s1)),
233 use VAR if you have the variable index (eg. VAR(iptr->sx.s23.s2.args[0])).
235 ******************************************************************************/
237 #define VAROP(v) (jd->var + (v).varindex)
238 #define VAR(i) (jd->var + (i))
240 static inline bool var_is_local(const jitdata *jd, s4 i) {
241 return (i < jd->localcount);
244 static inline bool var_is_prealloc(const jitdata *jd, s4 i) {
245 return ((i >= jd->localcount) && (jd->var[i].flags & PREALLOC));
248 static inline bool var_is_inout(const jitdata *jd, s4 i) {
249 const varinfo *v = jd->var + i;
251 (i >= jd->localcount) && (
252 (!(v->flags & PREALLOC) && (v->flags & INOUT)) ||
253 /* special case of TYPE_RET, used with JSR */
254 ((v->flags & PREALLOC) && (v->flags & INOUT) && (v->type == TYPE_RET))
259 static inline bool var_is_temp(const jitdata *jd, s4 i) {
260 const varinfo *v = jd->var + i;
261 return ((i >= jd->localcount) && !(v->flags & PREALLOC) && !(v->flags & INOUT));
264 static inline bool var_is_saved(const jitdata *jd, s4 i) {
265 return (jd->var[i].flags & SAVEDVAR);
269 /**************************** instruction structure ***************************/
271 /* branch_target_t: used in TABLESWITCH tables */
274 s4 insindex; /* used in parse */
275 basicblock *block; /* valid after parse */
278 /* lookup_target_t: used in LOOKUPSWITCH tables */
281 s4 value; /* case value */
282 branch_target_t target; /* branch target, see above */
297 classref_or_classinfo c;
298 unresolved_class *uc;
299 ptrint constval; /* for PUT*CONST */
300 s4 tablelow; /* for TABLESWITCH */
301 u4 lookupcount; /* for LOOKUPSWITCH */
302 s4 retaddrnr; /* for ASTORE */
303 instruction **iargs; /* for PHI */
311 classref_or_classinfo c;
312 constant_FMIref *fmiref;
313 unresolved_method *um;
314 unresolved_field *uf;
315 insinfo_inline *inlineinfo; /* for INLINE_START/END */
316 s4 tablehigh; /* for TABLESWITCH */
317 branch_target_t lookupdefault; /* for LOOKUPSWITCH */
318 branch_target_t jsrtarget; /* for JSR */
319 s4 javaindex; /* for *STORE */
320 struct builtintable_entry *bte;
323 /*** val operand ***/
331 java_handle_t *stringconst; /* for ACONST with string */
332 classref_or_classinfo c; /* for ACONST with class */
335 /*** dst operand ***/
339 basicblock *block; /* valid after parse */
340 branch_target_t *table; /* for TABLESWITCH */
341 lookup_target_t *lookup; /* for LOOKUPSWITCH */
342 s4 insindex; /* used in parse */
345 /*** flags (32 bits) ***/
347 #define INS_FLAG_BASICBLOCK 0x01 /* marks a basic block start */
348 #define INS_FLAG_UNRESOLVED 0x02 /* contains unresolved field/meth/class*/
349 #define INS_FLAG_CLASS 0x04 /* for ACONST, PUT*CONST with class */
350 #define INS_FLAG_ARRAY 0x08 /* for CHECKCAST/INSTANCEOF with array */
351 #define INS_FLAG_CHECK 0x10 /* for *ALOAD|*ASTORE: check index */
352 /* for BUILTIN: check exception */
353 #define INS_FLAG_KILL_PREV 0x04 /* for *STORE, invalidate prev local */
354 #define INS_FLAG_KILL_NEXT 0x08 /* for *STORE, invalidate next local */
355 #define INS_FLAG_RETADDR 0x10 /* for ASTORE: op is a returnAddress */
357 #define INS_FLAG_ID_SHIFT 5
358 #define INS_FLAG_ID_MASK (~0 << INS_FLAG_ID_SHIFT)
364 /*** instruction ***/
366 /* The instruction format for the intermediate representation: */
370 u2 line; /* line number */
371 #if SIZEOF_VOID_P == 8
372 flags_operand_t flags; /* 4 bytes */
374 s1_operand_t s1; /* pointer-size */
377 s2_operand_t s2; /* pointer-size */
378 s3_operand_t s3; /* pointer-size */
380 val_operand_t val; /* long-size */
382 dst_operand_t dst; /* pointer-size */
383 #if SIZEOF_VOID_P == 4
384 flags_operand_t flags; /* 4 bytes */
386 #if defined(ENABLE_ESCAPE_REASON)
387 void *escape_reasons;
392 #define INSTRUCTION_STARTS_BASICBLOCK(iptr) \
393 ((iptr)->flags.bits & INS_FLAG_BASICBLOCK)
395 #define INSTRUCTION_IS_RESOLVED(iptr) \
396 (!((iptr)->flags.bits & INS_FLAG_UNRESOLVED))
398 #define INSTRUCTION_IS_UNRESOLVED(iptr) \
399 ((iptr)->flags.bits & INS_FLAG_UNRESOLVED)
401 #define INSTRUCTION_MUST_CHECK(iptr) \
402 ((iptr)->flags.bits & INS_FLAG_CHECK)
404 #define INSTRUCTION_GET_FIELDREF(iptr,fref) \
406 if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
407 fref = iptr->sx.s23.s3.uf->fieldref; \
409 fref = iptr->sx.s23.s3.fmiref; \
412 #define INSTRUCTION_GET_METHODREF(iptr,mref) \
414 if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
415 mref = iptr->sx.s23.s3.um->methodref; \
417 mref = iptr->sx.s23.s3.fmiref; \
420 #define INSTRUCTION_GET_METHODDESC(iptr, md) \
422 if (iptr->flags.bits & INS_FLAG_UNRESOLVED) \
423 md = iptr->sx.s23.s3.um->methodref->parseddesc.md; \
425 md = iptr->sx.s23.s3.fmiref->parseddesc.md; \
428 /* additional info structs for special instructions ***************************/
430 /* for ICMD_INLINE_START and ICMD_INLINE_END */
432 struct insinfo_inline {
433 /* fields copied from the inlining tree ----------------------------------*/
434 insinfo_inline *parent; /* insinfo of the surrounding inlining, if any*/
435 methodinfo *method; /* the inlined method starting/ending here */
436 methodinfo *outer; /* the outer method suspended/resumed here */
437 s4 synclocal; /* local index used for synchronization */
438 bool synchronize; /* true if synchronization is needed */
439 s4 throughcount; /* total # of pass-through variables */
440 s4 paramcount; /* number of parameters of original call */
441 s4 stackvarscount; /* source stackdepth at INLINE_START */
442 s4 *stackvars; /* stack vars at INLINE_START */
444 /* fields set by inlining ------------------------------------------------*/
445 s4 *javalocals_start; /* javalocals at start of inlined body */
446 s4 *javalocals_end; /* javalocals after inlined body */
448 /* fields set by replacement point creation ------------------------------*/
449 #if defined(ENABLE_REPLACEMENT)
450 rplpoint *rp; /* replacement point at INLINE_START */
453 /* fields set by the codegen ---------------------------------------------*/
454 s4 startmpc; /* machine code offset of start of inlining */
458 /* basicblock *****************************************************************/
467 #define BBTYPECHECK_UNDEF 2
468 #define BBTYPECHECK_REACHED 3
470 #define BBTYPE_STD 0 /* standard basic block type */
471 #define BBTYPE_EXH 1 /* exception handler basic block type */
472 #define BBTYPE_SBR 2 /* subroutine basic block type */
474 #define BBFLAG_REPLACEMENT 0x01 /* put a replacement point at the start */
476 /* XXX basicblock wastes quite a lot of memory by having four flag fields */
477 /* (flags, bitflags, type and lflags). Probably the last three could be */
478 /* combined without loss of efficiency. The first one could be combined with */
479 /* the others by using bitfields. */
481 /* XXX "flags" should probably be called "state", as it is an integer state */
484 s4 nr; /* basic block number */
485 s4 flags; /* used during stack analysis, init with -1 */
486 s4 bitflags; /* OR of BBFLAG_... constants, init with 0 */
487 s4 type; /* basic block type (std, xhandler, subroutine*/
488 s4 lflags; /* used during loop copying, init with 0 */
490 s4 icount; /* number of intermediate code instructions */
491 instruction *iinstr; /* pointer to intermediate code instructions */
493 varinfo *inlocals; /* copy of locals on block entry */
494 s4 *javalocals; /* map from java locals to cacao variables[+] */
495 s4 *invars; /* array of in-variables at begin of block */
496 s4 *outvars; /* array of out-variables at end of block */
497 s4 indepth; /* stack depth at begin of basic block */
498 s4 outdepth; /* stack depth end of basic block */
499 s4 varstart; /* index of first non-invar block variable */
500 s4 varcount; /* number of non-invar block variables */
504 basicblock **predecessors; /* array of predecessor basic blocks */
505 basicblock **successors; /* array of successor basic blocks */
507 branchref *branchrefs; /* list of branches to be patched */
509 basicblock *next; /* used to build a BB list (instead of array) */
510 basicblock *copied_to; /* points to the copy of this basic block */
511 /* when loop nodes are copied */
512 basicblock *original; /* block of which this block is a clone */
513 /* NULL for the original block itself */
514 methodinfo *method; /* method this block belongs to */
515 insinfo_inline *inlineinfo; /* inlineinfo for the start of this block */
517 s4 mpc; /* machine code pc at start of block */
519 /* TODO: those fields are probably usefull for other passes as well. */
521 #if defined(ENABLE_SSA)
522 basicblock *idom; /* Immediate dominator, parent in dominator tree */
523 basicblock **domsuccessors;/* Children in dominator tree */
524 s4 domsuccessorcount;
526 basicblock **domfrontier; /* Dominance frontier */
529 basicblock **exhandlers; /* Exception handlers for this block */
531 basicblock **expredecessors; /* Blocks this block is exception handler for */
532 s4 expredecessorcount;
533 s4 exouts; /* Number of exceptional exits */
535 instruction *phis; /* Phi functions */
536 s4 phicount; /* Number of phi functions */
538 void *vp; /* Freely used by different passes */
542 #define FOR_EACH_SUCCESSOR(bptr, it) \
543 for ((it) = (bptr)->successors; (it) != (bptr)->successors + (bptr)->successorcount; ++(it))
545 #define FOR_EACH_PREDECESSOR(bptr, it) \
547 (it) = (bptr)->predecessors; \
548 (it) != (bptr)->predecessors + ((bptr)->predecessorcount < 0 ? 0 : (bptr)->predecessorcount); \
552 #define FOR_EACH_INSTRUCTION(bptr, it) \
553 for ((it) = (bptr)->iinstr; (it) != (bptr)->iinstr + (bptr)->icount; ++(it))
555 #define FOR_EACH_INSTRUCTION_REV(bptr, it) \
556 for ((it) = (bptr)->iinstr + (bptr)->icount - 1; (it) != (bptr)->iinstr - 1; --(it))
558 #if defined(ENABLE_SSA)
560 #define FOR_EACH_EXHANDLER(bptr, it) \
561 for ((it) = (bptr)->exhandlers; (it) != (bptr)->exhandlers + (bptr)->exhandlercount; ++(it))
563 #define FOR_EACH_EXPREDECESSOR(bptr, it) \
564 for ((it) = (bptr)->expredecessors; (it) != (bptr)->expredecessors + (bptr)->expredecessorcount; ++(it))
568 /* [+]...the javalocals array: This array is indexed by the javaindex (the */
569 /* local variable index ocurring in the original bytecode). An element */
570 /* javalocals[javaindex] encodes where to find the contents of the */
571 /* original variable at this point in the program. */
572 /* There are three cases for javalocals[javaindex]: */
573 /* >= 0.......it's an index into the jd->var array, where the */
574 /* CACAO variable corresponding to the original local */
576 /* UNUSED.....the original variable is not live at this point */
577 /* < UNUSED...the original variable contains a returnAddress at */
578 /* this point. The number of the block to return to can */
579 /* be calculated using RETADDR_FROM_JAVALOCAL: */
581 /* javalocals[javaindex] == JAVALOCAL_FROM_RETADDR(nr) */
582 /* RETADDR_FROM_JAVALOCAL(javalocals[javaindex]) == nr */
584 #define JAVALOCAL_FROM_RETADDR(nr) (UNUSED - (1 + (nr)))
585 #define RETADDR_FROM_JAVALOCAL(jl) (UNUSED - (1 + (jl)))
588 /* Macro for initializing newly allocated basic block's. It does not
589 need to zero fields, as we zero out the whole basic block array. */
591 #define BASICBLOCK_INIT(bptr,m) \
595 bptr->type = BBTYPE_STD; \
596 bptr->method = (m); \
599 static inline bool basicblock_reached(const basicblock *bptr) {
600 return (bptr->flags >= BBREACHED);
603 /* data-flow constants for the ICMD table ************************************/
610 #define DF_DST_BASE 4 /* from this value on, iptr->dst is a variable */
612 #define DF_0_TO_1 (DF_DST_BASE + 0)
613 #define DF_1_TO_1 (DF_DST_BASE + 1)
614 #define DF_2_TO_1 (DF_DST_BASE + 2)
615 #define DF_3_TO_1 (DF_DST_BASE + 3)
616 #define DF_N_TO_1 (DF_DST_BASE + 4)
618 #define DF_INVOKE (DF_DST_BASE + 5)
619 #define DF_BUILTIN (DF_DST_BASE + 6)
621 #define DF_COPY (DF_DST_BASE + 7)
622 #define DF_MOVE (DF_DST_BASE + 8)
628 #define DF_DUP2_X1 -1
629 #define DF_DUP2_X2 -1
632 /* special data-flow recognized by verify/generate.pl: */
633 #define DF_LOAD DF_COPY
634 #define DF_STORE DF_MOVE
635 #define DF_IINC DF_1_TO_1
636 #define DF_POP DF_1_TO_0
637 #define DF_POP2 DF_2_TO_0
640 /* control-flow constants for the ICMD table *********************************/
645 #define CF_END_BASE 2 /* from here on, they mark the end of a superblock */
647 #define CF_END (CF_END_BASE + 0)
648 #define CF_GOTO (CF_END_BASE + 1)
649 #define CF_TABLE (CF_END_BASE + 2)
650 #define CF_LOOKUP (CF_END_BASE + 3)
651 #define CF_JSR (CF_END_BASE + 4)
652 #define CF_RET (CF_END_BASE + 5)
655 /* flag constants for the ICMD table *****************************************/
657 #define ICMDTABLE_PEI 0x0001 /* ICMD may throw an exception */
658 #define ICMDTABLE_CALLS 0x0002 /* needs registers to be saved, may call */
661 /* ICMD table entry **********************************************************/
663 typedef struct icmdtable_entry_t icmdtable_entry_t;
665 struct icmdtable_entry_t {
667 char *name; /* name, without ICMD_ prefix */
669 s4 dataflow; /* a DF_ constant, see above */
670 s4 controlflow; /* a CF_ constant, see above */
671 s4 flags; /* a combination of ICMDTABLE_ flags */
675 /* the ICMD table ************************************************************/
677 extern icmdtable_entry_t icmd_table[256];
680 /********** JavaVM operation codes (sorted) and instruction lengths ***********/
685 ICMD_ACONST = BC_aconst_null,
689 ICMD_ICONST = BC_iconst_0,
700 ICMD_LCONST = BC_lconst_0,
704 ICMD_FCONST = BC_fconst_0,
709 ICMD_DCONST = BC_dconst_0,
719 /* Order of LOAD instructions must be equal to order of TYPE_*
722 ICMD_ILOAD = BC_iload,
723 ICMD_LLOAD = BC_lload,
724 ICMD_FLOAD = BC_fload,
725 ICMD_DLOAD = BC_dload,
726 ICMD_ALOAD = BC_aload,
737 ICMD_IUSHRCONST = 34,
750 ICMD_LUSHRCONST = 44,
754 ICMD_IALOAD = BC_iaload,
755 ICMD_LALOAD = BC_laload,
756 ICMD_FALOAD = BC_faload,
757 ICMD_DALOAD = BC_daload,
758 ICMD_AALOAD = BC_aaload,
759 ICMD_BALOAD = BC_baload,
760 ICMD_CALOAD = BC_caload,
761 ICMD_SALOAD = BC_saload,
763 /* Order of STORE instructions must be equal to order of TYPE_*
766 ICMD_ISTORE = BC_istore,
767 ICMD_LSTORE = BC_lstore,
768 ICMD_FSTORE = BC_fstore,
769 ICMD_DSTORE = BC_dstore,
770 ICMD_ASTORE = BC_astore,
795 ICMD_IASTORE = BC_iastore,
796 ICMD_LASTORE = BC_lastore,
797 ICMD_FASTORE = BC_fastore,
798 ICMD_DASTORE = BC_dastore,
799 ICMD_AASTORE = BC_aastore,
800 ICMD_BASTORE = BC_bastore,
801 ICMD_CASTORE = BC_castore,
802 ICMD_SASTORE = BC_sastore,
807 ICMD_DUP_X1 = BC_dup_x1,
808 ICMD_DUP_X2 = BC_dup_x2,
810 ICMD_DUP2_X1 = BC_dup2_x1,
811 ICMD_DUP2_X2 = BC_dup2_x2,
848 ICMD_IUSHR = BC_iushr,
849 ICMD_LUSHR = BC_lushr,
873 ICMD_INT2BYTE = BC_int2byte,
874 ICMD_INT2CHAR = BC_int2char,
875 ICMD_INT2SHORT = BC_int2short,
878 ICMD_FCMPL = BC_fcmpl,
879 ICMD_FCMPG = BC_fcmpg,
880 ICMD_DCMPL = BC_dcmpl,
881 ICMD_DCMPG = BC_dcmpg,
890 ICMD_IF_ICMPEQ = BC_if_icmpeq,
891 ICMD_IF_ICMPNE = BC_if_icmpne,
892 ICMD_IF_ICMPLT = BC_if_icmplt,
893 ICMD_IF_ICMPGE = BC_if_icmpge,
894 ICMD_IF_ICMPGT = BC_if_icmpgt,
895 ICMD_IF_ICMPLE = BC_if_icmple,
896 ICMD_IF_ACMPEQ = BC_if_acmpeq,
897 ICMD_IF_ACMPNE = BC_if_acmpne,
903 ICMD_TABLESWITCH = BC_tableswitch,
904 ICMD_LOOKUPSWITCH = BC_lookupswitch,
906 ICMD_IRETURN = BC_ireturn,
907 ICMD_LRETURN = BC_lreturn,
908 ICMD_FRETURN = BC_freturn,
909 ICMD_DRETURN = BC_dreturn,
910 ICMD_ARETURN = BC_areturn,
911 ICMD_RETURN = BC_return,
913 ICMD_GETSTATIC = BC_getstatic,
914 ICMD_PUTSTATIC = BC_putstatic,
915 ICMD_GETFIELD = BC_getfield,
916 ICMD_PUTFIELD = BC_putfield,
918 ICMD_INVOKEVIRTUAL = BC_invokevirtual,
919 ICMD_INVOKESPECIAL = BC_invokespecial,
920 ICMD_INVOKESTATIC = BC_invokestatic,
921 ICMD_INVOKEINTERFACE = BC_invokeinterface,
926 ICMD_NEWARRAY = BC_newarray,
927 ICMD_ANEWARRAY = BC_anewarray,
929 ICMD_ARRAYLENGTH = BC_arraylength,
931 ICMD_ATHROW = BC_athrow,
933 ICMD_CHECKCAST = BC_checkcast,
934 ICMD_INSTANCEOF = BC_instanceof,
936 ICMD_MONITORENTER = BC_monitorenter,
937 ICMD_MONITOREXIT = BC_monitorexit,
941 ICMD_MULTIANEWARRAY = BC_multianewarray,
943 ICMD_IFNULL = BC_ifnull,
944 ICMD_IFNONNULL = BC_ifnonnull,
950 ICMD_IASTORECONST = 204,
951 ICMD_LASTORECONST = 205,
952 ICMD_FASTORECONST = 206,
953 ICMD_DASTORECONST = 207,
954 ICMD_AASTORECONST = 208,
955 ICMD_BASTORECONST = 209,
956 ICMD_CASTORECONST = 210,
957 ICMD_SASTORECONST = 211,
959 ICMD_PUTSTATICCONST = 212,
960 ICMD_PUTFIELDCONST = 213,
965 ICMD_GETEXCEPTION = 249,
968 ICMD_INLINE_START = 251, /* instruction before inlined method */
969 ICMD_INLINE_END = 252, /* instruction after inlined method */
970 ICMD_INLINE_BODY = 253, /* start of inlined body */
972 ICMD_BUILTIN = 255 /* internal opcode */
975 /* Additional instruction accessors */
977 methoddesc *instruction_call_site(const instruction *iptr);
979 static inline bool instruction_has_dst(const instruction *iptr) {
981 (icmd_table[iptr->opc].dataflow == DF_INVOKE) ||
982 (icmd_table[iptr->opc].dataflow == DF_BUILTIN)
984 return instruction_call_site(iptr)->returntype.type != TYPE_VOID;
986 return icmd_table[iptr->opc].dataflow >= DF_DST_BASE;
990 /***************************** register types *********************************/
992 #define REG_RES 0 /* reserved register for OS or code generator */
993 #define REG_RET 1 /* return value register */
994 #define REG_EXC 2 /* exception value register */
995 #define REG_SAV 3 /* (callee) saved register */
996 #define REG_TMP 4 /* scratch temporary register (caller saved) */
997 #define REG_ARG 5 /* argument register (caller saved) */
999 #define REG_END -1 /* last entry in tables */
1001 #define PARAMMODE_NUMBERED 0
1002 #define PARAMMODE_STUFFED 1
1005 /* function prototypes ********************************************************/
1007 /* compiler initialisation */
1008 void jit_init(void);
1010 /* compiler finalisation */
1011 void jit_close(void);
1013 /* create a new jitdata */
1014 jitdata *jit_jitdata_new(methodinfo *m);
1016 /* compile a method with jit compiler */
1017 u1 *jit_compile(methodinfo *m);
1018 u1 *jit_recompile(methodinfo *m);
1020 void jit_invalidate_code(methodinfo *m);
1021 codeinfo *jit_get_current_code(methodinfo *m);
1022 void jit_request_optimization(methodinfo *m);
1024 /* patch the method entrypoint */
1025 #if !defined(JIT_COMPILER_VIA_SIGNAL)
1026 u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra);
1028 void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr);
1030 s4 jit_complement_condition(s4 opcode);
1032 void jit_renumber_basicblocks(jitdata *jd);
1033 #if !defined(NDEBUG)
1034 void jit_check_basicblock_numbers(jitdata *jd);
1038 /* machine dependent functions ************************************************/
1040 #if defined(ENABLE_JIT)
1044 #if defined(ENABLE_INTRP)
1045 void intrp_md_init(void);
1048 void *md_jit_method_patch_address(void *pv, void *ra, void *mptr);
1054 * These are local overrides for various environment variables in Emacs.
1055 * Please do not remove this and leave it at the end of the file, where
1056 * Emacs will automagically detect them.
1057 * ---------------------------------------------------------------------
1060 * indent-tabs-mode: t
1064 * vim:noexpandtab:sw=4:ts=4: