1 /* jit/stack.c - stack analysis
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
29 $Id: stack.c 614 2003-11-12 21:53:42Z stefan $
42 #include "toolbox/loging.h"
43 #include "toolbox/memory.h"
46 /* from codegen.inc */
51 #define COUNT(cnt) cnt++
56 #define STACKRESET {curstack=0;stackdepth=0;}
58 #define TYPEPANIC {show_icmd_method();panic("Stack type mismatch");}
59 #define CURKIND curstack->varkind
60 #define CURTYPE curstack->type
62 #define NEWSTACK(s,v,n) {new->prev=curstack;new->type=s;new->flags=0;\
63 new->varkind=v;new->varnum=n;curstack=new;new++;}
64 #define NEWSTACKn(s,n) NEWSTACK(s,UNDEFVAR,n)
65 #define NEWSTACK0(s) NEWSTACK(s,UNDEFVAR,0)
66 #define NEWXSTACK {NEWSTACK(TYPE_ADR,STACKVAR,0);curstack=0;}
68 #define SETDST {iptr->dst=curstack;}
69 #define POP(s) {if(s!=curstack->type){TYPEPANIC;}\
70 if(curstack->varkind==UNDEFVAR)curstack->varkind=TEMPVAR;\
71 curstack=curstack->prev;}
72 #define POPANY {if(curstack->varkind==UNDEFVAR)curstack->varkind=TEMPVAR;\
73 curstack=curstack->prev;}
74 #define COPY(s,d) {(d)->flags=0;(d)->type=(s)->type;\
75 (d)->varkind=(s)->varkind;(d)->varnum=(s)->varnum;}
77 #define PUSHCONST(s){NEWSTACKn(s,stackdepth);SETDST;stackdepth++;}
78 #define LOAD(s,v,n) {NEWSTACK(s,v,n);SETDST;stackdepth++;}
79 #define STORE(s) {POP(s);SETDST;stackdepth--;}
80 #define OP1_0(s) {POP(s);SETDST;stackdepth--;}
81 #define OP1_0ANY {POPANY;SETDST;stackdepth--;}
82 #define OP0_1(s) {NEWSTACKn(s,stackdepth);SETDST;stackdepth++;}
83 #define OP1_1(s,d) {POP(s);NEWSTACKn(d,stackdepth-1);SETDST;}
84 #define OP2_0(s) {POP(s);POP(s);SETDST;stackdepth-=2;}
85 #define OPTT2_0(t,b){POP(t);POP(b);SETDST;stackdepth-=2;}
86 #define OP2_1(s) {POP(s);POP(s);NEWSTACKn(s,stackdepth-2);SETDST;stackdepth--;}
87 #define OP2IAT_1(s) {POP(TYPE_INT);POP(TYPE_ADR);NEWSTACKn(s,stackdepth-2);\
89 #define OP2IT_1(s) {POP(TYPE_INT);POP(s);NEWSTACKn(s,stackdepth-2);\
91 #define OPTT2_1(s,d){POP(s);POP(s);NEWSTACKn(d,stackdepth-2);SETDST;stackdepth--;}
92 #define OP2_2(s) {POP(s);POP(s);NEWSTACKn(s,stackdepth-2);\
93 NEWSTACKn(s,stackdepth-1);SETDST;}
94 #define OP3TIA_0(s) {POP(s);POP(TYPE_INT);POP(TYPE_ADR);SETDST;stackdepth-=3;}
95 #define OP3_0(s) {POP(s);POP(s);POP(s);SETDST;stackdepth-=3;}
96 #define POPMANY(i) {stackdepth-=i;while(--i>=0){POPANY;}SETDST;}
97 #define DUP {NEWSTACK(CURTYPE,CURKIND,curstack->varnum);SETDST;\
99 #define SWAP {COPY(curstack,new);POPANY;COPY(curstack,new+1);POPANY;\
100 new[0].prev=curstack;new[1].prev=new;\
101 curstack=new+1;new+=2;SETDST;}
102 #define DUP_X1 {COPY(curstack,new);COPY(curstack,new+2);POPANY;\
103 COPY(curstack,new+1);POPANY;new[0].prev=curstack;\
104 new[1].prev=new;new[2].prev=new+1;\
105 curstack=new+2;new+=3;SETDST;stackdepth++;}
106 #define DUP2_X1 {COPY(curstack,new+1);COPY(curstack,new+4);POPANY;\
107 COPY(curstack,new);COPY(curstack,new+3);POPANY;\
108 COPY(curstack,new+2);POPANY;new[0].prev=curstack;\
109 new[1].prev=new;new[2].prev=new+1;\
110 new[3].prev=new+2;new[4].prev=new+3;\
111 curstack=new+4;new+=5;SETDST;stackdepth+=2;}
112 #define DUP_X2 {COPY(curstack,new);COPY(curstack,new+3);POPANY;\
113 COPY(curstack,new+2);POPANY;COPY(curstack,new+1);POPANY;\
114 new[0].prev=curstack;new[1].prev=new;\
115 new[2].prev=new+1;new[3].prev=new+2;\
116 curstack=new+3;new+=4;SETDST;stackdepth++;}
117 #define DUP2_X2 {COPY(curstack,new+1);COPY(curstack,new+5);POPANY;\
118 COPY(curstack,new);COPY(curstack,new+4);POPANY;\
119 COPY(curstack,new+3);POPANY;COPY(curstack,new+2);POPANY;\
120 new[0].prev=curstack;new[1].prev=new;\
121 new[2].prev=new+1;new[3].prev=new+2;\
122 new[4].prev=new+3;new[5].prev=new+4;\
123 curstack=new+5;new+=6;SETDST;stackdepth+=2;}
125 #define COPYCURSTACK(copy) {\
138 copy->varkind=STACKVAR;\
154 if((copy->varkind==STACKVAR)&&(copy->varnum>i))\
155 copy->varkind=TEMPVAR;\
157 copy->varkind=STACKVAR;\
160 interfaces[i][copy->type].type = copy->type;\
161 interfaces[i][copy->type].flags |= copy->flags;\
162 i--;copy=copy->prev;\
167 interfaces[i][copy->type].type = copy->type;\
168 if(copy->varkind==STACKVAR){\
169 if (copy->flags & SAVEDVAR)\
170 interfaces[i][copy->type].flags |= SAVEDVAR;\
172 i--;copy=copy->prev;\
177 #define MARKREACHED(b,c) {\
179 {COPYCURSTACK(c);b->flags=0;b->instack=c;b->indepth=stackdepth;}\
180 else {stackptr s=curstack;stackptr t=b->instack;\
181 if(b->indepth!=stackdepth)\
182 {show_icmd_method();panic("Stack depth mismatch");}\
183 while(s){if (s->type!=t->type)\
185 s=s->prev;t=t->prev;\
199 int opcode, i, len, loops;
200 int superblockend, repeat, deadcode;
207 int *argren = DMNEW(int, maxlocals);
208 //int *argren = (int *)alloca(maxlocals * sizeof(int)); /* table for argument renaming */
209 for (i = 0; i < maxlocals; i++)
215 block[0].flags = BBREACHED;
216 block[0].instack = 0;
217 block[0].indepth = 0;
219 for (i = 0; i < exceptiontablelength; i++) {
220 bptr = &block[block_index[extable[i].handlerpc]];
221 bptr->flags = BBREACHED;
222 bptr->type = BBTYPE_EXH;
225 bptr->pre_count = 10000;
230 #ifdef CONDITIONAL_LOADCONST
231 b_count = block_count;
233 while (--b_count >= 0) {
234 if (bptr->icount != 0) {
235 iptr = bptr->iinstr + bptr->icount - 1;
268 block[block_index[iptr->op1]].pre_count++;
271 case ICMD_TABLESWITCH:
273 block[block_index[*s4ptr++]].pre_count++; /* default */
274 i = *s4ptr++; /* low */
275 i = *s4ptr++ - i + 1; /* high */
277 block[block_index[*s4ptr++]].pre_count++;
281 case ICMD_LOOKUPSWITCH:
283 block[block_index[*s4ptr++]].pre_count++; /* default */
284 i = *s4ptr++; /* count */
286 block[block_index[s4ptr[1]]].pre_count++;
302 b_count = block_count;
304 superblockend = true;
308 while (--b_count >= 0) {
309 if (bptr->flags == BBDELETED) {
312 else if (superblockend && (bptr->flags < BBREACHED))
314 else if (bptr->flags <= BBREACHED) {
316 stackdepth = bptr->indepth;
317 else if (bptr->flags < BBREACHED) {
319 bptr->instack = copy;
320 bptr->indepth = stackdepth;
322 else if (bptr->indepth != stackdepth) {
324 panic("Stack depth mismatch");
327 curstack = bptr->instack;
329 superblockend = false;
330 bptr->flags = BBFINISHED;
333 b_index = bptr - block;
338 #ifdef USEBUILTINTABLE
340 stdopdescriptor *breplace;
341 breplace = find_builtin(opcode);
343 /* if (breplace != blast && opcode == breplace->opcode && !breplace->supported) { */
344 if (opcode == breplace->opcode && !breplace->supported) {
345 iptr[0].opc = breplace->icmd;
346 iptr[0].op1 = breplace->type_d;
347 iptr[0].val.a = breplace->builtin;
348 isleafmethod = false;
349 switch (breplace->icmd) {
364 case ICMD_CHECKASIZE:
366 case ICMD_IFEQ_ICONST:
367 case ICMD_IFNE_ICONST:
368 case ICMD_IFLT_ICONST:
369 case ICMD_IFGE_ICONST:
370 case ICMD_IFGT_ICONST:
371 case ICMD_IFLE_ICONST:
372 case ICMD_ELSE_ICONST:
377 locals[iptr->op1][TYPE_ADR].type = TYPE_ADR;
379 COUNT(count_pcmd_return);
381 superblockend = true;
384 /* pop 0 push 1 const */
387 COUNT(count_pcmd_load);
389 switch (iptr[1].opc) {
391 iptr[0].opc = ICMD_IADDCONST;
393 iptr[1].opc = ICMD_NOP;
394 OP1_1(TYPE_INT,TYPE_INT);
395 COUNT(count_pcmd_op);
398 iptr[0].opc = ICMD_ISUBCONST;
399 goto icmd_iconst_tail;
401 iptr[0].opc = ICMD_IMULCONST;
402 goto icmd_iconst_tail;
404 if (iptr[0].val.i == 0x00000002)
406 else if (iptr[0].val.i == 0x00000004)
408 else if (iptr[0].val.i == 0x00000008)
410 else if (iptr[0].val.i == 0x00000010)
412 else if (iptr[0].val.i == 0x00000020)
414 else if (iptr[0].val.i == 0x00000040)
416 else if (iptr[0].val.i == 0x00000080)
418 else if (iptr[0].val.i == 0x00000100)
420 else if (iptr[0].val.i == 0x00000200)
422 else if (iptr[0].val.i == 0x00000400)
424 else if (iptr[0].val.i == 0x00000800)
426 else if (iptr[0].val.i == 0x00001000)
428 else if (iptr[0].val.i == 0x00002000)
430 else if (iptr[0].val.i == 0x00004000)
432 else if (iptr[0].val.i == 0x00008000)
434 else if (iptr[0].val.i == 0x00010000)
436 else if (iptr[0].val.i == 0x00020000)
438 else if (iptr[0].val.i == 0x00040000)
440 else if (iptr[0].val.i == 0x00080000)
442 else if (iptr[0].val.i == 0x00100000)
444 else if (iptr[0].val.i == 0x00200000)
446 else if (iptr[0].val.i == 0x00400000)
448 else if (iptr[0].val.i == 0x00800000)
450 else if (iptr[0].val.i == 0x01000000)
452 else if (iptr[0].val.i == 0x02000000)
454 else if (iptr[0].val.i == 0x04000000)
456 else if (iptr[0].val.i == 0x08000000)
458 else if (iptr[0].val.i == 0x10000000)
460 else if (iptr[0].val.i == 0x20000000)
462 else if (iptr[0].val.i == 0x40000000)
464 else if (iptr[0].val.i == 0x80000000)
470 iptr[0].opc = ICMD_IDIVPOW2;
471 goto icmd_iconst_tail;
473 #if !defined(NO_DIV_OPT)
474 if (iptr[0].val.i == 0x10001) {
475 iptr[0].opc = ICMD_IREM0X10001;
476 goto icmd_iconst_tail;
479 if ((iptr[0].val.i == 0x00000002) ||
480 (iptr[0].val.i == 0x00000004) ||
481 (iptr[0].val.i == 0x00000008) ||
482 (iptr[0].val.i == 0x00000010) ||
483 (iptr[0].val.i == 0x00000020) ||
484 (iptr[0].val.i == 0x00000040) ||
485 (iptr[0].val.i == 0x00000080) ||
486 (iptr[0].val.i == 0x00000100) ||
487 (iptr[0].val.i == 0x00000200) ||
488 (iptr[0].val.i == 0x00000400) ||
489 (iptr[0].val.i == 0x00000800) ||
490 (iptr[0].val.i == 0x00001000) ||
491 (iptr[0].val.i == 0x00002000) ||
492 (iptr[0].val.i == 0x00004000) ||
493 (iptr[0].val.i == 0x00008000) ||
494 (iptr[0].val.i == 0x00010000) ||
495 (iptr[0].val.i == 0x00020000) ||
496 (iptr[0].val.i == 0x00040000) ||
497 (iptr[0].val.i == 0x00080000) ||
498 (iptr[0].val.i == 0x00100000) ||
499 (iptr[0].val.i == 0x00200000) ||
500 (iptr[0].val.i == 0x00400000) ||
501 (iptr[0].val.i == 0x00800000) ||
502 (iptr[0].val.i == 0x01000000) ||
503 (iptr[0].val.i == 0x02000000) ||
504 (iptr[0].val.i == 0x04000000) ||
505 (iptr[0].val.i == 0x08000000) ||
506 (iptr[0].val.i == 0x10000000) ||
507 (iptr[0].val.i == 0x20000000) ||
508 (iptr[0].val.i == 0x40000000) ||
509 (iptr[0].val.i == 0x80000000)) {
510 iptr[0].opc = ICMD_IREMPOW2;
512 goto icmd_iconst_tail;
517 iptr[0].opc = ICMD_IANDCONST;
518 goto icmd_iconst_tail;
520 iptr[0].opc = ICMD_IORCONST;
521 goto icmd_iconst_tail;
523 iptr[0].opc = ICMD_IXORCONST;
524 goto icmd_iconst_tail;
526 iptr[0].opc = ICMD_ISHLCONST;
527 goto icmd_iconst_tail;
529 iptr[0].opc = ICMD_ISHRCONST;
530 goto icmd_iconst_tail;
532 iptr[0].opc = ICMD_IUSHRCONST;
533 goto icmd_iconst_tail;
534 #if SUPPORT_LONG_SHIFT
536 iptr[0].opc = ICMD_LSHLCONST;
537 goto icmd_lconst_tail;
539 iptr[0].opc = ICMD_LSHRCONST;
540 goto icmd_lconst_tail;
542 iptr[0].opc = ICMD_LUSHRCONST;
543 goto icmd_lconst_tail;
546 iptr[0].opc = ICMD_IFEQ;
548 iptr[0].op1 = iptr[1].op1;
551 /* iptr[1].opc = ICMD_NOP; */
553 tbptr = block + block_index[iptr->op1];
555 iptr[0].target = (void *) tbptr;
557 MARKREACHED(tbptr, copy);
558 COUNT(count_pcmd_bra);
561 iptr[0].opc = ICMD_IFLT;
562 goto icmd_if_icmp_tail;
564 iptr[0].opc = ICMD_IFLE;
565 goto icmd_if_icmp_tail;
567 iptr[0].opc = ICMD_IFNE;
568 goto icmd_if_icmp_tail;
570 iptr[0].opc = ICMD_IFGT;
571 goto icmd_if_icmp_tail;
573 iptr[0].opc = ICMD_IFGE;
574 goto icmd_if_icmp_tail;
583 COUNT(count_pcmd_load);
585 switch (iptr[1].opc) {
588 iptr[0].opc = ICMD_LADDCONST;
590 iptr[1].opc = ICMD_NOP;
591 OP1_1(TYPE_LNG,TYPE_LNG);
592 COUNT(count_pcmd_op);
595 iptr[0].opc = ICMD_LSUBCONST;
596 goto icmd_lconst_tail;
598 #if SUPPORT_LONG_MULDIV
600 iptr[0].opc = ICMD_LMULCONST;
601 goto icmd_lconst_tail;
603 if (iptr[0].val.l == 0x00000002)
605 else if (iptr[0].val.l == 0x00000004)
607 else if (iptr[0].val.l == 0x00000008)
609 else if (iptr[0].val.l == 0x00000010)
611 else if (iptr[0].val.l == 0x00000020)
613 else if (iptr[0].val.l == 0x00000040)
615 else if (iptr[0].val.l == 0x00000080)
617 else if (iptr[0].val.l == 0x00000100)
619 else if (iptr[0].val.l == 0x00000200)
621 else if (iptr[0].val.l == 0x00000400)
623 else if (iptr[0].val.l == 0x00000800)
625 else if (iptr[0].val.l == 0x00001000)
627 else if (iptr[0].val.l == 0x00002000)
629 else if (iptr[0].val.l == 0x00004000)
631 else if (iptr[0].val.l == 0x00008000)
633 else if (iptr[0].val.l == 0x00010000)
635 else if (iptr[0].val.l == 0x00020000)
637 else if (iptr[0].val.l == 0x00040000)
639 else if (iptr[0].val.l == 0x00080000)
641 else if (iptr[0].val.l == 0x00100000)
643 else if (iptr[0].val.l == 0x00200000)
645 else if (iptr[0].val.l == 0x00400000)
647 else if (iptr[0].val.l == 0x00800000)
649 else if (iptr[0].val.l == 0x01000000)
651 else if (iptr[0].val.l == 0x02000000)
653 else if (iptr[0].val.l == 0x04000000)
655 else if (iptr[0].val.l == 0x08000000)
657 else if (iptr[0].val.l == 0x10000000)
659 else if (iptr[0].val.l == 0x20000000)
661 else if (iptr[0].val.l == 0x40000000)
663 else if (iptr[0].val.l == 0x80000000)
669 iptr[0].opc = ICMD_LDIVPOW2;
670 goto icmd_lconst_tail;
672 #if !defined(NO_DIV_OPT)
673 if (iptr[0].val.l == 0x10001) {
674 iptr[0].opc = ICMD_LREM0X10001;
675 goto icmd_lconst_tail;
678 if ((iptr[0].val.l == 0x00000002) ||
679 (iptr[0].val.l == 0x00000004) ||
680 (iptr[0].val.l == 0x00000008) ||
681 (iptr[0].val.l == 0x00000010) ||
682 (iptr[0].val.l == 0x00000020) ||
683 (iptr[0].val.l == 0x00000040) ||
684 (iptr[0].val.l == 0x00000080) ||
685 (iptr[0].val.l == 0x00000100) ||
686 (iptr[0].val.l == 0x00000200) ||
687 (iptr[0].val.l == 0x00000400) ||
688 (iptr[0].val.l == 0x00000800) ||
689 (iptr[0].val.l == 0x00001000) ||
690 (iptr[0].val.l == 0x00002000) ||
691 (iptr[0].val.l == 0x00004000) ||
692 (iptr[0].val.l == 0x00008000) ||
693 (iptr[0].val.l == 0x00010000) ||
694 (iptr[0].val.l == 0x00020000) ||
695 (iptr[0].val.l == 0x00040000) ||
696 (iptr[0].val.l == 0x00080000) ||
697 (iptr[0].val.l == 0x00100000) ||
698 (iptr[0].val.l == 0x00200000) ||
699 (iptr[0].val.l == 0x00400000) ||
700 (iptr[0].val.l == 0x00800000) ||
701 (iptr[0].val.l == 0x01000000) ||
702 (iptr[0].val.l == 0x02000000) ||
703 (iptr[0].val.l == 0x04000000) ||
704 (iptr[0].val.l == 0x08000000) ||
705 (iptr[0].val.l == 0x10000000) ||
706 (iptr[0].val.l == 0x20000000) ||
707 (iptr[0].val.l == 0x40000000) ||
708 (iptr[0].val.l == 0x80000000)) {
709 iptr[0].opc = ICMD_LREMPOW2;
711 goto icmd_lconst_tail;
718 iptr[0].opc = ICMD_LANDCONST;
719 goto icmd_lconst_tail;
721 iptr[0].opc = ICMD_LORCONST;
722 goto icmd_lconst_tail;
724 iptr[0].opc = ICMD_LXORCONST;
725 goto icmd_lconst_tail;
727 #if !defined(NOLONG_CONDITIONAL)
729 if ((len > 1) && (iptr[2].val.i == 0)) {
730 switch (iptr[2].opc) {
732 iptr[0].opc = ICMD_IF_LEQ;
733 icmd_lconst_lcmp_tail:
734 iptr[0].op1 = iptr[2].op1;
737 /* iptr[1].opc = ICMD_NOP;
738 iptr[2].opc = ICMD_NOP; */
740 tbptr = block + block_index[iptr->op1];
742 iptr[0].target = (void *) tbptr;
744 MARKREACHED(tbptr, copy);
745 COUNT(count_pcmd_bra);
746 COUNT(count_pcmd_op);
749 iptr[0].opc = ICMD_IF_LNE;
750 goto icmd_lconst_lcmp_tail;
752 iptr[0].opc = ICMD_IF_LLT;
753 goto icmd_lconst_lcmp_tail;
755 iptr[0].opc = ICMD_IF_LGT;
756 goto icmd_lconst_lcmp_tail;
758 iptr[0].opc = ICMD_IF_LLE;
759 goto icmd_lconst_lcmp_tail;
761 iptr[0].opc = ICMD_IF_LGE;
762 goto icmd_lconst_lcmp_tail;
765 } /* switch (iptr[2].opc) */
766 } /* if (iptr[2].val.i == 0) */
779 COUNT(count_pcmd_load);
783 COUNT(count_pcmd_load);
787 COUNT(count_pcmd_load);
791 /* pop 0 push 1 load */
798 COUNT(count_load_instruction);
799 i = opcode-ICMD_ILOAD;
800 iptr->op1 = argren[iptr->op1];
801 locals[iptr->op1][i].type = i;
802 LOAD(i, LOCALVAR, iptr->op1);
812 COUNT(count_check_null);
813 COUNT(count_check_bound);
814 COUNT(count_pcmd_mem);
815 OP2IAT_1(opcode-ICMD_IALOAD);
821 COUNT(count_check_null);
822 COUNT(count_check_bound);
823 COUNT(count_pcmd_mem);
827 /* pop 0 push 0 iinc */
833 count_store_depth[10]++;
835 count_store_depth[i]++;
840 if ((copy->varkind == LOCALVAR) &&
841 (copy->varnum == iptr->op1)) {
842 copy->varkind = TEMPVAR;
851 /* pop 1 push 0 store */
860 i = opcode - ICMD_ISTORE;
861 locals[iptr->op1][i].type = i;
866 count_store_length[20]++;
868 count_store_length[i]++;
871 count_store_depth[10]++;
873 count_store_depth[i]++;
875 copy = curstack->prev;
878 if ((copy->varkind == LOCALVAR) &&
879 (copy->varnum == iptr->op1)) {
880 copy->varkind = TEMPVAR;
886 if ((new - curstack) == 1) {
887 curstack->varkind = LOCALVAR;
888 curstack->varnum = iptr->op1;
890 STORE(opcode-ICMD_ISTORE);
900 COUNT(count_check_null);
901 COUNT(count_check_bound);
902 COUNT(count_pcmd_mem);
903 OP3TIA_0(opcode-ICMD_IASTORE);
908 COUNT(count_check_null);
909 COUNT(count_check_bound);
910 COUNT(count_pcmd_mem);
925 COUNT(count_pcmd_return);
926 OP1_0(opcode-ICMD_IRETURN);
927 superblockend = true;
931 COUNT(count_check_null);
935 superblockend = true;
939 COUNT(count_pcmd_mem);
943 /* pop 1 push 0 branch */
947 COUNT(count_pcmd_bra);
949 tbptr = block + block_index[iptr->op1];
951 iptr[0].target = (void *) tbptr;
953 MARKREACHED(tbptr, copy);
962 COUNT(count_pcmd_bra);
963 #ifdef CONDITIONAL_LOADCONST
965 tbptr = block + b_index;
966 if ((b_count >= 3) &&
967 ((b_index + 2) == block_index[iptr[0].op1]) &&
968 (tbptr[1].pre_count == 1) &&
969 (iptr[1].opc == ICMD_ICONST) &&
970 (iptr[2].opc == ICMD_GOTO) &&
971 ((b_index + 3) == block_index[iptr[2].op1]) &&
972 (tbptr[2].pre_count == 1) &&
973 (iptr[3].opc == ICMD_ICONST)) {
974 OP1_1(TYPE_INT, TYPE_INT);
975 switch (iptr[0].opc) {
977 iptr[0].opc = ICMD_IFNE_ICONST;
980 iptr[0].opc = ICMD_IFEQ_ICONST;
983 iptr[0].opc = ICMD_IFGE_ICONST;
986 iptr[0].opc = ICMD_IFLT_ICONST;
989 iptr[0].opc = ICMD_IFLE_ICONST;
992 iptr[0].opc = ICMD_IFGT_ICONST;
995 iptr[0].val.i = iptr[1].val.i;
996 iptr[1].opc = ICMD_ELSE_ICONST;
997 iptr[1].val.i = iptr[3].val.i;
998 iptr[2].opc = ICMD_NOP;
999 iptr[3].opc = ICMD_NOP;
1000 tbptr[1].flags = BBDELETED;
1001 tbptr[2].flags = BBDELETED;
1002 tbptr[1].icount = 0;
1003 tbptr[2].icount = 0;
1004 if (tbptr[3].pre_count == 2) {
1005 len += tbptr[3].icount + 3;
1006 bptr->icount += tbptr[3].icount + 3;
1007 tbptr[3].flags = BBDELETED;
1008 tbptr[3].icount = 0;
1021 tbptr = block + block_index[iptr->op1];
1023 iptr[0].target = (void *) tbptr;
1025 MARKREACHED(tbptr, copy);
1028 /* pop 0 push 0 branch */
1031 COUNT(count_pcmd_bra);
1032 tbptr = block + block_index[iptr->op1];
1034 iptr[0].target = (void *) tbptr;
1036 MARKREACHED(tbptr, copy);
1038 superblockend = true;
1041 /* pop 1 push 0 table branch */
1043 case ICMD_TABLESWITCH:
1044 COUNT(count_pcmd_table);
1046 s4ptr = iptr->val.a;
1047 tbptr = block + block_index[*s4ptr++]; /* default */
1048 MARKREACHED(tbptr, copy);
1049 i = *s4ptr++; /* low */
1050 i = *s4ptr++ - i + 1; /* high */
1052 tptr = DMNEW(void*, i+1);
1053 iptr->target = (void *) tptr;
1055 tptr[0] = (void *) tbptr;
1059 tbptr = block + block_index[*s4ptr++];
1061 tptr[0] = (void *) tbptr;
1064 MARKREACHED(tbptr, copy);
1067 superblockend = true;
1070 /* pop 1 push 0 table branch */
1072 case ICMD_LOOKUPSWITCH:
1073 COUNT(count_pcmd_table);
1075 s4ptr = iptr->val.a;
1076 tbptr = block + block_index[*s4ptr++]; /* default */
1077 MARKREACHED(tbptr, copy);
1078 i = *s4ptr++; /* count */
1080 tptr = DMNEW(void*, i+1);
1081 iptr->target = (void *) tptr;
1083 tptr[0] = (void *) tbptr;
1087 tbptr = block + block_index[s4ptr[1]];
1089 tptr[0] = (void *) tbptr;
1092 MARKREACHED(tbptr, copy);
1096 superblockend = true;
1099 case ICMD_NULLCHECKPOP:
1100 case ICMD_MONITORENTER:
1101 COUNT(count_check_null);
1102 case ICMD_MONITOREXIT:
1106 /* pop 2 push 0 branch */
1108 case ICMD_IF_ICMPEQ:
1109 case ICMD_IF_ICMPNE:
1110 case ICMD_IF_ICMPLT:
1111 case ICMD_IF_ICMPGE:
1112 case ICMD_IF_ICMPGT:
1113 case ICMD_IF_ICMPLE:
1114 COUNT(count_pcmd_bra);
1116 tbptr = block + block_index[iptr->op1];
1118 iptr[0].target = (void *) tbptr;
1120 MARKREACHED(tbptr, copy);
1123 case ICMD_IF_ACMPEQ:
1124 case ICMD_IF_ACMPNE:
1125 COUNT(count_pcmd_bra);
1127 tbptr = block + block_index[iptr->op1];
1129 iptr[0].target = (void *) tbptr;
1131 MARKREACHED(tbptr, copy);
1137 COUNT(count_check_null);
1138 COUNT(count_pcmd_mem);
1139 OPTT2_0(iptr->op1,TYPE_ADR);
1143 if (! IS_2_WORD_TYPE(curstack->type)) {
1144 OP1_0ANY; /* second pop */
1147 iptr->opc = ICMD_POP;
1151 /* pop 0 push 1 dup */
1154 COUNT(count_dup_instruction);
1159 if (IS_2_WORD_TYPE(curstack->type)) {
1160 iptr->opc = ICMD_DUP;
1165 NEWSTACK(copy->prev->type, copy->prev->varkind,
1166 copy->prev->varnum);
1167 NEWSTACK(copy->type, copy->varkind,
1174 /* pop 2 push 3 dup */
1181 if (IS_2_WORD_TYPE(curstack->type)) {
1182 iptr->opc = ICMD_DUP_X1;
1190 /* pop 3 push 4 dup */
1193 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1194 iptr->opc = ICMD_DUP_X1;
1203 if (IS_2_WORD_TYPE(curstack->type)) {
1204 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1205 iptr->opc = ICMD_DUP_X1;
1209 iptr->opc = ICMD_DUP_X2;
1214 if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1215 iptr->opc = ICMD_DUP2_X1;
1223 /* pop 2 push 2 swap */
1232 #if !SUPPORT_DIVISION
1233 iptr[0].opc = ICMD_BUILTIN2;
1234 iptr[0].op1 = TYPE_INT;
1235 iptr[0].val.a = (functionptr) asm_builtin_idiv;
1236 isleafmethod = false;
1241 #if !SUPPORT_DIVISION
1242 iptr[0].opc = ICMD_BUILTIN2;
1243 iptr[0].op1 = TYPE_INT;
1244 iptr[0].val.a = (functionptr) asm_builtin_irem;
1245 isleafmethod = false;
1259 COUNT(count_pcmd_op);
1264 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_MULDIV)
1265 iptr[0].opc = ICMD_BUILTIN2;
1266 iptr[0].op1 = TYPE_LNG;
1267 iptr[0].val.a = (functionptr) asm_builtin_ldiv;
1268 isleafmethod = false;
1273 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_MULDIV)
1274 iptr[0].opc = ICMD_BUILTIN2;
1275 iptr[0].op1 = TYPE_LNG;
1276 iptr[0].val.a = (functionptr) asm_builtin_lrem;
1277 isleafmethod = false;
1288 COUNT(count_pcmd_op);
1295 COUNT(count_pcmd_op);
1304 COUNT(count_pcmd_op);
1313 COUNT(count_pcmd_op);
1318 COUNT(count_pcmd_op);
1319 #if !defined(NOLONG_CONDITIONAL)
1320 if ((len > 0) && (iptr[1].val.i == 0)) {
1321 switch (iptr[1].opc) {
1323 iptr[0].opc = ICMD_IF_LCMPEQ;
1325 iptr[0].op1 = iptr[1].op1;
1328 /* iptr[1].opc = ICMD_NOP; */
1330 tbptr = block + block_index[iptr->op1];
1332 iptr[0].target = (void *) tbptr;
1334 MARKREACHED(tbptr, copy);
1335 COUNT(count_pcmd_bra);
1338 iptr[0].opc = ICMD_IF_LCMPNE;
1339 goto icmd_lcmp_if_tail;
1341 iptr[0].opc = ICMD_IF_LCMPLT;
1342 goto icmd_lcmp_if_tail;
1344 iptr[0].opc = ICMD_IF_LCMPGT;
1345 goto icmd_lcmp_if_tail;
1347 iptr[0].opc = ICMD_IF_LCMPLE;
1348 goto icmd_lcmp_if_tail;
1350 iptr[0].opc = ICMD_IF_LCMPGE;
1351 goto icmd_lcmp_if_tail;
1353 OPTT2_1(TYPE_LNG, TYPE_INT);
1358 OPTT2_1(TYPE_LNG, TYPE_INT);
1362 COUNT(count_pcmd_op);
1363 OPTT2_1(TYPE_FLT, TYPE_INT);
1367 COUNT(count_pcmd_op);
1368 OPTT2_1(TYPE_DBL, TYPE_INT);
1376 case ICMD_INT2SHORT:
1377 COUNT(count_pcmd_op);
1378 OP1_1(TYPE_INT, TYPE_INT);
1381 COUNT(count_pcmd_op);
1382 OP1_1(TYPE_LNG, TYPE_LNG);
1385 COUNT(count_pcmd_op);
1386 OP1_1(TYPE_FLT, TYPE_FLT);
1389 COUNT(count_pcmd_op);
1390 OP1_1(TYPE_DBL, TYPE_DBL);
1394 COUNT(count_pcmd_op);
1395 OP1_1(TYPE_INT, TYPE_LNG);
1398 COUNT(count_pcmd_op);
1399 OP1_1(TYPE_INT, TYPE_FLT);
1402 COUNT(count_pcmd_op);
1403 OP1_1(TYPE_INT, TYPE_DBL);
1406 COUNT(count_pcmd_op);
1407 OP1_1(TYPE_LNG, TYPE_INT);
1410 COUNT(count_pcmd_op);
1411 OP1_1(TYPE_LNG, TYPE_FLT);
1414 COUNT(count_pcmd_op);
1415 OP1_1(TYPE_LNG, TYPE_DBL);
1418 COUNT(count_pcmd_op);
1419 OP1_1(TYPE_FLT, TYPE_INT);
1422 COUNT(count_pcmd_op);
1423 OP1_1(TYPE_FLT, TYPE_LNG);
1426 COUNT(count_pcmd_op);
1427 OP1_1(TYPE_FLT, TYPE_DBL);
1430 COUNT(count_pcmd_op);
1431 OP1_1(TYPE_DBL, TYPE_INT);
1434 COUNT(count_pcmd_op);
1435 OP1_1(TYPE_DBL, TYPE_LNG);
1438 COUNT(count_pcmd_op);
1439 OP1_1(TYPE_DBL, TYPE_FLT);
1442 case ICMD_CHECKCAST:
1443 OP1_1(TYPE_ADR, TYPE_ADR);
1446 case ICMD_ARRAYLENGTH:
1447 case ICMD_INSTANCEOF:
1448 OP1_1(TYPE_ADR, TYPE_INT);
1452 case ICMD_ANEWARRAY:
1453 OP1_1(TYPE_INT, TYPE_ADR);
1457 COUNT(count_check_null);
1458 COUNT(count_pcmd_mem);
1459 OP1_1(TYPE_ADR, iptr->op1);
1464 case ICMD_GETSTATIC:
1465 COUNT(count_pcmd_mem);
1475 tbptr = block + block_index[iptr->op1];
1477 iptr[0].target = (void *) tbptr;
1479 tbptr->type=BBTYPE_SBR;
1480 MARKREACHED(tbptr, copy);
1484 /* pop many push any */
1486 case ICMD_INVOKEVIRTUAL:
1487 case ICMD_INVOKESPECIAL:
1488 case ICMD_INVOKEINTERFACE:
1489 case ICMD_INVOKESTATIC:
1490 COUNT(count_pcmd_met);
1492 methodinfo *m = iptr->val.a;
1493 if (m->flags & ACC_STATIC)
1494 {COUNT(count_check_null);}
1496 if (i > arguments_num)
1498 #if defined(__X86_64__)
1506 (IS_FLT_DBL_TYPE(copy->type)) ? farg++ : iarg++;
1510 stackargs += (iarg < intreg_argnum) ? 0 : (iarg - intreg_argnum);
1511 stackargs += (farg < fltreg_argnum) ? 0 : (farg - fltreg_argnum);
1516 if (!(copy->flags & SAVEDVAR)) {
1517 copy->varkind = ARGVAR;
1518 if (IS_FLT_DBL_TYPE(copy->type)) {
1519 if (--farg < fltreg_argnum) {
1520 copy->varnum = farg;
1522 copy->varnum = --stackargs + intreg_argnum;
1525 if (--iarg < intreg_argnum) {
1526 copy->varnum = iarg;
1528 copy->varnum = --stackargs + intreg_argnum;
1532 (IS_FLT_DBL_TYPE(copy->type)) ? --farg : --iarg;
1540 if (! (copy->flags & SAVEDVAR)) {
1541 copy->varkind = ARGVAR;
1548 copy->flags |= SAVEDVAR;
1553 if (m->returntype != TYPE_VOID) {
1554 OP0_1(m->returntype);
1560 if (! (curstack->flags & SAVEDVAR)) {
1561 curstack->varkind = ARGVAR;
1562 curstack->varnum = 2;
1564 if (3 > arguments_num) {
1571 if (!(curstack->flags & SAVEDVAR)) {
1572 curstack->varkind = ARGVAR;
1573 curstack->varnum = 1;
1575 if (2 > arguments_num) {
1582 if (!(curstack->flags & SAVEDVAR)) {
1583 curstack->varkind = ARGVAR;
1584 curstack->varnum = 0;
1586 if (1 > arguments_num) {
1592 copy->flags |= SAVEDVAR;
1595 if (iptr->op1 != TYPE_VOID)
1599 case ICMD_MULTIANEWARRAY:
1601 if ((i + intreg_argnum) > arguments_num)
1602 arguments_num = i + intreg_argnum;
1605 if (! (copy->flags & SAVEDVAR)) {
1606 copy->varkind = ARGVAR;
1607 copy->varnum = i + intreg_argnum;
1612 copy->flags |= SAVEDVAR;
1620 case ICMD_CLEAR_ARGREN:
1621 for (i = iptr->op1; i<maxlocals; i++)
1623 iptr->opc = opcode = ICMD_NOP;
1627 case ICMD_READONLY_ARG:
1628 case ICMD_READONLY_ARG+1:
1629 case ICMD_READONLY_ARG+2:
1630 case ICMD_READONLY_ARG+3:
1631 case ICMD_READONLY_ARG+4:
1633 if (curstack->varkind == LOCALVAR) {
1634 i = curstack->varnum;
1635 argren[iptr->op1] = i;
1638 opcode = iptr->opc = opcode - ICMD_READONLY_ARG + ICMD_ISTORE;
1644 printf("ICMD %d at %d\n", iptr->opc, (int)(iptr-instr));
1645 panic("Missing ICMD code during stack analysis");
1648 } /* while instructions */
1649 bptr->outstack = curstack;
1650 bptr->outdepth = stackdepth;
1654 superblockend = true;
1656 } /* while blocks */
1657 } while (repeat && !deadcode);
1660 if (block_count > count_max_basic_blocks)
1661 count_max_basic_blocks = block_count;
1662 count_basic_blocks += block_count;
1663 if (instr_count > count_max_javainstr)
1664 count_max_javainstr = instr_count;
1665 count_javainstr += instr_count;
1666 if (stack_count > count_upper_bound_new_stack)
1667 count_upper_bound_new_stack = stack_count;
1668 if ((new - stack) > count_max_new_stack)
1669 count_max_new_stack = (new - stack);
1671 b_count = block_count;
1673 while (--b_count >= 0) {
1674 if (bptr->flags > BBREACHED) {
1675 if (bptr->indepth >= 10)
1676 count_block_stack[10]++;
1678 count_block_stack[bptr->indepth]++;
1681 count_block_size_distribution[len]++;
1683 count_block_size_distribution[10]++;
1685 count_block_size_distribution[11]++;
1687 count_block_size_distribution[12]++;
1689 count_block_size_distribution[13]++;
1691 count_block_size_distribution[14]++;
1693 count_block_size_distribution[15]++;
1695 count_block_size_distribution[16]++;
1697 count_block_size_distribution[17]++;
1703 count_analyse_iterations[0]++;
1704 else if (loops == 2)
1705 count_analyse_iterations[1]++;
1706 else if (loops == 3)
1707 count_analyse_iterations[2]++;
1708 else if (loops == 4)
1709 count_analyse_iterations[3]++;
1711 count_analyse_iterations[4]++;
1713 if (block_count <= 5)
1714 count_method_bb_distribution[0]++;
1715 else if (block_count <= 10)
1716 count_method_bb_distribution[1]++;
1717 else if (block_count <= 15)
1718 count_method_bb_distribution[2]++;
1719 else if (block_count <= 20)
1720 count_method_bb_distribution[3]++;
1721 else if (block_count <= 30)
1722 count_method_bb_distribution[4]++;
1723 else if (block_count <= 40)
1724 count_method_bb_distribution[5]++;
1725 else if (block_count <= 50)
1726 count_method_bb_distribution[6]++;
1727 else if (block_count <= 75)
1728 count_method_bb_distribution[7]++;
1730 count_method_bb_distribution[8]++;
1735 static void print_stack(stackptr s)
1752 if (s->flags & SAVEDVAR)
1753 switch (s->varkind) {
1755 if (s->flags & INMEMORY)
1756 printf(" M%02d", s->regoff);
1757 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1758 printf(" F%02d", s->regoff);
1760 printf(" %3s", regs[s->regoff]);
1763 printf(" I%02d", s->varnum);
1766 printf(" L%02d", s->varnum);
1769 printf(" A%02d", s->varnum);
1772 printf(" !%02d", j);
1775 switch (s->varkind) {
1777 if (s->flags & INMEMORY)
1778 printf(" m%02d", s->regoff);
1779 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1780 printf(" f%02d", s->regoff);
1782 printf(" %3s", regs[s->regoff]);
1785 printf(" i%02d", s->varnum);
1788 printf(" l%02d", s->varnum);
1791 printf(" a%02d", s->varnum);
1794 printf(" ?%02d", j);
1802 static void print_reg(stackptr s) {
1804 if (s->flags & SAVEDVAR)
1805 switch (s->varkind) {
1807 if (s->flags & INMEMORY)
1808 printf(" tm%02d", s->regoff);
1810 printf(" tr%02d", s->regoff);
1813 printf(" s %02d", s->varnum);
1816 printf(" l %02d", s->varnum);
1819 printf(" a %02d", s->varnum);
1822 printf(" ! %02d", s->varnum);
1825 switch (s->varkind) {
1827 if (s->flags & INMEMORY)
1828 printf(" Tm%02d", s->regoff);
1830 printf(" Tr%02d", s->regoff);
1833 printf(" S %02d", s->varnum);
1836 printf(" L %02d", s->varnum);
1839 printf(" A %02d", s->varnum);
1842 printf(" ? %02d", s->varnum);
1852 static char *builtin_name(functionptr bptr)
1854 builtin_descriptor *bdesc = builtin_desc;
1855 while ((bdesc->bptr != NULL) && (bdesc->bptr != bptr))
1861 static char *jit_type[] = {
1870 void show_icmd_method()
1881 utf_fprint(stdout, class->name);
1883 utf_fprint(stdout, method->name);
1885 utf_fprint(stdout, method->descriptor);
1886 printf ("\n\nMax locals: %d\n", (int) maxlocals);
1887 printf ("Max stack: %d\n", (int) maxstack);
1889 printf ("Exceptions (Number: %d):\n", exceptiontablelength);
1890 for (ex = extable; ex != NULL; ex = ex->down) {
1891 printf(" L%03d ... ", ex->start->debug_nr );
1892 printf("L%03d = ", ex->end->debug_nr);
1893 printf("L%03d\n", ex->handler->debug_nr);
1896 printf ("Local Table:\n");
1897 for (i = 0; i < maxlocals; i++) {
1898 printf(" %3d: ", i);
1899 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1900 if (locals[i][j].type >= 0) {
1901 printf(" (%s) ", jit_type[j]);
1902 if (locals[i][j].flags & INMEMORY)
1903 printf("m%2d", locals[i][j].regoff);
1904 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1905 printf("f%02d", locals[i][j].regoff);
1907 printf("%3s", regs[locals[i][j].regoff]);
1913 printf ("Interface Table:\n");
1914 for (i = 0; i < maxstack; i++) {
1915 if ((interfaces[i][0].type >= 0) || (interfaces[i][1].type >= 0) ||
1916 (interfaces[i][2].type >= 0) || (interfaces[i][3].type >= 0) ||
1917 (interfaces[i][4].type >= 0)) {
1918 printf(" %3d: ", i);
1919 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1920 if (interfaces[i][j].type >= 0) {
1921 printf(" (%s) ", jit_type[j]);
1922 if (interfaces[i][j].flags & SAVEDVAR) {
1923 if (interfaces[i][j].flags & INMEMORY)
1924 printf("M%2d", interfaces[i][j].regoff);
1925 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1926 printf("F%02d", interfaces[i][j].regoff);
1928 printf("%3s", regs[interfaces[i][j].regoff]);
1931 if (interfaces[i][j].flags & INMEMORY)
1932 printf("m%2d", interfaces[i][j].regoff);
1933 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1934 printf("f%02d", interfaces[i][j].regoff);
1936 printf("%3s", regs[interfaces[i][j].regoff]);
1944 if (showdisassemble) {
1945 #if defined(__I386__) || defined(__X86_64__)
1949 u1ptr = method->mcode + dseglen;
1950 for (i = 0; i < block[0].mpc; i++, u1ptr++) {
1951 a = disassinstr(u1ptr, i);
1957 s4ptr = (s4 *) (method->mcode + dseglen);
1958 for (i = 0; i < block[0].mpc; i += 4, s4ptr++) {
1959 disassinstr(*s4ptr, i);
1966 for (bptr = block; bptr != NULL; bptr = bptr->next) {
1967 if (bptr->flags != BBDELETED) {
1968 deadcode = bptr->flags <= BBREACHED;
1971 for (j = maxstack; j > 0; j--)
1974 print_stack(bptr->instack);
1975 printf("] L%03d(%d - %d):\n", bptr->debug_nr, bptr->icount, bptr->pre_count);
1976 iptr = bptr->iinstr;
1978 for (i=0; i < bptr->icount; i++, iptr++) {
1981 for (j = maxstack; j > 0; j--)
1985 print_stack(iptr->dst);
1986 printf("] %4d %s", i, icmd_names[iptr->opc]);
1987 switch ((int) iptr->opc) {
1988 case ICMD_IADDCONST:
1989 case ICMD_ISUBCONST:
1990 case ICMD_IMULCONST:
1993 case ICMD_IREM0X10001:
1994 case ICMD_IANDCONST:
1996 case ICMD_IXORCONST:
1997 case ICMD_ISHLCONST:
1998 case ICMD_ISHRCONST:
1999 case ICMD_IUSHRCONST:
2000 case ICMD_LSHLCONST:
2001 case ICMD_LSHRCONST:
2002 case ICMD_LUSHRCONST:
2004 case ICMD_ELSE_ICONST:
2005 case ICMD_IFEQ_ICONST:
2006 case ICMD_IFNE_ICONST:
2007 case ICMD_IFLT_ICONST:
2008 case ICMD_IFGE_ICONST:
2009 case ICMD_IFGT_ICONST:
2010 case ICMD_IFLE_ICONST:
2011 printf(" %d", iptr->val.i);
2013 case ICMD_LADDCONST:
2014 case ICMD_LSUBCONST:
2015 case ICMD_LMULCONST:
2018 case ICMD_LANDCONST:
2020 case ICMD_LXORCONST:
2022 #if defined(__I386__)
2023 printf(" %lld", iptr->val.l);
2025 printf(" %ld", iptr->val.l);
2029 printf(" %f", iptr->val.f);
2032 printf(" %f", iptr->val.d);
2035 printf(" %p", iptr->val.a);
2039 printf(" %d,", ((fieldinfo *) iptr->val.a)->offset);
2040 case ICMD_PUTSTATIC:
2041 case ICMD_GETSTATIC:
2044 ((fieldinfo *) iptr->val.a)->name);
2047 printf(" %d + %d", iptr->op1, iptr->val.i);
2082 printf(" %d", iptr->op1);
2087 ((classinfo *) iptr->val.a)->name);
2090 switch (iptr->op1) {
2117 case ICMD_ANEWARRAY:
2121 ((classinfo *) iptr->val.a)->name);
2124 case ICMD_CHECKCAST:
2125 case ICMD_INSTANCEOF:
2127 classinfo *c = iptr->val.a;
2128 if (c->flags & ACC_INTERFACE)
2129 printf(" (INTERFACE) ");
2131 printf(" (CLASS,%3d) ", c->vftbl->diffval);
2132 utf_fprint(stdout, c->name);
2138 printf(" %s", builtin_name((functionptr) iptr->val.a));
2140 case ICMD_INVOKEVIRTUAL:
2141 case ICMD_INVOKESPECIAL:
2142 case ICMD_INVOKESTATIC:
2143 case ICMD_INVOKEINTERFACE:
2146 ((methodinfo *) iptr->val.a)->class->name);
2149 ((methodinfo *) iptr->val.a)->name);
2157 printf("(%d) L%03d", iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
2165 printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
2170 case ICMD_IFNONNULL:
2171 case ICMD_IF_ICMPEQ:
2172 case ICMD_IF_ICMPNE:
2173 case ICMD_IF_ICMPLT:
2174 case ICMD_IF_ICMPGE:
2175 case ICMD_IF_ICMPGT:
2176 case ICMD_IF_ICMPLE:
2177 case ICMD_IF_LCMPEQ:
2178 case ICMD_IF_LCMPNE:
2179 case ICMD_IF_LCMPLT:
2180 case ICMD_IF_LCMPGE:
2181 case ICMD_IF_LCMPGT:
2182 case ICMD_IF_LCMPLE:
2183 case ICMD_IF_ACMPEQ:
2184 case ICMD_IF_ACMPNE:
2185 printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
2187 case ICMD_TABLESWITCH:
2189 s4ptr = iptr->val.a;
2190 tptr = (void **) iptr->target;
2192 printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
2198 j = *s4ptr++; /* low */
2199 j = *s4ptr++ - j; /* high */
2201 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2206 case ICMD_LOOKUPSWITCH:
2207 s4ptr = iptr->val.a;
2208 tptr = (void **) iptr->target;
2210 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2211 s4ptr++; /* default */
2212 j = *s4ptr; /* count */
2216 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2224 if (showdisassemble && (!deadcode)) {
2225 #if defined(__I386__) || defined(__X86_64__)
2231 u1ptr = method->mcode + dseglen + i;
2233 if (bptr->next != NULL) {
2234 for (; i < bptr->next->mpc; i++, u1ptr++) {
2235 a = disassinstr(u1ptr, i);
2242 for (; u1ptr < (u1 *) (method->mcode + method->mcodelength); i++, u1ptr++) {
2243 a = disassinstr(u1ptr, i);
2252 s4ptr = (s4 *) (method->mcode + dseglen + i);
2254 if (bptr->next != NULL) {
2255 for (; i < bptr->next->mpc; i += 4, s4ptr++) {
2256 disassinstr(*s4ptr, i);
2261 for (; s4ptr < (s4 *) (method->mcode + method->mcodelength); i += 4, s4ptr++) {
2262 disassinstr(*s4ptr, i);
2274 * These are local overrides for various environment variables in Emacs.
2275 * Please do not remove this and leave it at the end of the file, where
2276 * Emacs will automagically detect them.
2277 * ---------------------------------------------------------------------
2280 * indent-tabs-mode: t