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 640 2003-11-15 12:14:05Z 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 && opcode == breplace->opcode) {
344 iptr[0].opc = breplace->icmd;
345 iptr[0].op1 = breplace->type_d;
346 iptr[0].val.a = breplace->builtin;
347 isleafmethod = false;
348 switch (breplace->icmd) {
363 case ICMD_CHECKASIZE:
365 case ICMD_IFEQ_ICONST:
366 case ICMD_IFNE_ICONST:
367 case ICMD_IFLT_ICONST:
368 case ICMD_IFGE_ICONST:
369 case ICMD_IFGT_ICONST:
370 case ICMD_IFLE_ICONST:
371 case ICMD_ELSE_ICONST:
376 locals[iptr->op1][TYPE_ADR].type = TYPE_ADR;
378 COUNT(count_pcmd_return);
380 superblockend = true;
383 /* pop 0 push 1 const */
386 COUNT(count_pcmd_load);
388 switch (iptr[1].opc) {
390 iptr[0].opc = ICMD_IADDCONST;
392 iptr[1].opc = ICMD_NOP;
393 OP1_1(TYPE_INT,TYPE_INT);
394 COUNT(count_pcmd_op);
397 iptr[0].opc = ICMD_ISUBCONST;
398 goto icmd_iconst_tail;
400 iptr[0].opc = ICMD_IMULCONST;
401 goto icmd_iconst_tail;
403 if (iptr[0].val.i == 0x00000002)
405 else if (iptr[0].val.i == 0x00000004)
407 else if (iptr[0].val.i == 0x00000008)
409 else if (iptr[0].val.i == 0x00000010)
411 else if (iptr[0].val.i == 0x00000020)
413 else if (iptr[0].val.i == 0x00000040)
415 else if (iptr[0].val.i == 0x00000080)
417 else if (iptr[0].val.i == 0x00000100)
419 else if (iptr[0].val.i == 0x00000200)
421 else if (iptr[0].val.i == 0x00000400)
423 else if (iptr[0].val.i == 0x00000800)
425 else if (iptr[0].val.i == 0x00001000)
427 else if (iptr[0].val.i == 0x00002000)
429 else if (iptr[0].val.i == 0x00004000)
431 else if (iptr[0].val.i == 0x00008000)
433 else if (iptr[0].val.i == 0x00010000)
435 else if (iptr[0].val.i == 0x00020000)
437 else if (iptr[0].val.i == 0x00040000)
439 else if (iptr[0].val.i == 0x00080000)
441 else if (iptr[0].val.i == 0x00100000)
443 else if (iptr[0].val.i == 0x00200000)
445 else if (iptr[0].val.i == 0x00400000)
447 else if (iptr[0].val.i == 0x00800000)
449 else if (iptr[0].val.i == 0x01000000)
451 else if (iptr[0].val.i == 0x02000000)
453 else if (iptr[0].val.i == 0x04000000)
455 else if (iptr[0].val.i == 0x08000000)
457 else if (iptr[0].val.i == 0x10000000)
459 else if (iptr[0].val.i == 0x20000000)
461 else if (iptr[0].val.i == 0x40000000)
463 else if (iptr[0].val.i == 0x80000000)
469 iptr[0].opc = ICMD_IDIVPOW2;
470 goto icmd_iconst_tail;
472 #if !defined(NO_DIV_OPT)
473 if (iptr[0].val.i == 0x10001) {
474 iptr[0].opc = ICMD_IREM0X10001;
475 goto icmd_iconst_tail;
478 if ((iptr[0].val.i == 0x00000002) ||
479 (iptr[0].val.i == 0x00000004) ||
480 (iptr[0].val.i == 0x00000008) ||
481 (iptr[0].val.i == 0x00000010) ||
482 (iptr[0].val.i == 0x00000020) ||
483 (iptr[0].val.i == 0x00000040) ||
484 (iptr[0].val.i == 0x00000080) ||
485 (iptr[0].val.i == 0x00000100) ||
486 (iptr[0].val.i == 0x00000200) ||
487 (iptr[0].val.i == 0x00000400) ||
488 (iptr[0].val.i == 0x00000800) ||
489 (iptr[0].val.i == 0x00001000) ||
490 (iptr[0].val.i == 0x00002000) ||
491 (iptr[0].val.i == 0x00004000) ||
492 (iptr[0].val.i == 0x00008000) ||
493 (iptr[0].val.i == 0x00010000) ||
494 (iptr[0].val.i == 0x00020000) ||
495 (iptr[0].val.i == 0x00040000) ||
496 (iptr[0].val.i == 0x00080000) ||
497 (iptr[0].val.i == 0x00100000) ||
498 (iptr[0].val.i == 0x00200000) ||
499 (iptr[0].val.i == 0x00400000) ||
500 (iptr[0].val.i == 0x00800000) ||
501 (iptr[0].val.i == 0x01000000) ||
502 (iptr[0].val.i == 0x02000000) ||
503 (iptr[0].val.i == 0x04000000) ||
504 (iptr[0].val.i == 0x08000000) ||
505 (iptr[0].val.i == 0x10000000) ||
506 (iptr[0].val.i == 0x20000000) ||
507 (iptr[0].val.i == 0x40000000) ||
508 (iptr[0].val.i == 0x80000000)) {
509 iptr[0].opc = ICMD_IREMPOW2;
511 goto icmd_iconst_tail;
516 iptr[0].opc = ICMD_IANDCONST;
517 goto icmd_iconst_tail;
519 iptr[0].opc = ICMD_IORCONST;
520 goto icmd_iconst_tail;
522 iptr[0].opc = ICMD_IXORCONST;
523 goto icmd_iconst_tail;
525 iptr[0].opc = ICMD_ISHLCONST;
526 goto icmd_iconst_tail;
528 iptr[0].opc = ICMD_ISHRCONST;
529 goto icmd_iconst_tail;
531 iptr[0].opc = ICMD_IUSHRCONST;
532 goto icmd_iconst_tail;
533 #if SUPPORT_LONG_SHIFT
535 iptr[0].opc = ICMD_LSHLCONST;
536 goto icmd_lconst_tail;
538 iptr[0].opc = ICMD_LSHRCONST;
539 goto icmd_lconst_tail;
541 iptr[0].opc = ICMD_LUSHRCONST;
542 goto icmd_lconst_tail;
545 iptr[0].opc = ICMD_IFEQ;
547 iptr[0].op1 = iptr[1].op1;
550 /* iptr[1].opc = ICMD_NOP; */
552 tbptr = block + block_index[iptr->op1];
554 iptr[0].target = (void *) tbptr;
556 MARKREACHED(tbptr, copy);
557 COUNT(count_pcmd_bra);
560 iptr[0].opc = ICMD_IFLT;
561 goto icmd_if_icmp_tail;
563 iptr[0].opc = ICMD_IFLE;
564 goto icmd_if_icmp_tail;
566 iptr[0].opc = ICMD_IFNE;
567 goto icmd_if_icmp_tail;
569 iptr[0].opc = ICMD_IFGT;
570 goto icmd_if_icmp_tail;
572 iptr[0].opc = ICMD_IFGE;
573 goto icmd_if_icmp_tail;
582 COUNT(count_pcmd_load);
584 switch (iptr[1].opc) {
587 iptr[0].opc = ICMD_LADDCONST;
589 iptr[1].opc = ICMD_NOP;
590 OP1_1(TYPE_LNG,TYPE_LNG);
591 COUNT(count_pcmd_op);
594 iptr[0].opc = ICMD_LSUBCONST;
595 goto icmd_lconst_tail;
599 iptr[0].opc = ICMD_LMULCONST;
600 goto icmd_lconst_tail;
604 if (iptr[0].val.l == 0x00000002)
606 else if (iptr[0].val.l == 0x00000004)
608 else if (iptr[0].val.l == 0x00000008)
610 else if (iptr[0].val.l == 0x00000010)
612 else if (iptr[0].val.l == 0x00000020)
614 else if (iptr[0].val.l == 0x00000040)
616 else if (iptr[0].val.l == 0x00000080)
618 else if (iptr[0].val.l == 0x00000100)
620 else if (iptr[0].val.l == 0x00000200)
622 else if (iptr[0].val.l == 0x00000400)
624 else if (iptr[0].val.l == 0x00000800)
626 else if (iptr[0].val.l == 0x00001000)
628 else if (iptr[0].val.l == 0x00002000)
630 else if (iptr[0].val.l == 0x00004000)
632 else if (iptr[0].val.l == 0x00008000)
634 else if (iptr[0].val.l == 0x00010000)
636 else if (iptr[0].val.l == 0x00020000)
638 else if (iptr[0].val.l == 0x00040000)
640 else if (iptr[0].val.l == 0x00080000)
642 else if (iptr[0].val.l == 0x00100000)
644 else if (iptr[0].val.l == 0x00200000)
646 else if (iptr[0].val.l == 0x00400000)
648 else if (iptr[0].val.l == 0x00800000)
650 else if (iptr[0].val.l == 0x01000000)
652 else if (iptr[0].val.l == 0x02000000)
654 else if (iptr[0].val.l == 0x04000000)
656 else if (iptr[0].val.l == 0x08000000)
658 else if (iptr[0].val.l == 0x10000000)
660 else if (iptr[0].val.l == 0x20000000)
662 else if (iptr[0].val.l == 0x40000000)
664 else if (iptr[0].val.l == 0x80000000)
670 iptr[0].opc = ICMD_LDIVPOW2;
671 goto icmd_lconst_tail;
673 #if !defined(NO_DIV_OPT)
674 if (iptr[0].val.l == 0x10001) {
675 iptr[0].opc = ICMD_LREM0X10001;
676 goto icmd_lconst_tail;
679 if ((iptr[0].val.l == 0x00000002) ||
680 (iptr[0].val.l == 0x00000004) ||
681 (iptr[0].val.l == 0x00000008) ||
682 (iptr[0].val.l == 0x00000010) ||
683 (iptr[0].val.l == 0x00000020) ||
684 (iptr[0].val.l == 0x00000040) ||
685 (iptr[0].val.l == 0x00000080) ||
686 (iptr[0].val.l == 0x00000100) ||
687 (iptr[0].val.l == 0x00000200) ||
688 (iptr[0].val.l == 0x00000400) ||
689 (iptr[0].val.l == 0x00000800) ||
690 (iptr[0].val.l == 0x00001000) ||
691 (iptr[0].val.l == 0x00002000) ||
692 (iptr[0].val.l == 0x00004000) ||
693 (iptr[0].val.l == 0x00008000) ||
694 (iptr[0].val.l == 0x00010000) ||
695 (iptr[0].val.l == 0x00020000) ||
696 (iptr[0].val.l == 0x00040000) ||
697 (iptr[0].val.l == 0x00080000) ||
698 (iptr[0].val.l == 0x00100000) ||
699 (iptr[0].val.l == 0x00200000) ||
700 (iptr[0].val.l == 0x00400000) ||
701 (iptr[0].val.l == 0x00800000) ||
702 (iptr[0].val.l == 0x01000000) ||
703 (iptr[0].val.l == 0x02000000) ||
704 (iptr[0].val.l == 0x04000000) ||
705 (iptr[0].val.l == 0x08000000) ||
706 (iptr[0].val.l == 0x10000000) ||
707 (iptr[0].val.l == 0x20000000) ||
708 (iptr[0].val.l == 0x40000000) ||
709 (iptr[0].val.l == 0x80000000)) {
710 iptr[0].opc = ICMD_LREMPOW2;
712 goto icmd_lconst_tail;
719 iptr[0].opc = ICMD_LANDCONST;
720 goto icmd_lconst_tail;
722 iptr[0].opc = ICMD_LORCONST;
723 goto icmd_lconst_tail;
725 iptr[0].opc = ICMD_LXORCONST;
726 goto icmd_lconst_tail;
728 #if !defined(NOLONG_CONDITIONAL)
730 if ((len > 1) && (iptr[2].val.i == 0)) {
731 switch (iptr[2].opc) {
733 iptr[0].opc = ICMD_IF_LEQ;
734 icmd_lconst_lcmp_tail:
735 iptr[0].op1 = iptr[2].op1;
738 /* iptr[1].opc = ICMD_NOP;
739 iptr[2].opc = ICMD_NOP; */
741 tbptr = block + block_index[iptr->op1];
743 iptr[0].target = (void *) tbptr;
745 MARKREACHED(tbptr, copy);
746 COUNT(count_pcmd_bra);
747 COUNT(count_pcmd_op);
750 iptr[0].opc = ICMD_IF_LNE;
751 goto icmd_lconst_lcmp_tail;
753 iptr[0].opc = ICMD_IF_LLT;
754 goto icmd_lconst_lcmp_tail;
756 iptr[0].opc = ICMD_IF_LGT;
757 goto icmd_lconst_lcmp_tail;
759 iptr[0].opc = ICMD_IF_LLE;
760 goto icmd_lconst_lcmp_tail;
762 iptr[0].opc = ICMD_IF_LGE;
763 goto icmd_lconst_lcmp_tail;
766 } /* switch (iptr[2].opc) */
767 } /* if (iptr[2].val.i == 0) */
780 COUNT(count_pcmd_load);
784 COUNT(count_pcmd_load);
788 COUNT(count_pcmd_load);
792 /* pop 0 push 1 load */
799 COUNT(count_load_instruction);
800 i = opcode-ICMD_ILOAD;
801 iptr->op1 = argren[iptr->op1];
802 locals[iptr->op1][i].type = i;
803 LOAD(i, LOCALVAR, iptr->op1);
813 COUNT(count_check_null);
814 COUNT(count_check_bound);
815 COUNT(count_pcmd_mem);
816 OP2IAT_1(opcode-ICMD_IALOAD);
822 COUNT(count_check_null);
823 COUNT(count_check_bound);
824 COUNT(count_pcmd_mem);
828 /* pop 0 push 0 iinc */
834 count_store_depth[10]++;
836 count_store_depth[i]++;
841 if ((copy->varkind == LOCALVAR) &&
842 (copy->varnum == iptr->op1)) {
843 copy->varkind = TEMPVAR;
852 /* pop 1 push 0 store */
861 i = opcode - ICMD_ISTORE;
862 locals[iptr->op1][i].type = i;
867 count_store_length[20]++;
869 count_store_length[i]++;
872 count_store_depth[10]++;
874 count_store_depth[i]++;
876 copy = curstack->prev;
879 if ((copy->varkind == LOCALVAR) &&
880 (copy->varnum == iptr->op1)) {
881 copy->varkind = TEMPVAR;
887 if ((new - curstack) == 1) {
888 curstack->varkind = LOCALVAR;
889 curstack->varnum = iptr->op1;
891 STORE(opcode-ICMD_ISTORE);
901 COUNT(count_check_null);
902 COUNT(count_check_bound);
903 COUNT(count_pcmd_mem);
904 OP3TIA_0(opcode-ICMD_IASTORE);
909 COUNT(count_check_null);
910 COUNT(count_check_bound);
911 COUNT(count_pcmd_mem);
926 COUNT(count_pcmd_return);
927 OP1_0(opcode-ICMD_IRETURN);
928 superblockend = true;
932 COUNT(count_check_null);
936 superblockend = true;
940 COUNT(count_pcmd_mem);
944 /* pop 1 push 0 branch */
948 COUNT(count_pcmd_bra);
950 tbptr = block + block_index[iptr->op1];
952 iptr[0].target = (void *) tbptr;
954 MARKREACHED(tbptr, copy);
963 COUNT(count_pcmd_bra);
964 #ifdef CONDITIONAL_LOADCONST
966 tbptr = block + b_index;
967 if ((b_count >= 3) &&
968 ((b_index + 2) == block_index[iptr[0].op1]) &&
969 (tbptr[1].pre_count == 1) &&
970 (iptr[1].opc == ICMD_ICONST) &&
971 (iptr[2].opc == ICMD_GOTO) &&
972 ((b_index + 3) == block_index[iptr[2].op1]) &&
973 (tbptr[2].pre_count == 1) &&
974 (iptr[3].opc == ICMD_ICONST)) {
975 OP1_1(TYPE_INT, TYPE_INT);
976 switch (iptr[0].opc) {
978 iptr[0].opc = ICMD_IFNE_ICONST;
981 iptr[0].opc = ICMD_IFEQ_ICONST;
984 iptr[0].opc = ICMD_IFGE_ICONST;
987 iptr[0].opc = ICMD_IFLT_ICONST;
990 iptr[0].opc = ICMD_IFLE_ICONST;
993 iptr[0].opc = ICMD_IFGT_ICONST;
996 iptr[0].val.i = iptr[1].val.i;
997 iptr[1].opc = ICMD_ELSE_ICONST;
998 iptr[1].val.i = iptr[3].val.i;
999 iptr[2].opc = ICMD_NOP;
1000 iptr[3].opc = ICMD_NOP;
1001 tbptr[1].flags = BBDELETED;
1002 tbptr[2].flags = BBDELETED;
1003 tbptr[1].icount = 0;
1004 tbptr[2].icount = 0;
1005 if (tbptr[3].pre_count == 2) {
1006 len += tbptr[3].icount + 3;
1007 bptr->icount += tbptr[3].icount + 3;
1008 tbptr[3].flags = BBDELETED;
1009 tbptr[3].icount = 0;
1022 tbptr = block + block_index[iptr->op1];
1024 iptr[0].target = (void *) tbptr;
1026 MARKREACHED(tbptr, copy);
1029 /* pop 0 push 0 branch */
1032 COUNT(count_pcmd_bra);
1033 tbptr = block + block_index[iptr->op1];
1035 iptr[0].target = (void *) tbptr;
1037 MARKREACHED(tbptr, copy);
1039 superblockend = true;
1042 /* pop 1 push 0 table branch */
1044 case ICMD_TABLESWITCH:
1045 COUNT(count_pcmd_table);
1047 s4ptr = iptr->val.a;
1048 tbptr = block + block_index[*s4ptr++]; /* default */
1049 MARKREACHED(tbptr, copy);
1050 i = *s4ptr++; /* low */
1051 i = *s4ptr++ - i + 1; /* high */
1053 tptr = DMNEW(void*, i+1);
1054 iptr->target = (void *) tptr;
1056 tptr[0] = (void *) tbptr;
1060 tbptr = block + block_index[*s4ptr++];
1062 tptr[0] = (void *) tbptr;
1065 MARKREACHED(tbptr, copy);
1068 superblockend = true;
1071 /* pop 1 push 0 table branch */
1073 case ICMD_LOOKUPSWITCH:
1074 COUNT(count_pcmd_table);
1076 s4ptr = iptr->val.a;
1077 tbptr = block + block_index[*s4ptr++]; /* default */
1078 MARKREACHED(tbptr, copy);
1079 i = *s4ptr++; /* count */
1081 tptr = DMNEW(void*, i+1);
1082 iptr->target = (void *) tptr;
1084 tptr[0] = (void *) tbptr;
1088 tbptr = block + block_index[s4ptr[1]];
1090 tptr[0] = (void *) tbptr;
1093 MARKREACHED(tbptr, copy);
1097 superblockend = true;
1100 case ICMD_NULLCHECKPOP:
1101 case ICMD_MONITORENTER:
1102 COUNT(count_check_null);
1103 case ICMD_MONITOREXIT:
1107 /* pop 2 push 0 branch */
1109 case ICMD_IF_ICMPEQ:
1110 case ICMD_IF_ICMPNE:
1111 case ICMD_IF_ICMPLT:
1112 case ICMD_IF_ICMPGE:
1113 case ICMD_IF_ICMPGT:
1114 case ICMD_IF_ICMPLE:
1115 COUNT(count_pcmd_bra);
1117 tbptr = block + block_index[iptr->op1];
1119 iptr[0].target = (void *) tbptr;
1121 MARKREACHED(tbptr, copy);
1124 case ICMD_IF_ACMPEQ:
1125 case ICMD_IF_ACMPNE:
1126 COUNT(count_pcmd_bra);
1128 tbptr = block + block_index[iptr->op1];
1130 iptr[0].target = (void *) tbptr;
1132 MARKREACHED(tbptr, copy);
1138 COUNT(count_check_null);
1139 COUNT(count_pcmd_mem);
1140 OPTT2_0(iptr->op1,TYPE_ADR);
1144 if (! IS_2_WORD_TYPE(curstack->type)) {
1145 OP1_0ANY; /* second pop */
1148 iptr->opc = ICMD_POP;
1152 /* pop 0 push 1 dup */
1155 COUNT(count_dup_instruction);
1160 if (IS_2_WORD_TYPE(curstack->type)) {
1161 iptr->opc = ICMD_DUP;
1166 NEWSTACK(copy->prev->type, copy->prev->varkind,
1167 copy->prev->varnum);
1168 NEWSTACK(copy->type, copy->varkind,
1175 /* pop 2 push 3 dup */
1182 if (IS_2_WORD_TYPE(curstack->type)) {
1183 iptr->opc = ICMD_DUP_X1;
1191 /* pop 3 push 4 dup */
1194 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1195 iptr->opc = ICMD_DUP_X1;
1204 if (IS_2_WORD_TYPE(curstack->type)) {
1205 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1206 iptr->opc = ICMD_DUP_X1;
1210 iptr->opc = ICMD_DUP_X2;
1215 if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1216 iptr->opc = ICMD_DUP2_X1;
1224 /* pop 2 push 2 swap */
1233 #if !SUPPORT_DIVISION
1234 iptr[0].opc = ICMD_BUILTIN2;
1235 iptr[0].op1 = TYPE_INT;
1236 iptr[0].val.a = (functionptr) asm_builtin_idiv;
1237 isleafmethod = false;
1242 #if !SUPPORT_DIVISION
1243 iptr[0].opc = ICMD_BUILTIN2;
1244 iptr[0].op1 = TYPE_INT;
1245 iptr[0].val.a = (functionptr) asm_builtin_irem;
1246 isleafmethod = false;
1260 COUNT(count_pcmd_op);
1265 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1266 iptr[0].opc = ICMD_BUILTIN2;
1267 iptr[0].op1 = TYPE_LNG;
1268 iptr[0].val.a = (functionptr) asm_builtin_ldiv;
1269 isleafmethod = false;
1274 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1275 iptr[0].opc = ICMD_BUILTIN2;
1276 iptr[0].op1 = TYPE_LNG;
1277 iptr[0].val.a = (functionptr) asm_builtin_lrem;
1278 isleafmethod = false;
1289 COUNT(count_pcmd_op);
1296 COUNT(count_pcmd_op);
1305 COUNT(count_pcmd_op);
1314 COUNT(count_pcmd_op);
1319 COUNT(count_pcmd_op);
1320 #if !defined(NOLONG_CONDITIONAL)
1321 if ((len > 0) && (iptr[1].val.i == 0)) {
1322 switch (iptr[1].opc) {
1324 iptr[0].opc = ICMD_IF_LCMPEQ;
1326 iptr[0].op1 = iptr[1].op1;
1329 /* iptr[1].opc = ICMD_NOP; */
1331 tbptr = block + block_index[iptr->op1];
1333 iptr[0].target = (void *) tbptr;
1335 MARKREACHED(tbptr, copy);
1336 COUNT(count_pcmd_bra);
1339 iptr[0].opc = ICMD_IF_LCMPNE;
1340 goto icmd_lcmp_if_tail;
1342 iptr[0].opc = ICMD_IF_LCMPLT;
1343 goto icmd_lcmp_if_tail;
1345 iptr[0].opc = ICMD_IF_LCMPGT;
1346 goto icmd_lcmp_if_tail;
1348 iptr[0].opc = ICMD_IF_LCMPLE;
1349 goto icmd_lcmp_if_tail;
1351 iptr[0].opc = ICMD_IF_LCMPGE;
1352 goto icmd_lcmp_if_tail;
1354 OPTT2_1(TYPE_LNG, TYPE_INT);
1359 OPTT2_1(TYPE_LNG, TYPE_INT);
1363 COUNT(count_pcmd_op);
1364 OPTT2_1(TYPE_FLT, TYPE_INT);
1368 COUNT(count_pcmd_op);
1369 OPTT2_1(TYPE_DBL, TYPE_INT);
1377 case ICMD_INT2SHORT:
1378 COUNT(count_pcmd_op);
1379 OP1_1(TYPE_INT, TYPE_INT);
1382 COUNT(count_pcmd_op);
1383 OP1_1(TYPE_LNG, TYPE_LNG);
1386 COUNT(count_pcmd_op);
1387 OP1_1(TYPE_FLT, TYPE_FLT);
1390 COUNT(count_pcmd_op);
1391 OP1_1(TYPE_DBL, TYPE_DBL);
1395 COUNT(count_pcmd_op);
1396 OP1_1(TYPE_INT, TYPE_LNG);
1399 COUNT(count_pcmd_op);
1400 OP1_1(TYPE_INT, TYPE_FLT);
1403 COUNT(count_pcmd_op);
1404 OP1_1(TYPE_INT, TYPE_DBL);
1407 COUNT(count_pcmd_op);
1408 OP1_1(TYPE_LNG, TYPE_INT);
1411 COUNT(count_pcmd_op);
1412 OP1_1(TYPE_LNG, TYPE_FLT);
1415 COUNT(count_pcmd_op);
1416 OP1_1(TYPE_LNG, TYPE_DBL);
1419 COUNT(count_pcmd_op);
1420 OP1_1(TYPE_FLT, TYPE_INT);
1423 COUNT(count_pcmd_op);
1424 OP1_1(TYPE_FLT, TYPE_LNG);
1427 COUNT(count_pcmd_op);
1428 OP1_1(TYPE_FLT, TYPE_DBL);
1431 COUNT(count_pcmd_op);
1432 OP1_1(TYPE_DBL, TYPE_INT);
1435 COUNT(count_pcmd_op);
1436 OP1_1(TYPE_DBL, TYPE_LNG);
1439 COUNT(count_pcmd_op);
1440 OP1_1(TYPE_DBL, TYPE_FLT);
1443 case ICMD_CHECKCAST:
1444 OP1_1(TYPE_ADR, TYPE_ADR);
1447 case ICMD_ARRAYLENGTH:
1448 case ICMD_INSTANCEOF:
1449 OP1_1(TYPE_ADR, TYPE_INT);
1453 case ICMD_ANEWARRAY:
1454 OP1_1(TYPE_INT, TYPE_ADR);
1458 COUNT(count_check_null);
1459 COUNT(count_pcmd_mem);
1460 OP1_1(TYPE_ADR, iptr->op1);
1465 case ICMD_GETSTATIC:
1466 COUNT(count_pcmd_mem);
1476 tbptr = block + block_index[iptr->op1];
1478 iptr[0].target = (void *) tbptr;
1480 tbptr->type=BBTYPE_SBR;
1481 MARKREACHED(tbptr, copy);
1485 /* pop many push any */
1487 case ICMD_INVOKEVIRTUAL:
1488 case ICMD_INVOKESPECIAL:
1489 case ICMD_INVOKEINTERFACE:
1490 case ICMD_INVOKESTATIC:
1491 COUNT(count_pcmd_met);
1493 methodinfo *m = iptr->val.a;
1494 if (m->flags & ACC_STATIC)
1495 {COUNT(count_check_null);}
1497 if (i > arguments_num)
1499 #if defined(__X86_64__)
1507 (IS_FLT_DBL_TYPE(copy->type)) ? farg++ : iarg++;
1511 stackargs += (iarg < intreg_argnum) ? 0 : (iarg - intreg_argnum);
1512 stackargs += (farg < fltreg_argnum) ? 0 : (farg - fltreg_argnum);
1517 if (!(copy->flags & SAVEDVAR)) {
1518 copy->varkind = ARGVAR;
1519 if (IS_FLT_DBL_TYPE(copy->type)) {
1520 if (--farg < fltreg_argnum) {
1521 copy->varnum = farg;
1523 copy->varnum = --stackargs + intreg_argnum;
1526 if (--iarg < intreg_argnum) {
1527 copy->varnum = iarg;
1529 copy->varnum = --stackargs + intreg_argnum;
1533 (IS_FLT_DBL_TYPE(copy->type)) ? --farg : --iarg;
1541 if (! (copy->flags & SAVEDVAR)) {
1542 copy->varkind = ARGVAR;
1549 copy->flags |= SAVEDVAR;
1554 if (m->returntype != TYPE_VOID) {
1555 OP0_1(m->returntype);
1561 if (! (curstack->flags & SAVEDVAR)) {
1562 curstack->varkind = ARGVAR;
1563 curstack->varnum = 2;
1565 if (3 > arguments_num) {
1572 if (!(curstack->flags & SAVEDVAR)) {
1573 curstack->varkind = ARGVAR;
1574 curstack->varnum = 1;
1576 if (2 > arguments_num) {
1583 if (!(curstack->flags & SAVEDVAR)) {
1584 curstack->varkind = ARGVAR;
1585 curstack->varnum = 0;
1587 if (1 > arguments_num) {
1593 copy->flags |= SAVEDVAR;
1596 if (iptr->op1 != TYPE_VOID)
1600 case ICMD_MULTIANEWARRAY:
1602 if ((i + intreg_argnum) > arguments_num)
1603 arguments_num = i + intreg_argnum;
1606 if (! (copy->flags & SAVEDVAR)) {
1607 copy->varkind = ARGVAR;
1608 copy->varnum = i + intreg_argnum;
1613 copy->flags |= SAVEDVAR;
1621 case ICMD_CLEAR_ARGREN:
1622 for (i = iptr->op1; i<maxlocals; i++)
1624 iptr->opc = opcode = ICMD_NOP;
1628 case ICMD_READONLY_ARG:
1629 case ICMD_READONLY_ARG+1:
1630 case ICMD_READONLY_ARG+2:
1631 case ICMD_READONLY_ARG+3:
1632 case ICMD_READONLY_ARG+4:
1634 if (curstack->varkind == LOCALVAR) {
1635 i = curstack->varnum;
1636 argren[iptr->op1] = i;
1639 opcode = iptr->opc = opcode - ICMD_READONLY_ARG + ICMD_ISTORE;
1645 printf("ICMD %d at %d\n", iptr->opc, (int)(iptr-instr));
1646 panic("Missing ICMD code during stack analysis");
1649 } /* while instructions */
1650 bptr->outstack = curstack;
1651 bptr->outdepth = stackdepth;
1655 superblockend = true;
1657 } /* while blocks */
1658 } while (repeat && !deadcode);
1661 if (block_count > count_max_basic_blocks)
1662 count_max_basic_blocks = block_count;
1663 count_basic_blocks += block_count;
1664 if (instr_count > count_max_javainstr)
1665 count_max_javainstr = instr_count;
1666 count_javainstr += instr_count;
1667 if (stack_count > count_upper_bound_new_stack)
1668 count_upper_bound_new_stack = stack_count;
1669 if ((new - stack) > count_max_new_stack)
1670 count_max_new_stack = (new - stack);
1672 b_count = block_count;
1674 while (--b_count >= 0) {
1675 if (bptr->flags > BBREACHED) {
1676 if (bptr->indepth >= 10)
1677 count_block_stack[10]++;
1679 count_block_stack[bptr->indepth]++;
1682 count_block_size_distribution[len]++;
1684 count_block_size_distribution[10]++;
1686 count_block_size_distribution[11]++;
1688 count_block_size_distribution[12]++;
1690 count_block_size_distribution[13]++;
1692 count_block_size_distribution[14]++;
1694 count_block_size_distribution[15]++;
1696 count_block_size_distribution[16]++;
1698 count_block_size_distribution[17]++;
1704 count_analyse_iterations[0]++;
1705 else if (loops == 2)
1706 count_analyse_iterations[1]++;
1707 else if (loops == 3)
1708 count_analyse_iterations[2]++;
1709 else if (loops == 4)
1710 count_analyse_iterations[3]++;
1712 count_analyse_iterations[4]++;
1714 if (block_count <= 5)
1715 count_method_bb_distribution[0]++;
1716 else if (block_count <= 10)
1717 count_method_bb_distribution[1]++;
1718 else if (block_count <= 15)
1719 count_method_bb_distribution[2]++;
1720 else if (block_count <= 20)
1721 count_method_bb_distribution[3]++;
1722 else if (block_count <= 30)
1723 count_method_bb_distribution[4]++;
1724 else if (block_count <= 40)
1725 count_method_bb_distribution[5]++;
1726 else if (block_count <= 50)
1727 count_method_bb_distribution[6]++;
1728 else if (block_count <= 75)
1729 count_method_bb_distribution[7]++;
1731 count_method_bb_distribution[8]++;
1736 static void print_stack(stackptr s)
1753 if (s->flags & SAVEDVAR)
1754 switch (s->varkind) {
1756 if (s->flags & INMEMORY)
1757 printf(" M%02d", s->regoff);
1758 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1759 printf(" F%02d", s->regoff);
1761 printf(" %3s", regs[s->regoff]);
1764 printf(" I%02d", s->varnum);
1767 printf(" L%02d", s->varnum);
1770 printf(" A%02d", s->varnum);
1773 printf(" !%02d", j);
1776 switch (s->varkind) {
1778 if (s->flags & INMEMORY)
1779 printf(" m%02d", s->regoff);
1780 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1781 printf(" f%02d", s->regoff);
1783 printf(" %3s", regs[s->regoff]);
1786 printf(" i%02d", s->varnum);
1789 printf(" l%02d", s->varnum);
1792 printf(" a%02d", s->varnum);
1795 printf(" ?%02d", j);
1803 static void print_reg(stackptr s) {
1805 if (s->flags & SAVEDVAR)
1806 switch (s->varkind) {
1808 if (s->flags & INMEMORY)
1809 printf(" tm%02d", s->regoff);
1811 printf(" tr%02d", s->regoff);
1814 printf(" s %02d", s->varnum);
1817 printf(" l %02d", s->varnum);
1820 printf(" a %02d", s->varnum);
1823 printf(" ! %02d", s->varnum);
1826 switch (s->varkind) {
1828 if (s->flags & INMEMORY)
1829 printf(" Tm%02d", s->regoff);
1831 printf(" Tr%02d", s->regoff);
1834 printf(" S %02d", s->varnum);
1837 printf(" L %02d", s->varnum);
1840 printf(" A %02d", s->varnum);
1843 printf(" ? %02d", s->varnum);
1853 static char *builtin_name(functionptr bptr)
1855 builtin_descriptor *bdesc = builtin_desc;
1856 while ((bdesc->bptr != NULL) && (bdesc->bptr != bptr))
1862 static char *jit_type[] = {
1871 void show_icmd_method()
1882 utf_fprint(stdout, class->name);
1884 utf_fprint(stdout, method->name);
1886 utf_fprint(stdout, method->descriptor);
1887 printf ("\n\nMax locals: %d\n", (int) maxlocals);
1888 printf ("Max stack: %d\n", (int) maxstack);
1890 printf ("Exceptions (Number: %d):\n", exceptiontablelength);
1891 for (ex = extable; ex != NULL; ex = ex->down) {
1892 printf(" L%03d ... ", ex->start->debug_nr );
1893 printf("L%03d = ", ex->end->debug_nr);
1894 printf("L%03d\n", ex->handler->debug_nr);
1897 printf ("Local Table:\n");
1898 for (i = 0; i < maxlocals; i++) {
1899 printf(" %3d: ", i);
1900 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1901 if (locals[i][j].type >= 0) {
1902 printf(" (%s) ", jit_type[j]);
1903 if (locals[i][j].flags & INMEMORY)
1904 printf("m%2d", locals[i][j].regoff);
1905 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1906 printf("f%02d", locals[i][j].regoff);
1908 printf("%3s", regs[locals[i][j].regoff]);
1914 printf ("Interface Table:\n");
1915 for (i = 0; i < maxstack; i++) {
1916 if ((interfaces[i][0].type >= 0) || (interfaces[i][1].type >= 0) ||
1917 (interfaces[i][2].type >= 0) || (interfaces[i][3].type >= 0) ||
1918 (interfaces[i][4].type >= 0)) {
1919 printf(" %3d: ", i);
1920 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1921 if (interfaces[i][j].type >= 0) {
1922 printf(" (%s) ", jit_type[j]);
1923 if (interfaces[i][j].flags & SAVEDVAR) {
1924 if (interfaces[i][j].flags & INMEMORY)
1925 printf("M%2d", interfaces[i][j].regoff);
1926 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1927 printf("F%02d", interfaces[i][j].regoff);
1929 printf("%3s", regs[interfaces[i][j].regoff]);
1932 if (interfaces[i][j].flags & INMEMORY)
1933 printf("m%2d", interfaces[i][j].regoff);
1934 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1935 printf("f%02d", interfaces[i][j].regoff);
1937 printf("%3s", regs[interfaces[i][j].regoff]);
1945 if (showdisassemble) {
1946 #if defined(__I386__) || defined(__X86_64__)
1950 u1ptr = method->mcode + dseglen;
1951 for (i = 0; i < block[0].mpc; i++, u1ptr++) {
1952 a = disassinstr(u1ptr, i);
1958 s4ptr = (s4 *) (method->mcode + dseglen);
1959 for (i = 0; i < block[0].mpc; i += 4, s4ptr++) {
1960 disassinstr(*s4ptr, i);
1967 for (bptr = block; bptr != NULL; bptr = bptr->next) {
1968 if (bptr->flags != BBDELETED) {
1969 deadcode = bptr->flags <= BBREACHED;
1972 for (j = maxstack; j > 0; j--)
1975 print_stack(bptr->instack);
1976 printf("] L%03d(%d - %d):\n", bptr->debug_nr, bptr->icount, bptr->pre_count);
1977 iptr = bptr->iinstr;
1979 for (i=0; i < bptr->icount; i++, iptr++) {
1982 for (j = maxstack; j > 0; j--)
1986 print_stack(iptr->dst);
1987 printf("] %4d %s", i, icmd_names[iptr->opc]);
1988 switch ((int) iptr->opc) {
1989 case ICMD_IADDCONST:
1990 case ICMD_ISUBCONST:
1991 case ICMD_IMULCONST:
1994 case ICMD_IREM0X10001:
1995 case ICMD_IANDCONST:
1997 case ICMD_IXORCONST:
1998 case ICMD_ISHLCONST:
1999 case ICMD_ISHRCONST:
2000 case ICMD_IUSHRCONST:
2001 case ICMD_LSHLCONST:
2002 case ICMD_LSHRCONST:
2003 case ICMD_LUSHRCONST:
2005 case ICMD_ELSE_ICONST:
2006 case ICMD_IFEQ_ICONST:
2007 case ICMD_IFNE_ICONST:
2008 case ICMD_IFLT_ICONST:
2009 case ICMD_IFGE_ICONST:
2010 case ICMD_IFGT_ICONST:
2011 case ICMD_IFLE_ICONST:
2012 printf(" %d", iptr->val.i);
2014 case ICMD_LADDCONST:
2015 case ICMD_LSUBCONST:
2016 case ICMD_LMULCONST:
2019 case ICMD_LANDCONST:
2021 case ICMD_LXORCONST:
2023 #if defined(__I386__)
2024 printf(" %lld", iptr->val.l);
2026 printf(" %ld", iptr->val.l);
2030 printf(" %f", iptr->val.f);
2033 printf(" %f", iptr->val.d);
2036 printf(" %p", iptr->val.a);
2040 printf(" %d,", ((fieldinfo *) iptr->val.a)->offset);
2041 case ICMD_PUTSTATIC:
2042 case ICMD_GETSTATIC:
2045 ((fieldinfo *) iptr->val.a)->name);
2048 printf(" %d + %d", iptr->op1, iptr->val.i);
2083 printf(" %d", iptr->op1);
2088 ((classinfo *) iptr->val.a)->name);
2091 switch (iptr->op1) {
2118 case ICMD_ANEWARRAY:
2122 ((classinfo *) iptr->val.a)->name);
2125 case ICMD_CHECKCAST:
2126 case ICMD_INSTANCEOF:
2128 classinfo *c = iptr->val.a;
2129 if (c->flags & ACC_INTERFACE)
2130 printf(" (INTERFACE) ");
2132 printf(" (CLASS,%3d) ", c->vftbl->diffval);
2133 utf_fprint(stdout, c->name);
2139 printf(" %s", builtin_name((functionptr) iptr->val.a));
2141 case ICMD_INVOKEVIRTUAL:
2142 case ICMD_INVOKESPECIAL:
2143 case ICMD_INVOKESTATIC:
2144 case ICMD_INVOKEINTERFACE:
2147 ((methodinfo *) iptr->val.a)->class->name);
2150 ((methodinfo *) iptr->val.a)->name);
2158 printf("(%d) L%03d", iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
2166 printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
2171 case ICMD_IFNONNULL:
2172 case ICMD_IF_ICMPEQ:
2173 case ICMD_IF_ICMPNE:
2174 case ICMD_IF_ICMPLT:
2175 case ICMD_IF_ICMPGE:
2176 case ICMD_IF_ICMPGT:
2177 case ICMD_IF_ICMPLE:
2178 case ICMD_IF_LCMPEQ:
2179 case ICMD_IF_LCMPNE:
2180 case ICMD_IF_LCMPLT:
2181 case ICMD_IF_LCMPGE:
2182 case ICMD_IF_LCMPGT:
2183 case ICMD_IF_LCMPLE:
2184 case ICMD_IF_ACMPEQ:
2185 case ICMD_IF_ACMPNE:
2186 printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
2188 case ICMD_TABLESWITCH:
2190 s4ptr = iptr->val.a;
2191 tptr = (void **) iptr->target;
2193 printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
2199 j = *s4ptr++; /* low */
2200 j = *s4ptr++ - j; /* high */
2202 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2207 case ICMD_LOOKUPSWITCH:
2208 s4ptr = iptr->val.a;
2209 tptr = (void **) iptr->target;
2211 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2212 s4ptr++; /* default */
2213 j = *s4ptr; /* count */
2217 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2225 if (showdisassemble && (!deadcode)) {
2226 #if defined(__I386__) || defined(__X86_64__)
2232 u1ptr = method->mcode + dseglen + i;
2234 if (bptr->next != NULL) {
2235 for (; i < bptr->next->mpc; i++, u1ptr++) {
2236 a = disassinstr(u1ptr, i);
2243 for (; u1ptr < (u1 *) (method->mcode + method->mcodelength); i++, u1ptr++) {
2244 a = disassinstr(u1ptr, i);
2253 s4ptr = (s4 *) (method->mcode + dseglen + i);
2255 if (bptr->next != NULL) {
2256 for (; i < bptr->next->mpc; i += 4, s4ptr++) {
2257 disassinstr(*s4ptr, i);
2262 for (; s4ptr < (s4 *) (method->mcode + method->mcodelength); i += 4, s4ptr++) {
2263 disassinstr(*s4ptr, i);
2275 * These are local overrides for various environment variables in Emacs.
2276 * Please do not remove this and leave it at the end of the file, where
2277 * Emacs will automagically detect them.
2278 * ---------------------------------------------------------------------
2281 * indent-tabs-mode: t