1 /* jit/jit.h - code generation header
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
5 M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
6 P. Tomsich, J. Wenninger
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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Andreas Krall
30 Changes: Christian Thalinger
32 $Id: jit.h 557 2003-11-02 22:51:59Z twisti $
41 #include "toolbox/chain.h"
44 /**************************** resolve typedef-cycles **************************/
46 typedef struct stackelement stackelement;
47 typedef stackelement *stackptr;
48 typedef struct basicblock basicblock;
49 typedef struct instruction instruction;
50 typedef struct subroutineinfo subroutineinfo;
51 typedef struct varinfo varinfo;
52 typedef struct branchref branchref;
53 typedef struct jumpref jumpref;
54 typedef struct dataref dataref;
55 typedef varinfo *varinfoptr;
58 /************************** stack element structure ***************************/
62 #define TYPE_INT 0 /* the stack slot types must numbered in the */
63 #define TYPE_LNG 1 /* same order as the ICMD_Ixxx to ICMD_Axxx */
64 #define TYPE_FLT 2 /* instructions (LOAD and STORE) */
65 #define TYPE_DBL 3 /* integer, long, float, double, address */
68 #define IS_INT_LNG_TYPE(a) (!((a)&TYPE_FLT))
69 #define IS_FLT_DBL_TYPE(a) ((a)&TYPE_FLT)
70 #define IS_2_WORD_TYPE(a) ((a)&TYPE_LNG)
75 #define SAVEDVAR 1 /* variable has to survive method invocations */
76 #define INMEMORY 2 /* variable stored in memory */
77 #define SAVEDTMP 4 /* temporary variable using a saved register */
81 #define UNDEFVAR 0 /* stack slot will become temp during regalloc*/
82 #define TEMPVAR 1 /* stack slot is temp register */
83 #define STACKVAR 2 /* stack slot is numbered stack slot */
84 #define LOCALVAR 3 /* stack slot is local variable */
85 #define ARGVAR 4 /* stack slot is argument variable */
89 stackptr prev; /* pointer to next element towards bottom */
90 int type; /* slot type of stack element */
91 int flags; /* flags (SAVED, INMEMORY) */
92 int varkind; /* kind of variable or register */
93 int varnum; /* number of variable */
94 int regoff; /* register number or memory offset */
98 /**************************** instruction structure ***************************/
101 stackptr dst; /* stack index of destination operand stack */
102 u2 opc; /* opcode of intermediate code command */
103 s4 op1; /* first operand, usually variable number */
106 s4 i; /* integer operand */
107 s8 l; /* long operand */
108 float f; /* float operand */
109 double d; /* double operand */
110 void *a; /* address operand */
111 } val; /* immediate constant */
113 void *target; /* used for targets of branches and jumps */
114 /* and as address for list of targets for */
119 /**************************** basic block structure ***************************/
128 #define BBTYPE_STD 0 /* standard basic block type */
129 #define BBTYPE_EXH 1 /* exception handler basic block type */
130 #define BBTYPE_SBR 2 /* subroutine basic block type */
133 int flags; /* used during stack analysis, init with -1 */
134 int type; /* basic block type (std, xhandler, subroutine*/
135 instruction *iinstr; /* pointer to intermediate code instructions */
136 int icount; /* number of intermediate code instructions */
137 int mpc; /* machine code pc at start of block */
138 stackptr instack; /* stack at begin of basic block */
139 stackptr outstack; /* stack at end of basic block */
140 int indepth; /* stack depth at begin of basic block */
141 int outdepth; /* stack depth end of basic block */
142 int pre_count; /* count of predecessor basic blocks */
143 branchref *branchrefs; /* list of branches to be patched */
145 basicblock *next; /* used to build a BB list (instead of array) */
146 int lflags; /* used during loop copying, init with 0 */
147 basicblock *copied_to; /* points to the copy of this basic block */
148 /* when loop nodes are copied */
153 /************************* pseudo variable structure **************************/
156 int type; /* basic type of variable */
157 int flags; /* flags (SAVED, INMEMORY) */
158 int regoff; /* register number or memory offset */
161 typedef varinfo varinfo5[5];
164 /***************** forward references in branch instructions ******************/
167 s4 branchpos; /* patching position in code segment */
168 branchref *next; /* next element in branchref list */
172 /******************** forward references in tables ***************************/
175 s4 tablepos; /* patching position in data segment */
176 basicblock *target; /* target basic block */
177 jumpref *next; /* next element in jumpref list */
182 u1 *pos; /* patching position in generated code */
183 dataref *next; /* next element in dataref list */
187 /********** JavaVM operation codes (sorted) and instruction lengths ***********/
189 extern char *icmd_names[256];
190 extern char *opcode_names[256];
191 extern int jcommandsize[256];
196 #define JAVA_ACONST_NULL 1
197 #define ICMD_ACONST 1 /* val.a = constant */
199 #define JAVA_ICONST_M1 2
200 #define ICMD_NULLCHECKPOP 2
202 #define JAVA_ICONST_0 3
203 #define ICMD_ICONST 3 /* val.i = constant */
205 #define JAVA_ICONST_1 4
206 #define ICMD_IREM0X10001 4
208 #define JAVA_ICONST_2 5
209 #define ICMD_IDIVPOW2 5 /* val.i = constant */
211 #define JAVA_ICONST_3 6
212 #define ICMD_LDIVPOW2 6 /* val.l = constant */
214 #define JAVA_ICONST_4 7
216 #define JAVA_ICONST_5 8
217 #define ICMD_LREM0X10001 8
219 #define JAVA_LCONST_0 9
220 #define ICMD_LCONST 9 /* val.l = constant */
222 #define JAVA_LCONST_1 10
223 #define ICMD_LCMPCONST 10 /* val.l = constant */
225 #define JAVA_FCONST_0 11
226 #define ICMD_FCONST 11 /* val.f = constant */
228 #define JAVA_FCONST_1 12
230 #define JAVA_FCONST_2 13
231 #define ICMD_ELSE_ICONST 13
233 #define JAVA_DCONST_0 14
234 #define ICMD_DCONST 14 /* val.d = constant */
236 #define JAVA_DCONST_1 15
237 #define ICMD_IFEQ_ICONST 15
239 #define JAVA_BIPUSH 16
240 #define ICMD_IFNE_ICONST 16
242 #define JAVA_SIPUSH 17
243 #define ICMD_IFLT_ICONST 17
246 #define ICMD_IFGE_ICONST 18
249 #define ICMD_IFGT_ICONST 19
251 #define JAVA_LDC2W 20
252 #define ICMD_IFLE_ICONST 20
254 /* order of LOAD instructions must be */
255 /* equal to order of TYPE_XXX defines */
256 #define JAVA_ILOAD 21
257 #define ICMD_ILOAD 21 /* op1 = local variable */
259 #define JAVA_LLOAD 22
260 #define ICMD_LLOAD 22 /* op1 = local variable */
262 #define JAVA_FLOAD 23
263 #define ICMD_FLOAD 23 /* op1 = local variable */
265 #define JAVA_DLOAD 24
266 #define ICMD_DLOAD 24 /* op1 = local variable */
268 #define JAVA_ALOAD 25
269 #define ICMD_ALOAD 25 /* op1 = local variable */
271 #define JAVA_ILOAD_0 26
272 #define ICMD_IADDCONST 26 /* val.i = constant */
274 #define JAVA_ILOAD_1 27
275 #define ICMD_ISUBCONST 27 /* val.i = constant */
277 #define JAVA_ILOAD_2 28
278 #define ICMD_IMULCONST 28 /* val.i = constant */
280 #define JAVA_ILOAD_3 29
281 #define ICMD_IANDCONST 29 /* val.i = constant */
283 #define JAVA_LLOAD_0 30
284 #define ICMD_IORCONST 30 /* val.i = constant */
286 #define JAVA_LLOAD_1 31
287 #define ICMD_IXORCONST 31 /* val.i = constant */
289 #define JAVA_LLOAD_2 32
290 #define ICMD_ISHLCONST 32 /* val.i = constant */
292 #define JAVA_LLOAD_3 33
293 #define ICMD_ISHRCONST 33 /* val.i = constant */
295 #define JAVA_FLOAD_0 34
296 #define ICMD_IUSHRCONST 34 /* val.i = constant */
298 #define JAVA_FLOAD_1 35
299 #define ICMD_IREMPOW2 35 /* val.i = constant */
301 #define JAVA_FLOAD_2 36
302 #define ICMD_LADDCONST 36 /* val.l = constant */
304 #define JAVA_FLOAD_3 37
305 #define ICMD_LSUBCONST 37 /* val.l = constant */
307 #define JAVA_DLOAD_0 38
308 #define ICMD_LMULCONST 38 /* val.l = constant */
310 #define JAVA_DLOAD_1 39
311 #define ICMD_LANDCONST 39 /* val.l = constant */
313 #define JAVA_DLOAD_2 40
314 #define ICMD_LORCONST 40 /* val.l = constant */
316 #define JAVA_DLOAD_3 41
317 #define ICMD_LXORCONST 41 /* val.l = constant */
319 #define JAVA_ALOAD_0 42
320 #define ICMD_LSHLCONST 42 /* val.l = constant */
322 #define JAVA_ALOAD_1 43
323 #define ICMD_LSHRCONST 43 /* val.l = constant */
325 #define JAVA_ALOAD_2 44
326 #define ICMD_LUSHRCONST 44 /* val.l = constant */
328 #define JAVA_ALOAD_3 45
329 #define ICMD_LREMPOW2 45 /* val.l = constant */
331 #define JAVA_IALOAD 46
332 #define ICMD_IALOAD 46
334 #define JAVA_LALOAD 47
335 #define ICMD_LALOAD 47
337 #define JAVA_FALOAD 48
338 #define ICMD_FALOAD 48
340 #define JAVA_DALOAD 49
341 #define ICMD_DALOAD 49
343 #define JAVA_AALOAD 50
344 #define ICMD_AALOAD 50
346 #define JAVA_BALOAD 51
347 #define ICMD_BALOAD 51
349 #define JAVA_CALOAD 52
350 #define ICMD_CALOAD 52
352 #define JAVA_SALOAD 53
353 #define ICMD_SALOAD 53
355 /* order of STORE instructions must be*/
356 /* equal to order of TYPE_XXX defines */
357 #define JAVA_ISTORE 54
358 #define ICMD_ISTORE 54 /* op1 = local variable */
360 #define JAVA_LSTORE 55
361 #define ICMD_LSTORE 55 /* op1 = local variable */
363 #define JAVA_FSTORE 56
364 #define ICMD_FSTORE 56 /* op1 = local variable */
366 #define JAVA_DSTORE 57
367 #define ICMD_DSTORE 57 /* op1 = local variable */
369 #define JAVA_ASTORE 58
370 #define ICMD_ASTORE 58 /* op1 = local variable */
372 #define JAVA_ISTORE_0 59
373 #define ICMD_IF_LEQ 59 /* op1 = target JavaVM pc, val.l */
375 #define JAVA_ISTORE_1 60
376 #define ICMD_IF_LNE 60 /* op1 = target JavaVM pc, val.l */
378 #define JAVA_ISTORE_2 61
379 #define ICMD_IF_LLT 61 /* op1 = target JavaVM pc, val.l */
381 #define JAVA_ISTORE_3 62
382 #define ICMD_IF_LGE 62 /* op1 = target JavaVM pc, val.l */
384 #define JAVA_LSTORE_0 63
385 #define ICMD_IF_LGT 63 /* op1 = target JavaVM pc, val.l */
387 #define JAVA_LSTORE_1 64
388 #define ICMD_IF_LLE 64 /* op1 = target JavaVM pc, val.l */
390 #define JAVA_LSTORE_2 65
391 #define ICMD_IF_LCMPEQ 65 /* op1 = target JavaVM pc */
393 #define JAVA_LSTORE_3 66
394 #define ICMD_IF_LCMPNE 66 /* op1 = target JavaVM pc */
396 #define JAVA_FSTORE_0 67
397 #define ICMD_IF_LCMPLT 67 /* op1 = target JavaVM pc */
399 #define JAVA_FSTORE_1 68
400 #define ICMD_IF_LCMPGE 68 /* op1 = target JavaVM pc */
402 #define JAVA_FSTORE_2 69
403 #define ICMD_IF_LCMPGT 69 /* op1 = target JavaVM pc */
405 #define JAVA_FSTORE_3 70
406 #define ICMD_IF_LCMPLE 70 /* op1 = target JavaVM pc */
408 #define JAVA_DSTORE_0 71
410 #define JAVA_DSTORE_1 72
412 #define JAVA_DSTORE_2 73
414 #define JAVA_DSTORE_3 74
416 #define JAVA_ASTORE_0 75
418 #define JAVA_ASTORE_1 76
420 #define JAVA_ASTORE_2 77
422 #define JAVA_ASTORE_3 78
424 #define JAVA_IASTORE 79
425 #define ICMD_IASTORE 79
427 #define JAVA_LASTORE 80
428 #define ICMD_LASTORE 80
430 #define JAVA_FASTORE 81
431 #define ICMD_FASTORE 81
433 #define JAVA_DASTORE 82
434 #define ICMD_DASTORE 82
436 #define JAVA_AASTORE 83
437 #define ICMD_AASTORE 83
439 #define JAVA_BASTORE 84
440 #define ICMD_BASTORE 84
442 #define JAVA_CASTORE 85
443 #define ICMD_CASTORE 85
445 #define JAVA_SASTORE 86
446 #define ICMD_SASTORE 86
457 #define JAVA_DUP_X1 90
458 #define ICMD_DUP_X1 90
460 #define JAVA_DUP_X2 91
461 #define ICMD_DUP_X2 91
466 #define JAVA_DUP2_X1 93
467 #define ICMD_DUP2_X1 93
469 #define JAVA_DUP2_X2 94
470 #define ICMD_DUP2_X2 94
487 #define JAVA_ISUB 100
488 #define ICMD_ISUB 100
490 #define JAVA_LSUB 101
491 #define ICMD_LSUB 101
493 #define JAVA_FSUB 102
494 #define ICMD_FSUB 102
496 #define JAVA_DSUB 103
497 #define ICMD_DSUB 103
499 #define JAVA_IMUL 104
500 #define ICMD_IMUL 104
502 #define JAVA_LMUL 105
503 #define ICMD_LMUL 105
505 #define JAVA_FMUL 106
506 #define ICMD_FMUL 106
508 #define JAVA_DMUL 107
509 #define ICMD_DMUL 107
511 #define JAVA_IDIV 108
512 #define ICMD_IDIV 108
514 #define JAVA_LDIV 109
515 #define ICMD_LDIV 109
517 #define JAVA_FDIV 110
518 #define ICMD_FDIV 110
520 #define JAVA_DDIV 111
521 #define ICMD_DDIV 111
523 #define JAVA_IREM 112
524 #define ICMD_IREM 112
526 #define JAVA_LREM 113
527 #define ICMD_LREM 113
529 #define JAVA_FREM 114
530 #define ICMD_FREM 114
532 #define JAVA_DREM 115
533 #define ICMD_DREM 115
535 #define JAVA_INEG 116
536 #define ICMD_INEG 116
538 #define JAVA_LNEG 117
539 #define ICMD_LNEG 117
541 #define JAVA_FNEG 118
542 #define ICMD_FNEG 118
544 #define JAVA_DNEG 119
545 #define ICMD_DNEG 119
547 #define JAVA_ISHL 120
548 #define ICMD_ISHL 120
550 #define JAVA_LSHL 121
551 #define ICMD_LSHL 121
553 #define JAVA_ISHR 122
554 #define ICMD_ISHR 122
556 #define JAVA_LSHR 123
557 #define ICMD_LSHR 123
559 #define JAVA_IUSHR 124
560 #define ICMD_IUSHR 124
562 #define JAVA_LUSHR 125
563 #define ICMD_LUSHR 125
565 #define JAVA_IAND 126
566 #define ICMD_IAND 126
568 #define JAVA_LAND 127
569 #define ICMD_LAND 127
577 #define JAVA_IXOR 130
578 #define ICMD_IXOR 130
580 #define JAVA_LXOR 131
581 #define ICMD_LXOR 131
583 #define JAVA_IINC 132
584 #define ICMD_IINC 132 /* op1 = local variable, val.i = constant */
622 #define JAVA_INT2BYTE 145
623 #define ICMD_INT2BYTE 145
625 #define JAVA_INT2CHAR 146
626 #define ICMD_INT2CHAR 146
628 #define JAVA_INT2SHORT 147
629 #define ICMD_INT2SHORT 147
631 #define JAVA_LCMP 148
632 #define ICMD_LCMP 148
634 #define JAVA_FCMPL 149
635 #define ICMD_FCMPL 149
637 #define JAVA_FCMPG 150
638 #define ICMD_FCMPG 150
640 #define JAVA_DCMPL 151
641 #define ICMD_DCMPL 151
643 #define JAVA_DCMPG 152
644 #define ICMD_DCMPG 152
646 #define JAVA_IFEQ 153
647 #define ICMD_IFEQ 153 /* op1 = target JavaVM pc, val.i */
649 #define JAVA_IFNE 154
650 #define ICMD_IFNE 154 /* op1 = target JavaVM pc, val.i */
652 #define JAVA_IFLT 155
653 #define ICMD_IFLT 155 /* op1 = target JavaVM pc, val.i */
655 #define JAVA_IFGE 156
656 #define ICMD_IFGE 156 /* op1 = target JavaVM pc, val.i */
658 #define JAVA_IFGT 157
659 #define ICMD_IFGT 157 /* op1 = target JavaVM pc, val.i */
661 #define JAVA_IFLE 158
662 #define ICMD_IFLE 158 /* op1 = target JavaVM pc, val.i */
664 #define JAVA_IF_ICMPEQ 159
665 #define ICMD_IF_ICMPEQ 159 /* op1 = target JavaVM pc */
667 #define JAVA_IF_ICMPNE 160
668 #define ICMD_IF_ICMPNE 160 /* op1 = target JavaVM pc */
670 #define JAVA_IF_ICMPLT 161
671 #define ICMD_IF_ICMPLT 161 /* op1 = target JavaVM pc */
673 #define JAVA_IF_ICMPGE 162
674 #define ICMD_IF_ICMPGE 162 /* op1 = target JavaVM pc */
676 #define JAVA_IF_ICMPGT 163
677 #define ICMD_IF_ICMPGT 163 /* op1 = target JavaVM pc */
679 #define JAVA_IF_ICMPLE 164
680 #define ICMD_IF_ICMPLE 164 /* op1 = target JavaVM pc */
682 #define JAVA_IF_ACMPEQ 165
683 #define ICMD_IF_ACMPEQ 165 /* op1 = target JavaVM pc */
685 #define JAVA_IF_ACMPNE 166
686 #define ICMD_IF_ACMPNE 166 /* op1 = target JavaVM pc */
688 #define JAVA_GOTO 167
689 #define ICMD_GOTO 167 /* op1 = target JavaVM pc */
692 #define ICMD_JSR 168 /* op1 = target JavaVM pc */
695 #define ICMD_RET 169 /* op1 = local variable */
697 #define JAVA_TABLESWITCH 170
698 #define ICMD_TABLESWITCH 170 /* val.a = pointer to s4 table */
699 /* length must be computed */
700 #define JAVA_LOOKUPSWITCH 171
701 #define ICMD_LOOKUPSWITCH 171 /* val.a = pointer to s4 table */
702 /* length must be computed */
703 #define JAVA_IRETURN 172
704 #define ICMD_IRETURN 172
706 #define JAVA_LRETURN 173
707 #define ICMD_LRETURN 173
709 #define JAVA_FRETURN 174
710 #define ICMD_FRETURN 174
712 #define JAVA_DRETURN 175
713 #define ICMD_DRETURN 175
715 #define JAVA_ARETURN 176
716 #define ICMD_ARETURN 176
718 #define JAVA_RETURN 177
719 #define ICMD_RETURN 177
721 #define JAVA_GETSTATIC 178
722 #define ICMD_GETSTATIC 178 /* op1 = type, val.a = field address */
724 #define JAVA_PUTSTATIC 179
725 #define ICMD_PUTSTATIC 179 /* op1 = type, val.a = field address */
727 #define JAVA_GETFIELD 180
728 #define ICMD_GETFIELD 180 /* op1 = type, val.i = field offset */
730 #define JAVA_PUTFIELD 181
731 #define ICMD_PUTFIELD 181 /* op1 = type, val.i = field offset */
733 #define JAVA_INVOKEVIRTUAL 182
734 #define ICMD_INVOKEVIRTUAL 182 /* val.a = method info pointer */
736 #define JAVA_INVOKESPECIAL 183
737 #define ICMD_INVOKESPECIAL 183 /* val.a = method info pointer */
739 #define JAVA_INVOKESTATIC 184
740 #define ICMD_INVOKESTATIC 184 /* val.a = method info pointer */
742 #define JAVA_INVOKEINTERFACE 185
743 #define ICMD_INVOKEINTERFACE 185 /* val.a = method info pointer */
745 #define ICMD_CHECKASIZE 186 /* */
748 #define ICMD_NEW 187 /* op1 = 1, val.a = class pointer */
750 #define JAVA_NEWARRAY 188
751 #define ICMD_NEWARRAY 188 /* op1 = basic type */
753 #define JAVA_ANEWARRAY 189
754 #define ICMD_ANEWARRAY 189 /* op1 = 0, val.a = array pointer */
755 /* op1 = 1, val.a = class pointer */
756 #define JAVA_ARRAYLENGTH 190
757 #define ICMD_ARRAYLENGTH 190
759 #define JAVA_ATHROW 191
760 #define ICMD_ATHROW 191
762 #define JAVA_CHECKCAST 192
763 #define ICMD_CHECKCAST 192 /* op1 = 0, val.a = array pointer */
764 /* op1 = 1, val.a = class pointer */
765 #define JAVA_INSTANCEOF 193
766 #define ICMD_INSTANCEOF 193 /* op1 = 0, val.a = array pointer */
767 /* op1 = 1, val.a = class pointer */
768 #define JAVA_MONITORENTER 194
769 #define ICMD_MONITORENTER 194
771 #define JAVA_MONITOREXIT 195
772 #define ICMD_MONITOREXIT 195
774 #define JAVA_WIDE 196
776 #define JAVA_MULTIANEWARRAY 197
777 #define ICMD_MULTIANEWARRAY 197 /* op1 = dimension, val.a = array */
779 #define JAVA_IFNULL 198
780 #define ICMD_IFNULL 198 /* op1 = target JavaVM pc */
782 #define JAVA_IFNONNULL 199
783 #define ICMD_IFNONNULL 199 /* op1 = target JavaVM pc */
785 #define JAVA_GOTO_W 200
787 #define JAVA_JSR_W 201
789 #define JAVA_BREAKPOINT 202
792 #define ICMD_BUILTIN3 253 /* internal opcode */
793 #define ICMD_BUILTIN2 254 /* internal opcode */
794 #define ICMD_BUILTIN1 255 /* internal opcode */
795 #define ICMD_READONLY_ARG 1024 /* used for inlining, opcodes 1024-1028 are used */
796 #define ICMD_CLEAR_ARGREN 1029 /* indicates the start of a new inlined method argument renaming must be reset */
799 /******************* description of JavaVM instructions ***********************/
801 #if defined(USEBUILTINTABLE)
813 static stdopdescriptor builtintable[] = {
814 { ICMD_LCMP, TYPE_LONG, TYPE_LONG, TYPE_INT, ICMD_BUILTIN2,
815 (functionptr) builtin_lcmp , SUPPORT_LONG && SUPPORT_LONG_CMP, false },
816 { ICMD_LAND, TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2,
817 (functionptr) builtin_land , SUPPORT_LONG && SUPPORT_LONG_LOG, false },
818 { ICMD_LOR, TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2,
819 (functionptr) builtin_lor , SUPPORT_LONG && SUPPORT_LONG_LOG, false },
820 { ICMD_LXOR, TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2,
821 (functionptr) builtin_lxor , SUPPORT_LONG && SUPPORT_LONG_LOG, false },
822 { ICMD_LSHL, TYPE_LONG, TYPE_INT, TYPE_LONG, ICMD_BUILTIN2,
823 (functionptr) builtin_lshl , SUPPORT_LONG && SUPPORT_LONG_SHIFT, false },
824 { ICMD_LSHR, TYPE_LONG, TYPE_INT, TYPE_LONG, ICMD_BUILTIN2,
825 (functionptr) builtin_lshr, SUPPORT_LONG && SUPPORT_LONG_SHIFT, false },
826 { ICMD_LUSHR, TYPE_LONG, TYPE_INT, TYPE_LONG, ICMD_BUILTIN2,
827 (functionptr) builtin_lushr, SUPPORT_LONG && SUPPORT_LONG_SHIFT, false },
828 { ICMD_LADD, TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2,
829 (functionptr) builtin_ladd , SUPPORT_LONG && SUPPORT_LONG_ADD, false },
830 { ICMD_LSUB, TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2,
831 (functionptr) builtin_lsub , SUPPORT_LONG && SUPPORT_LONG_ADD, false },
832 { ICMD_LNEG, TYPE_LONG, TYPE_VOID, TYPE_LONG, ICMD_BUILTIN1,
833 (functionptr) builtin_lneg, SUPPORT_LONG && SUPPORT_LONG_ADD, true },
834 { ICMD_LMUL, TYPE_LONG, TYPE_LONG, TYPE_LONG, ICMD_BUILTIN2,
835 (functionptr) builtin_lmul , SUPPORT_LONG && SUPPORT_LONG_MULDIV, false },
836 { ICMD_FREM, TYPE_FLOAT, TYPE_FLOAT, TYPE_FLOAT, ICMD_BUILTIN2,
837 (functionptr) builtin_frem, SUPPORT_FLOAT && SUPPORT_FMOD, true },
838 { ICMD_DREM, TYPE_DOUBLE, TYPE_DOUBLE, TYPE_DOUBLE, ICMD_BUILTIN2,
839 (functionptr) builtin_drem, SUPPORT_DOUBLE && SUPPORT_FMOD, true },
840 { ICMD_I2F, TYPE_INT, TYPE_VOID, TYPE_FLOAT, ICMD_BUILTIN1,
841 (functionptr) builtin_i2f, SUPPORT_FLOAT && SUPPORT_IFCVT, true },
842 { ICMD_I2D, TYPE_INT, TYPE_VOID, TYPE_DOUBLE, ICMD_BUILTIN1,
843 (functionptr) builtin_i2d, SUPPORT_DOUBLE && SUPPORT_IFCVT, true },
844 { ICMD_L2F, TYPE_LONG, TYPE_VOID, TYPE_FLOAT, ICMD_BUILTIN1,
845 (functionptr) builtin_l2f, SUPPORT_LONG && SUPPORT_FLOAT && SUPPORT_LONG_FCVT, true },
846 { ICMD_L2D, TYPE_LONG, TYPE_VOID, TYPE_DOUBLE, ICMD_BUILTIN1,
847 (functionptr) builtin_l2d, SUPPORT_LONG && SUPPORT_DOUBLE && SUPPORT_LONG_FCVT, true },
848 { ICMD_F2L, TYPE_FLOAT, TYPE_VOID, TYPE_LONG, ICMD_BUILTIN1,
849 (functionptr) builtin_f2l, SUPPORT_FLOAT && SUPPORT_LONG && SUPPORT_LONG_FCVT, true },
850 { ICMD_D2L, TYPE_DOUBLE, TYPE_VOID, TYPE_LONG, ICMD_BUILTIN1,
851 (functionptr) builtin_d2l, SUPPORT_DOUBLE && SUPPORT_LONG && SUPPORT_LONG_FCVT, true },
852 { ICMD_F2I, TYPE_FLOAT, TYPE_VOID, TYPE_INT, ICMD_BUILTIN1,
853 (functionptr) builtin_f2i, SUPPORT_FLOAT && SUPPORT_FICVT, true },
854 { ICMD_D2I, TYPE_DOUBLE, TYPE_VOID, TYPE_INT, ICMD_BUILTIN1,
855 (functionptr) builtin_d2i, SUPPORT_DOUBLE && SUPPORT_FICVT, true },
858 #endif /* USEBUILTINTABLE */
861 /***************************** register types *********************************/
863 #define REG_RES 0 /* reserved register for OS or code generator */
864 #define REG_RET 1 /* return value register */
865 #define REG_EXC 2 /* exception value register */
866 #define REG_SAV 3 /* (callee) saved register */
867 #define REG_TMP 4 /* scratch temporary register (caller saved) */
868 #define REG_ARG 5 /* argument register (caller saved) */
870 #define REG_END -1 /* last entry in tables */
872 #define PARAMMODE_NUMBERED 0
873 #define PARAMMODE_STUFFED 1
876 /***************************** register info block ****************************/
878 extern int nregdescint[]; /* description of integer registers */
879 extern int nregdescfloat[]; /* description of floating point registers */
881 extern int nreg_parammode;
884 /* compiler switches (set by main function) ***********************************/
886 extern bool runverbose; /* trace all method invocation */
887 extern bool compileverbose; /* trace compiler actions */
888 extern bool showdisassemble; /* generate disassembler listing */
889 extern bool showddatasegment; /* generate data segment listing */
890 extern bool showintermediate; /* generate intermediate code listing */
891 extern int optimizelevel; /* optimzation level (0 = no optimization) */
893 extern bool useinlining; /* use method inlining */
894 extern bool inlinevirtuals; /* inline unique virtual methods */
895 extern bool inlineexceptions; /* inline methods, that contain excptions */
896 extern bool inlineparamopt; /* optimize parameter passing to inlined methods */
897 extern bool inlineoutsiders; /* inline methods, that are not member of the invoker's class */
900 extern bool checkbounds; /* check array bounds */
901 extern bool opt_loops; /* optimize array accesses in loops */
902 extern bool checknull; /* check null pointers */
903 extern bool opt_noieee; /* don't implement ieee compliant floats */
904 extern bool checksync; /* do synchronization */
906 extern bool getcompilingtime; /* compute compile time */
907 extern long compilingtime; /* accumulated compile time */
909 extern int has_ext_instr_set; /* has instruction set extensions */
911 extern bool statistics;
913 extern int count_jit_calls;
914 extern int count_methods;
915 extern int count_spills;
916 extern int count_pcmd_activ;
917 extern int count_pcmd_drop;
918 extern int count_pcmd_zero;
919 extern int count_pcmd_const_store;
920 extern int count_pcmd_const_alu;
921 extern int count_pcmd_const_bra;
922 extern int count_pcmd_load;
923 extern int count_pcmd_move;
924 extern int count_load_instruction;
925 extern int count_pcmd_store;
926 extern int count_pcmd_store_comb;
927 extern int count_dup_instruction;
928 extern int count_pcmd_op;
929 extern int count_pcmd_mem;
930 extern int count_pcmd_met;
931 extern int count_pcmd_bra;
932 extern int count_pcmd_table;
933 extern int count_pcmd_return;
934 extern int count_pcmd_returnx;
935 extern int count_check_null;
936 extern int count_check_bound;
937 extern int count_max_basic_blocks;
938 extern int count_basic_blocks;
939 extern int count_max_javainstr;
940 extern int count_javainstr;
941 extern int count_javacodesize;
942 extern int count_javaexcsize;
943 extern int count_calls;
944 extern int count_tryblocks;
945 extern int count_code_len;
946 extern int count_data_len;
947 extern int count_cstub_len;
948 extern int count_nstub_len;
949 extern int count_max_new_stack;
950 extern int count_upper_bound_new_stack;
951 extern int *count_block_stack;
952 extern int *count_analyse_iterations;
953 extern int *count_method_bb_distribution;
954 extern int *count_block_size_distribution;
955 extern int *count_store_length;
956 extern int *count_store_depth;
959 /* global compiler variables */
961 extern classinfo *class; /* class the compiled method belongs to */
962 extern methodinfo *method; /* pointer to method info of compiled method */
963 extern int mparamcount; /* number of parameters (incl. this) */
964 extern u1 *mparamtypes; /* types of all parameters (TYPE_INT, ...) */
966 extern int maxstack; /* maximal JavaVM stack size */
967 extern int maxlocals; /* maximal number of local JavaVM variables */
968 extern int jcodelength; /* length of JavaVM-codes */
969 extern u1 *jcode; /* pointer to start of JavaVM-code */
970 extern int exceptiontablelength;/* length of exception table */
971 extern xtable *extable; /* pointer to start of exception table */
972 extern exceptiontable *raw_extable;
974 extern int block_count; /* number of basic blocks */
975 extern basicblock *block; /* points to basic block array */
976 extern int *block_index; /* a table which contains for every byte of */
977 /* JavaVM code a basic block index if at this */
978 /* byte there is the start of a basic block */
980 extern int instr_count; /* number of JavaVM instructions */
981 extern instruction *instr; /* points to intermediate code instructions */
983 extern int stack_count; /* number of stack elements */
984 extern stackelement *stack; /* points to intermediate code instructions */
986 extern bool isleafmethod; /* true if a method doesn't call subroutines */
988 extern basicblock *last_block; /* points to the end of the BB list */
990 /* list of all classes used by the compiled method which have to be */
991 /* initialised (if not already done) before execution of this method */
992 extern chain *uninitializedclasses;
994 extern int stackreq[256];
997 /* function prototypes */
999 methodptr jit_compile (methodinfo *m); /* compile a method with jit compiler */
1001 void jit_init(); /* compiler initialisation */
1002 void jit_close(); /* compiler finalisation */
1004 u1 *createcompilerstub(methodinfo *m);
1005 u1 *createnativestub(functionptr f, methodinfo *m);
1007 void removecompilerstub(u1 *stub);
1008 void removenativestub(u1 *stub);
1014 * These are local overrides for various environment variables in Emacs.
1015 * Please do not remove this and leave it at the end of the file, where
1016 * Emacs will automagically detect them.
1017 * ---------------------------------------------------------------------
1020 * indent-tabs-mode: t