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 557 2003-11-02 22:51:59Z twisti $
40 #include "toolbox/loging.h"
41 #include "toolbox/memory.h"
44 /* from codegen.inc */
49 #define COUNT(cnt) cnt++
54 #define STACKRESET {curstack=0;stackdepth=0;}
56 #define TYPEPANIC {show_icmd_method();panic("Stack type mismatch");}
57 #define CURKIND curstack->varkind
58 #define CURTYPE curstack->type
60 #define NEWSTACK(s,v,n) {new->prev=curstack;new->type=s;new->flags=0;\
61 new->varkind=v;new->varnum=n;curstack=new;new++;}
62 #define NEWSTACKn(s,n) NEWSTACK(s,UNDEFVAR,n)
63 #define NEWSTACK0(s) NEWSTACK(s,UNDEFVAR,0)
64 #define NEWXSTACK {NEWSTACK(TYPE_ADR,STACKVAR,0);curstack=0;}
66 #define SETDST {iptr->dst=curstack;}
67 #define POP(s) {if(s!=curstack->type){TYPEPANIC;}\
68 if(curstack->varkind==UNDEFVAR)curstack->varkind=TEMPVAR;\
69 curstack=curstack->prev;}
70 #define POPANY {if(curstack->varkind==UNDEFVAR)curstack->varkind=TEMPVAR;\
71 curstack=curstack->prev;}
72 #define COPY(s,d) {(d)->flags=0;(d)->type=(s)->type;\
73 (d)->varkind=(s)->varkind;(d)->varnum=(s)->varnum;}
75 #define PUSHCONST(s){NEWSTACKn(s,stackdepth);SETDST;stackdepth++;}
76 #define LOAD(s,v,n) {NEWSTACK(s,v,n);SETDST;stackdepth++;}
77 #define STORE(s) {POP(s);SETDST;stackdepth--;}
78 #define OP1_0(s) {POP(s);SETDST;stackdepth--;}
79 #define OP1_0ANY {POPANY;SETDST;stackdepth--;}
80 #define OP0_1(s) {NEWSTACKn(s,stackdepth);SETDST;stackdepth++;}
81 #define OP1_1(s,d) {POP(s);NEWSTACKn(d,stackdepth-1);SETDST;}
82 #define OP2_0(s) {POP(s);POP(s);SETDST;stackdepth-=2;}
83 #define OPTT2_0(t,b){POP(t);POP(b);SETDST;stackdepth-=2;}
84 #define OP2_1(s) {POP(s);POP(s);NEWSTACKn(s,stackdepth-2);SETDST;stackdepth--;}
85 #define OP2IAT_1(s) {POP(TYPE_INT);POP(TYPE_ADR);NEWSTACKn(s,stackdepth-2);\
87 #define OP2IT_1(s) {POP(TYPE_INT);POP(s);NEWSTACKn(s,stackdepth-2);\
89 #define OPTT2_1(s,d){POP(s);POP(s);NEWSTACKn(d,stackdepth-2);SETDST;stackdepth--;}
90 #define OP2_2(s) {POP(s);POP(s);NEWSTACKn(s,stackdepth-2);\
91 NEWSTACKn(s,stackdepth-1);SETDST;}
92 #define OP3TIA_0(s) {POP(s);POP(TYPE_INT);POP(TYPE_ADR);SETDST;stackdepth-=3;}
93 #define OP3_0(s) {POP(s);POP(s);POP(s);SETDST;stackdepth-=3;}
94 #define POPMANY(i) {stackdepth-=i;while(--i>=0){POPANY;}SETDST;}
95 #define DUP {NEWSTACK(CURTYPE,CURKIND,curstack->varnum);SETDST;\
97 #define SWAP {COPY(curstack,new);POPANY;COPY(curstack,new+1);POPANY;\
98 new[0].prev=curstack;new[1].prev=new;\
99 curstack=new+1;new+=2;SETDST;}
100 #define DUP_X1 {COPY(curstack,new);COPY(curstack,new+2);POPANY;\
101 COPY(curstack,new+1);POPANY;new[0].prev=curstack;\
102 new[1].prev=new;new[2].prev=new+1;\
103 curstack=new+2;new+=3;SETDST;stackdepth++;}
104 #define DUP2_X1 {COPY(curstack,new+1);COPY(curstack,new+4);POPANY;\
105 COPY(curstack,new);COPY(curstack,new+3);POPANY;\
106 COPY(curstack,new+2);POPANY;new[0].prev=curstack;\
107 new[1].prev=new;new[2].prev=new+1;\
108 new[3].prev=new+2;new[4].prev=new+3;\
109 curstack=new+4;new+=5;SETDST;stackdepth+=2;}
110 #define DUP_X2 {COPY(curstack,new);COPY(curstack,new+3);POPANY;\
111 COPY(curstack,new+2);POPANY;COPY(curstack,new+1);POPANY;\
112 new[0].prev=curstack;new[1].prev=new;\
113 new[2].prev=new+1;new[3].prev=new+2;\
114 curstack=new+3;new+=4;SETDST;stackdepth++;}
115 #define DUP2_X2 {COPY(curstack,new+1);COPY(curstack,new+5);POPANY;\
116 COPY(curstack,new);COPY(curstack,new+4);POPANY;\
117 COPY(curstack,new+3);POPANY;COPY(curstack,new+2);POPANY;\
118 new[0].prev=curstack;new[1].prev=new;\
119 new[2].prev=new+1;new[3].prev=new+2;\
120 new[4].prev=new+3;new[5].prev=new+4;\
121 curstack=new+5;new+=6;SETDST;stackdepth+=2;}
123 #define COPYCURSTACK(copy) {\
136 copy->varkind=STACKVAR;\
152 if((copy->varkind==STACKVAR)&&(copy->varnum>i))\
153 copy->varkind=TEMPVAR;\
155 copy->varkind=STACKVAR;\
158 interfaces[i][copy->type].type = copy->type;\
159 interfaces[i][copy->type].flags |= copy->flags;\
160 i--;copy=copy->prev;\
165 interfaces[i][copy->type].type = copy->type;\
166 if(copy->varkind==STACKVAR){\
167 if (copy->flags & SAVEDVAR)\
168 interfaces[i][copy->type].flags |= SAVEDVAR;\
170 i--;copy=copy->prev;\
175 #define MARKREACHED(b,c) {\
177 {COPYCURSTACK(c);b->flags=0;b->instack=c;b->indepth=stackdepth;}\
178 else {stackptr s=curstack;stackptr t=b->instack;\
179 if(b->indepth!=stackdepth)\
180 {show_icmd_method();panic("Stack depth mismatch");}\
181 while(s){if (s->type!=t->type)\
183 s=s->prev;t=t->prev;\
188 #ifdef USEBUILTINTABLE
189 static stdopdescriptor *find_builtin(stdopdescriptor *first, stdopdescriptor *last,
192 int len = last - first;
194 stdopdescriptor *middle;
198 middle = first + half;
199 if (middle->opcode < icmd) {
218 int opcode, i, len, loops;
219 int superblockend, repeat, deadcode;
226 // int *argren = DMNEW(int, maxlocals);
227 int *argren = (int *)alloca(maxlocals * sizeof(int)); /* table for argument renaming */
228 for (i = 0; i < maxlocals; i++)
234 block[0].flags = BBREACHED;
235 block[0].instack = 0;
236 block[0].indepth = 0;
238 for (i = 0; i < exceptiontablelength; i++) {
239 bptr = &block[block_index[extable[i].handlerpc]];
240 bptr->flags = BBREACHED;
241 bptr->type = BBTYPE_EXH;
244 bptr->pre_count = 10000;
249 #ifdef CONDITIONAL_LOADCONST
250 b_count = block_count;
252 while (--b_count >= 0) {
253 if (bptr->icount != 0) {
254 iptr = bptr->iinstr + bptr->icount - 1;
287 block[block_index[iptr->op1]].pre_count++;
290 case ICMD_TABLESWITCH:
292 block[block_index[*s4ptr++]].pre_count++; /* default */
293 i = *s4ptr++; /* low */
294 i = *s4ptr++ - i + 1; /* high */
296 block[block_index[*s4ptr++]].pre_count++;
300 case ICMD_LOOKUPSWITCH:
302 block[block_index[*s4ptr++]].pre_count++; /* default */
303 i = *s4ptr++; /* count */
305 block[block_index[s4ptr[1]]].pre_count++;
321 b_count = block_count;
323 superblockend = true;
327 while (--b_count >= 0) {
328 if (bptr->flags == BBDELETED) {
331 else if (superblockend && (bptr->flags < BBREACHED))
333 else if (bptr->flags <= BBREACHED) {
335 stackdepth = bptr->indepth;
336 else if (bptr->flags < BBREACHED) {
338 bptr->instack = copy;
339 bptr->indepth = stackdepth;
341 else if (bptr->indepth != stackdepth) {
343 panic("Stack depth mismatch");
346 curstack = bptr->instack;
348 superblockend = false;
349 bptr->flags = BBFINISHED;
352 b_index = bptr - block;
357 #ifdef USEBUILTINTABLE
359 stdopdescriptor *blast = builtintable + sizeof(builtintable)/sizeof(stdopdescriptor);
360 stdopdescriptor *breplace;
361 breplace = find_builtin(builtintable, blast, opcode);
362 if (breplace != blast && opcode == breplace->opcode && !breplace->supported) {
363 iptr[0].opc = breplace->icmd;
364 iptr[0].op1 = breplace->type_d;
365 iptr[0].val.a = breplace->builtin;
366 isleafmethod = false;
367 switch (breplace->icmd) {
382 case ICMD_CHECKASIZE:
384 case ICMD_IFEQ_ICONST:
385 case ICMD_IFNE_ICONST:
386 case ICMD_IFLT_ICONST:
387 case ICMD_IFGE_ICONST:
388 case ICMD_IFGT_ICONST:
389 case ICMD_IFLE_ICONST:
390 case ICMD_ELSE_ICONST:
395 locals[iptr->op1][TYPE_ADR].type = TYPE_ADR;
397 COUNT(count_pcmd_return);
399 superblockend = true;
402 /* pop 0 push 1 const */
405 COUNT(count_pcmd_load);
407 switch (iptr[1].opc) {
409 iptr[0].opc = ICMD_IADDCONST;
411 iptr[1].opc = ICMD_NOP;
412 OP1_1(TYPE_INT,TYPE_INT);
413 COUNT(count_pcmd_op);
416 iptr[0].opc = ICMD_ISUBCONST;
417 goto icmd_iconst_tail;
419 iptr[0].opc = ICMD_IMULCONST;
420 goto icmd_iconst_tail;
422 if (iptr[0].val.i == 0x00000002)
424 else if (iptr[0].val.i == 0x00000004)
426 else if (iptr[0].val.i == 0x00000008)
428 else if (iptr[0].val.i == 0x00000010)
430 else if (iptr[0].val.i == 0x00000020)
432 else if (iptr[0].val.i == 0x00000040)
434 else if (iptr[0].val.i == 0x00000080)
436 else if (iptr[0].val.i == 0x00000100)
438 else if (iptr[0].val.i == 0x00000200)
440 else if (iptr[0].val.i == 0x00000400)
442 else if (iptr[0].val.i == 0x00000800)
444 else if (iptr[0].val.i == 0x00001000)
446 else if (iptr[0].val.i == 0x00002000)
448 else if (iptr[0].val.i == 0x00004000)
450 else if (iptr[0].val.i == 0x00008000)
452 else if (iptr[0].val.i == 0x00010000)
454 else if (iptr[0].val.i == 0x00020000)
456 else if (iptr[0].val.i == 0x00040000)
458 else if (iptr[0].val.i == 0x00080000)
460 else if (iptr[0].val.i == 0x00100000)
462 else if (iptr[0].val.i == 0x00200000)
464 else if (iptr[0].val.i == 0x00400000)
466 else if (iptr[0].val.i == 0x00800000)
468 else if (iptr[0].val.i == 0x01000000)
470 else if (iptr[0].val.i == 0x02000000)
472 else if (iptr[0].val.i == 0x04000000)
474 else if (iptr[0].val.i == 0x08000000)
476 else if (iptr[0].val.i == 0x10000000)
478 else if (iptr[0].val.i == 0x20000000)
480 else if (iptr[0].val.i == 0x40000000)
482 else if (iptr[0].val.i == 0x80000000)
488 iptr[0].opc = ICMD_IDIVPOW2;
489 goto icmd_iconst_tail;
491 #if !defined(NO_DIV_OPT)
492 if (iptr[0].val.i == 0x10001) {
493 iptr[0].opc = ICMD_IREM0X10001;
494 goto icmd_iconst_tail;
497 if ((iptr[0].val.i == 0x00000002) ||
498 (iptr[0].val.i == 0x00000004) ||
499 (iptr[0].val.i == 0x00000008) ||
500 (iptr[0].val.i == 0x00000010) ||
501 (iptr[0].val.i == 0x00000020) ||
502 (iptr[0].val.i == 0x00000040) ||
503 (iptr[0].val.i == 0x00000080) ||
504 (iptr[0].val.i == 0x00000100) ||
505 (iptr[0].val.i == 0x00000200) ||
506 (iptr[0].val.i == 0x00000400) ||
507 (iptr[0].val.i == 0x00000800) ||
508 (iptr[0].val.i == 0x00001000) ||
509 (iptr[0].val.i == 0x00002000) ||
510 (iptr[0].val.i == 0x00004000) ||
511 (iptr[0].val.i == 0x00008000) ||
512 (iptr[0].val.i == 0x00010000) ||
513 (iptr[0].val.i == 0x00020000) ||
514 (iptr[0].val.i == 0x00040000) ||
515 (iptr[0].val.i == 0x00080000) ||
516 (iptr[0].val.i == 0x00100000) ||
517 (iptr[0].val.i == 0x00200000) ||
518 (iptr[0].val.i == 0x00400000) ||
519 (iptr[0].val.i == 0x00800000) ||
520 (iptr[0].val.i == 0x01000000) ||
521 (iptr[0].val.i == 0x02000000) ||
522 (iptr[0].val.i == 0x04000000) ||
523 (iptr[0].val.i == 0x08000000) ||
524 (iptr[0].val.i == 0x10000000) ||
525 (iptr[0].val.i == 0x20000000) ||
526 (iptr[0].val.i == 0x40000000) ||
527 (iptr[0].val.i == 0x80000000)) {
528 iptr[0].opc = ICMD_IREMPOW2;
530 goto icmd_iconst_tail;
535 iptr[0].opc = ICMD_IANDCONST;
536 goto icmd_iconst_tail;
538 iptr[0].opc = ICMD_IORCONST;
539 goto icmd_iconst_tail;
541 iptr[0].opc = ICMD_IXORCONST;
542 goto icmd_iconst_tail;
544 iptr[0].opc = ICMD_ISHLCONST;
545 goto icmd_iconst_tail;
547 iptr[0].opc = ICMD_ISHRCONST;
548 goto icmd_iconst_tail;
550 iptr[0].opc = ICMD_IUSHRCONST;
551 goto icmd_iconst_tail;
552 #if SUPPORT_LONG_SHIFT
554 iptr[0].opc = ICMD_LSHLCONST;
555 goto icmd_lconst_tail;
557 iptr[0].opc = ICMD_LSHRCONST;
558 goto icmd_lconst_tail;
560 iptr[0].opc = ICMD_LUSHRCONST;
561 goto icmd_lconst_tail;
564 iptr[0].opc = ICMD_IFEQ;
566 iptr[0].op1 = iptr[1].op1;
569 /* iptr[1].opc = ICMD_NOP; */
571 tbptr = block + block_index[iptr->op1];
573 iptr[0].target = (void *) tbptr;
575 MARKREACHED(tbptr, copy);
576 COUNT(count_pcmd_bra);
579 iptr[0].opc = ICMD_IFLT;
580 goto icmd_if_icmp_tail;
582 iptr[0].opc = ICMD_IFLE;
583 goto icmd_if_icmp_tail;
585 iptr[0].opc = ICMD_IFNE;
586 goto icmd_if_icmp_tail;
588 iptr[0].opc = ICMD_IFGT;
589 goto icmd_if_icmp_tail;
591 iptr[0].opc = ICMD_IFGE;
592 goto icmd_if_icmp_tail;
601 COUNT(count_pcmd_load);
603 switch (iptr[1].opc) {
606 iptr[0].opc = ICMD_LADDCONST;
608 iptr[1].opc = ICMD_NOP;
609 OP1_1(TYPE_LNG,TYPE_LNG);
610 COUNT(count_pcmd_op);
613 iptr[0].opc = ICMD_LSUBCONST;
614 goto icmd_lconst_tail;
616 #if SUPPORT_LONG_MULDIV
618 iptr[0].opc = ICMD_LMULCONST;
619 goto icmd_lconst_tail;
621 if (iptr[0].val.l == 0x00000002)
623 else if (iptr[0].val.l == 0x00000004)
625 else if (iptr[0].val.l == 0x00000008)
627 else if (iptr[0].val.l == 0x00000010)
629 else if (iptr[0].val.l == 0x00000020)
631 else if (iptr[0].val.l == 0x00000040)
633 else if (iptr[0].val.l == 0x00000080)
635 else if (iptr[0].val.l == 0x00000100)
637 else if (iptr[0].val.l == 0x00000200)
639 else if (iptr[0].val.l == 0x00000400)
641 else if (iptr[0].val.l == 0x00000800)
643 else if (iptr[0].val.l == 0x00001000)
645 else if (iptr[0].val.l == 0x00002000)
647 else if (iptr[0].val.l == 0x00004000)
649 else if (iptr[0].val.l == 0x00008000)
651 else if (iptr[0].val.l == 0x00010000)
653 else if (iptr[0].val.l == 0x00020000)
655 else if (iptr[0].val.l == 0x00040000)
657 else if (iptr[0].val.l == 0x00080000)
659 else if (iptr[0].val.l == 0x00100000)
661 else if (iptr[0].val.l == 0x00200000)
663 else if (iptr[0].val.l == 0x00400000)
665 else if (iptr[0].val.l == 0x00800000)
667 else if (iptr[0].val.l == 0x01000000)
669 else if (iptr[0].val.l == 0x02000000)
671 else if (iptr[0].val.l == 0x04000000)
673 else if (iptr[0].val.l == 0x08000000)
675 else if (iptr[0].val.l == 0x10000000)
677 else if (iptr[0].val.l == 0x20000000)
679 else if (iptr[0].val.l == 0x40000000)
681 else if (iptr[0].val.l == 0x80000000)
687 iptr[0].opc = ICMD_LDIVPOW2;
688 goto icmd_lconst_tail;
690 #if !defined(NO_DIV_OPT)
691 if (iptr[0].val.l == 0x10001) {
692 iptr[0].opc = ICMD_LREM0X10001;
693 goto icmd_lconst_tail;
696 if ((iptr[0].val.l == 0x00000002) ||
697 (iptr[0].val.l == 0x00000004) ||
698 (iptr[0].val.l == 0x00000008) ||
699 (iptr[0].val.l == 0x00000010) ||
700 (iptr[0].val.l == 0x00000020) ||
701 (iptr[0].val.l == 0x00000040) ||
702 (iptr[0].val.l == 0x00000080) ||
703 (iptr[0].val.l == 0x00000100) ||
704 (iptr[0].val.l == 0x00000200) ||
705 (iptr[0].val.l == 0x00000400) ||
706 (iptr[0].val.l == 0x00000800) ||
707 (iptr[0].val.l == 0x00001000) ||
708 (iptr[0].val.l == 0x00002000) ||
709 (iptr[0].val.l == 0x00004000) ||
710 (iptr[0].val.l == 0x00008000) ||
711 (iptr[0].val.l == 0x00010000) ||
712 (iptr[0].val.l == 0x00020000) ||
713 (iptr[0].val.l == 0x00040000) ||
714 (iptr[0].val.l == 0x00080000) ||
715 (iptr[0].val.l == 0x00100000) ||
716 (iptr[0].val.l == 0x00200000) ||
717 (iptr[0].val.l == 0x00400000) ||
718 (iptr[0].val.l == 0x00800000) ||
719 (iptr[0].val.l == 0x01000000) ||
720 (iptr[0].val.l == 0x02000000) ||
721 (iptr[0].val.l == 0x04000000) ||
722 (iptr[0].val.l == 0x08000000) ||
723 (iptr[0].val.l == 0x10000000) ||
724 (iptr[0].val.l == 0x20000000) ||
725 (iptr[0].val.l == 0x40000000) ||
726 (iptr[0].val.l == 0x80000000)) {
727 iptr[0].opc = ICMD_LREMPOW2;
729 goto icmd_lconst_tail;
736 iptr[0].opc = ICMD_LANDCONST;
737 goto icmd_lconst_tail;
739 iptr[0].opc = ICMD_LORCONST;
740 goto icmd_lconst_tail;
742 iptr[0].opc = ICMD_LXORCONST;
743 goto icmd_lconst_tail;
745 #if defined(NOLONG_CONDITIONAL)
747 if ((len > 1) && (iptr[2].val.i == 0)) {
748 switch (iptr[2].opc) {
750 iptr[0].opc = ICMD_IF_LEQ;
751 icmd_lconst_lcmp_tail:
752 iptr[0].op1 = iptr[2].op1;
755 /* iptr[1].opc = ICMD_NOP;
756 iptr[2].opc = ICMD_NOP; */
758 tbptr = block + block_index[iptr->op1];
760 iptr[0].target = (void *) tbptr;
762 MARKREACHED(tbptr, copy);
763 COUNT(count_pcmd_bra);
764 COUNT(count_pcmd_op);
767 iptr[0].opc = ICMD_IF_LNE;
768 goto icmd_lconst_lcmp_tail;
770 iptr[0].opc = ICMD_IF_LLT;
771 goto icmd_lconst_lcmp_tail;
773 iptr[0].opc = ICMD_IF_LGT;
774 goto icmd_lconst_lcmp_tail;
776 iptr[0].opc = ICMD_IF_LLE;
777 goto icmd_lconst_lcmp_tail;
779 iptr[0].opc = ICMD_IF_LGE;
780 goto icmd_lconst_lcmp_tail;
783 } /* switch (iptr[2].opc) */
784 } /* if (iptr[2].val.i == 0) */
797 COUNT(count_pcmd_load);
801 COUNT(count_pcmd_load);
805 COUNT(count_pcmd_load);
809 /* pop 0 push 1 load */
816 COUNT(count_load_instruction);
817 i = opcode-ICMD_ILOAD;
818 iptr->op1 = argren[iptr->op1];
819 locals[iptr->op1][i].type = i;
820 LOAD(i, LOCALVAR, iptr->op1);
830 COUNT(count_check_null);
831 COUNT(count_check_bound);
832 COUNT(count_pcmd_mem);
833 OP2IAT_1(opcode-ICMD_IALOAD);
839 COUNT(count_check_null);
840 COUNT(count_check_bound);
841 COUNT(count_pcmd_mem);
845 /* pop 0 push 0 iinc */
851 count_store_depth[10]++;
853 count_store_depth[i]++;
858 if ((copy->varkind == LOCALVAR) &&
859 (copy->varnum == iptr->op1)) {
860 copy->varkind = TEMPVAR;
869 /* pop 1 push 0 store */
878 i = opcode-ICMD_ISTORE;
879 locals[iptr->op1][i].type = i;
884 count_store_length[20]++;
886 count_store_length[i]++;
889 count_store_depth[10]++;
891 count_store_depth[i]++;
893 copy = curstack->prev;
896 if ((copy->varkind == LOCALVAR) &&
897 (copy->varnum == iptr->op1)) {
898 copy->varkind = TEMPVAR;
904 if ((new - curstack) == 1) {
905 curstack->varkind = LOCALVAR;
906 curstack->varnum = iptr->op1;
908 STORE(opcode-ICMD_ISTORE);
918 COUNT(count_check_null);
919 COUNT(count_check_bound);
920 COUNT(count_pcmd_mem);
921 OP3TIA_0(opcode-ICMD_IASTORE);
926 COUNT(count_check_null);
927 COUNT(count_check_bound);
928 COUNT(count_pcmd_mem);
943 COUNT(count_pcmd_return);
944 OP1_0(opcode-ICMD_IRETURN);
945 superblockend = true;
949 COUNT(count_check_null);
953 superblockend = true;
957 COUNT(count_pcmd_mem);
961 /* pop 1 push 0 branch */
965 COUNT(count_pcmd_bra);
967 tbptr = block + block_index[iptr->op1];
969 iptr[0].target = (void *) tbptr;
971 MARKREACHED(tbptr, copy);
980 COUNT(count_pcmd_bra);
981 #ifdef CONDITIONAL_LOADCONST
983 tbptr = block + b_index;
984 if ((b_count >= 3) &&
985 ((b_index + 2) == block_index[iptr[0].op1]) &&
986 (tbptr[1].pre_count == 1) &&
987 (iptr[1].opc == ICMD_ICONST) &&
988 (iptr[2].opc == ICMD_GOTO) &&
989 ((b_index + 3) == block_index[iptr[2].op1]) &&
990 (tbptr[2].pre_count == 1) &&
991 (iptr[3].opc == ICMD_ICONST)) {
992 OP1_1(TYPE_INT, TYPE_INT);
993 switch (iptr[0].opc) {
995 iptr[0].opc = ICMD_IFNE_ICONST;
998 iptr[0].opc = ICMD_IFEQ_ICONST;
1001 iptr[0].opc = ICMD_IFGE_ICONST;
1004 iptr[0].opc = ICMD_IFLT_ICONST;
1007 iptr[0].opc = ICMD_IFLE_ICONST;
1010 iptr[0].opc = ICMD_IFGT_ICONST;
1013 iptr[0].val.i = iptr[1].val.i;
1014 iptr[1].opc = ICMD_ELSE_ICONST;
1015 iptr[1].val.i = iptr[3].val.i;
1016 iptr[2].opc = ICMD_NOP;
1017 iptr[3].opc = ICMD_NOP;
1018 tbptr[1].flags = BBDELETED;
1019 tbptr[2].flags = BBDELETED;
1020 tbptr[1].icount = 0;
1021 tbptr[2].icount = 0;
1022 if (tbptr[3].pre_count == 2) {
1023 len += tbptr[3].icount + 3;
1024 bptr->icount += tbptr[3].icount + 3;
1025 tbptr[3].flags = BBDELETED;
1026 tbptr[3].icount = 0;
1039 tbptr = block + block_index[iptr->op1];
1041 iptr[0].target = (void *) tbptr;
1043 MARKREACHED(tbptr, copy);
1046 /* pop 0 push 0 branch */
1049 COUNT(count_pcmd_bra);
1050 tbptr = block + block_index[iptr->op1];
1052 iptr[0].target = (void *) tbptr;
1054 MARKREACHED(tbptr, copy);
1056 superblockend = true;
1059 /* pop 1 push 0 table branch */
1061 case ICMD_TABLESWITCH:
1062 COUNT(count_pcmd_table);
1064 s4ptr = iptr->val.a;
1065 tbptr = block + block_index[*s4ptr++]; /* default */
1066 MARKREACHED(tbptr, copy);
1067 i = *s4ptr++; /* low */
1068 i = *s4ptr++ - i + 1; /* high */
1070 tptr = DMNEW(void*, i+1);
1071 iptr->target = (void *) tptr;
1073 tptr[0] = (void *) tbptr;
1077 tbptr = block + block_index[*s4ptr++];
1079 tptr[0] = (void *) tbptr;
1082 MARKREACHED(tbptr, copy);
1085 superblockend = true;
1088 /* pop 1 push 0 table branch */
1090 case ICMD_LOOKUPSWITCH:
1091 COUNT(count_pcmd_table);
1093 s4ptr = iptr->val.a;
1094 tbptr = block + block_index[*s4ptr++]; /* default */
1095 MARKREACHED(tbptr, copy);
1096 i = *s4ptr++; /* count */
1098 tptr = DMNEW(void*, i+1);
1099 iptr->target = (void *) tptr;
1101 tptr[0] = (void *) tbptr;
1105 tbptr = block + block_index[s4ptr[1]];
1107 tptr[0] = (void *) tbptr;
1110 MARKREACHED(tbptr, copy);
1114 superblockend = true;
1117 case ICMD_NULLCHECKPOP:
1118 case ICMD_MONITORENTER:
1119 COUNT(count_check_null);
1120 case ICMD_MONITOREXIT:
1124 /* pop 2 push 0 branch */
1126 case ICMD_IF_ICMPEQ:
1127 case ICMD_IF_ICMPNE:
1128 case ICMD_IF_ICMPLT:
1129 case ICMD_IF_ICMPGE:
1130 case ICMD_IF_ICMPGT:
1131 case ICMD_IF_ICMPLE:
1132 COUNT(count_pcmd_bra);
1134 tbptr = block + block_index[iptr->op1];
1136 iptr[0].target = (void *) tbptr;
1138 MARKREACHED(tbptr, copy);
1141 case ICMD_IF_ACMPEQ:
1142 case ICMD_IF_ACMPNE:
1143 COUNT(count_pcmd_bra);
1145 tbptr = block + block_index[iptr->op1];
1147 iptr[0].target = (void *) tbptr;
1149 MARKREACHED(tbptr, copy);
1155 COUNT(count_check_null);
1156 COUNT(count_pcmd_mem);
1157 OPTT2_0(iptr->op1,TYPE_ADR);
1161 if (! IS_2_WORD_TYPE(curstack->type)) {
1162 OP1_0ANY; /* second pop */
1165 iptr->opc = ICMD_POP;
1169 /* pop 0 push 1 dup */
1172 COUNT(count_dup_instruction);
1177 if (IS_2_WORD_TYPE(curstack->type)) {
1178 iptr->opc = ICMD_DUP;
1183 NEWSTACK(copy->prev->type, copy->prev->varkind,
1184 copy->prev->varnum);
1185 NEWSTACK(copy->type, copy->varkind,
1192 /* pop 2 push 3 dup */
1199 if (IS_2_WORD_TYPE(curstack->type)) {
1200 iptr->opc = ICMD_DUP_X1;
1208 /* pop 3 push 4 dup */
1211 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1212 iptr->opc = ICMD_DUP_X1;
1221 if (IS_2_WORD_TYPE(curstack->type)) {
1222 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1223 iptr->opc = ICMD_DUP_X1;
1227 iptr->opc = ICMD_DUP_X2;
1232 if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1233 iptr->opc = ICMD_DUP2_X1;
1241 /* pop 2 push 2 swap */
1250 #if !SUPPORT_DIVISION
1251 iptr[0].opc = ICMD_BUILTIN2;
1252 iptr[0].op1 = TYPE_INT;
1253 iptr[0].val.a = (functionptr) asm_builtin_idiv;
1254 isleafmethod = false;
1259 #if !SUPPORT_DIVISION
1260 iptr[0].opc = ICMD_BUILTIN2;
1261 iptr[0].op1 = TYPE_INT;
1262 iptr[0].val.a = (functionptr) asm_builtin_irem;
1263 isleafmethod = false;
1277 COUNT(count_pcmd_op);
1282 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_MULDIV)
1283 iptr[0].opc = ICMD_BUILTIN2;
1284 iptr[0].op1 = TYPE_LNG;
1285 iptr[0].val.a = (functionptr) asm_builtin_ldiv;
1286 isleafmethod = false;
1291 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_MULDIV)
1292 iptr[0].opc = ICMD_BUILTIN2;
1293 iptr[0].op1 = TYPE_LNG;
1294 iptr[0].val.a = (functionptr) asm_builtin_lrem;
1295 isleafmethod = false;
1306 COUNT(count_pcmd_op);
1313 COUNT(count_pcmd_op);
1322 COUNT(count_pcmd_op);
1331 COUNT(count_pcmd_op);
1336 COUNT(count_pcmd_op);
1337 #ifndef NOLONG_CONDITIONAL
1338 if ((len > 0) && (iptr[1].val.i == 0)) {
1339 switch (iptr[1].opc) {
1341 iptr[0].opc = ICMD_IF_LCMPEQ;
1343 iptr[0].op1 = iptr[1].op1;
1346 /* iptr[1].opc = ICMD_NOP; */
1348 tbptr = block + block_index[iptr->op1];
1350 iptr[0].target = (void *) tbptr;
1352 MARKREACHED(tbptr, copy);
1353 COUNT(count_pcmd_bra);
1356 iptr[0].opc = ICMD_IF_LCMPNE;
1357 goto icmd_lcmp_if_tail;
1359 iptr[0].opc = ICMD_IF_LCMPLT;
1360 goto icmd_lcmp_if_tail;
1362 iptr[0].opc = ICMD_IF_LCMPGT;
1363 goto icmd_lcmp_if_tail;
1365 iptr[0].opc = ICMD_IF_LCMPLE;
1366 goto icmd_lcmp_if_tail;
1368 iptr[0].opc = ICMD_IF_LCMPGE;
1369 goto icmd_lcmp_if_tail;
1371 OPTT2_1(TYPE_LNG, TYPE_INT);
1376 OPTT2_1(TYPE_LNG, TYPE_INT);
1380 COUNT(count_pcmd_op);
1381 OPTT2_1(TYPE_FLT, TYPE_INT);
1385 COUNT(count_pcmd_op);
1386 OPTT2_1(TYPE_DBL, TYPE_INT);
1394 case ICMD_INT2SHORT:
1395 COUNT(count_pcmd_op);
1396 OP1_1(TYPE_INT, TYPE_INT);
1399 COUNT(count_pcmd_op);
1400 OP1_1(TYPE_LNG, TYPE_LNG);
1403 COUNT(count_pcmd_op);
1404 OP1_1(TYPE_FLT, TYPE_FLT);
1407 COUNT(count_pcmd_op);
1408 OP1_1(TYPE_DBL, TYPE_DBL);
1412 COUNT(count_pcmd_op);
1413 OP1_1(TYPE_INT, TYPE_LNG);
1416 COUNT(count_pcmd_op);
1417 OP1_1(TYPE_INT, TYPE_FLT);
1420 COUNT(count_pcmd_op);
1421 OP1_1(TYPE_INT, TYPE_DBL);
1424 COUNT(count_pcmd_op);
1425 OP1_1(TYPE_LNG, TYPE_INT);
1428 COUNT(count_pcmd_op);
1429 OP1_1(TYPE_LNG, TYPE_FLT);
1432 COUNT(count_pcmd_op);
1433 OP1_1(TYPE_LNG, TYPE_DBL);
1436 COUNT(count_pcmd_op);
1437 OP1_1(TYPE_FLT, TYPE_INT);
1440 COUNT(count_pcmd_op);
1441 OP1_1(TYPE_FLT, TYPE_LNG);
1444 COUNT(count_pcmd_op);
1445 OP1_1(TYPE_FLT, TYPE_DBL);
1448 COUNT(count_pcmd_op);
1449 OP1_1(TYPE_DBL, TYPE_INT);
1452 COUNT(count_pcmd_op);
1453 OP1_1(TYPE_DBL, TYPE_LNG);
1456 COUNT(count_pcmd_op);
1457 OP1_1(TYPE_DBL, TYPE_FLT);
1460 case ICMD_CHECKCAST:
1461 OP1_1(TYPE_ADR, TYPE_ADR);
1464 case ICMD_ARRAYLENGTH:
1465 case ICMD_INSTANCEOF:
1466 OP1_1(TYPE_ADR, TYPE_INT);
1470 case ICMD_ANEWARRAY:
1471 OP1_1(TYPE_INT, TYPE_ADR);
1475 COUNT(count_check_null);
1476 COUNT(count_pcmd_mem);
1477 OP1_1(TYPE_ADR, iptr->op1);
1482 case ICMD_GETSTATIC:
1483 COUNT(count_pcmd_mem);
1493 tbptr = block + block_index[iptr->op1];
1495 iptr[0].target = (void *) tbptr;
1497 tbptr->type=BBTYPE_SBR;
1498 MARKREACHED(tbptr, copy);
1502 /* pop many push any */
1504 case ICMD_INVOKEVIRTUAL:
1505 case ICMD_INVOKESPECIAL:
1506 case ICMD_INVOKEINTERFACE:
1507 case ICMD_INVOKESTATIC:
1508 COUNT(count_pcmd_met);
1510 methodinfo *m = iptr->val.a;
1511 if (m->flags & ACC_STATIC)
1512 {COUNT(count_check_null);}
1514 if (i > arguments_num)
1516 #if defined(__X86_64__)
1524 (IS_FLT_DBL_TYPE(copy->type)) ? farg++ : iarg++;
1528 stackargs += (iarg < intreg_argnum) ? 0 : (iarg - intreg_argnum);
1529 stackargs += (farg < fltreg_argnum) ? 0 : (farg - fltreg_argnum);
1534 if (!(copy->flags & SAVEDVAR)) {
1535 copy->varkind = ARGVAR;
1536 if (IS_FLT_DBL_TYPE(copy->type)) {
1537 if (--farg < fltreg_argnum) {
1538 copy->varnum = farg;
1540 copy->varnum = --stackargs + intreg_argnum;
1543 if (--iarg < intreg_argnum) {
1544 copy->varnum = iarg;
1546 copy->varnum = --stackargs + intreg_argnum;
1550 (IS_FLT_DBL_TYPE(copy->type)) ? --farg : --iarg;
1558 if (! (copy->flags & SAVEDVAR)) {
1559 copy->varkind = ARGVAR;
1566 copy->flags |= SAVEDVAR;
1571 if (m->returntype != TYPE_VOID) {
1572 OP0_1(m->returntype);
1578 if (! (curstack->flags & SAVEDVAR)) {
1579 curstack->varkind = ARGVAR;
1580 curstack->varnum = 2;
1582 if (3 > arguments_num) {
1589 if (! (curstack->flags & SAVEDVAR)) {
1590 curstack->varkind = ARGVAR;
1591 curstack->varnum = 1;
1593 if (2 > arguments_num) {
1599 if (! (curstack->flags & SAVEDVAR)) {
1600 curstack->varkind = ARGVAR;
1601 curstack->varnum = 0;
1603 if (1 > arguments_num) {
1609 copy->flags |= SAVEDVAR;
1612 if (iptr->op1 != TYPE_VOID)
1616 case ICMD_MULTIANEWARRAY:
1618 if ((i + intreg_argnum) > arguments_num)
1619 arguments_num = i + intreg_argnum;
1622 if (! (copy->flags & SAVEDVAR)) {
1623 copy->varkind = ARGVAR;
1624 copy->varnum = i + intreg_argnum;
1629 copy->flags |= SAVEDVAR;
1637 case ICMD_CLEAR_ARGREN:
1638 for (i = iptr->op1; i<maxlocals; i++)
1640 iptr->opc = opcode = ICMD_NOP;
1644 case ICMD_READONLY_ARG:
1645 case ICMD_READONLY_ARG+1:
1646 case ICMD_READONLY_ARG+2:
1647 case ICMD_READONLY_ARG+3:
1648 case ICMD_READONLY_ARG+4:
1650 if (curstack->varkind == LOCALVAR) {
1651 i = curstack->varnum;
1652 argren[iptr->op1] = i;
1655 opcode = iptr->opc = opcode - ICMD_READONLY_ARG + ICMD_ISTORE;
1661 printf("ICMD %d at %d\n", iptr->opc, (int)(iptr-instr));
1662 panic("Missing ICMD code during stack analysis");
1665 } /* while instructions */
1666 bptr->outstack = curstack;
1667 bptr->outdepth = stackdepth;
1671 superblockend = true;
1673 } /* while blocks */
1674 } while (repeat && !deadcode);
1677 if (block_count > count_max_basic_blocks)
1678 count_max_basic_blocks = block_count;
1679 count_basic_blocks += block_count;
1680 if (instr_count > count_max_javainstr)
1681 count_max_javainstr = instr_count;
1682 count_javainstr += instr_count;
1683 if (stack_count > count_upper_bound_new_stack)
1684 count_upper_bound_new_stack = stack_count;
1685 if ((new - stack) > count_max_new_stack)
1686 count_max_new_stack = (new - stack);
1688 b_count = block_count;
1690 while (--b_count >= 0) {
1691 if (bptr->flags > BBREACHED) {
1692 if (bptr->indepth >= 10)
1693 count_block_stack[10]++;
1695 count_block_stack[bptr->indepth]++;
1698 count_block_size_distribution[len]++;
1700 count_block_size_distribution[10]++;
1702 count_block_size_distribution[11]++;
1704 count_block_size_distribution[12]++;
1706 count_block_size_distribution[13]++;
1708 count_block_size_distribution[14]++;
1710 count_block_size_distribution[15]++;
1712 count_block_size_distribution[16]++;
1714 count_block_size_distribution[17]++;
1720 count_analyse_iterations[0]++;
1721 else if (loops == 2)
1722 count_analyse_iterations[1]++;
1723 else if (loops == 3)
1724 count_analyse_iterations[2]++;
1725 else if (loops == 4)
1726 count_analyse_iterations[3]++;
1728 count_analyse_iterations[4]++;
1730 if (block_count <= 5)
1731 count_method_bb_distribution[0]++;
1732 else if (block_count <= 10)
1733 count_method_bb_distribution[1]++;
1734 else if (block_count <= 15)
1735 count_method_bb_distribution[2]++;
1736 else if (block_count <= 20)
1737 count_method_bb_distribution[3]++;
1738 else if (block_count <= 30)
1739 count_method_bb_distribution[4]++;
1740 else if (block_count <= 40)
1741 count_method_bb_distribution[5]++;
1742 else if (block_count <= 50)
1743 count_method_bb_distribution[6]++;
1744 else if (block_count <= 75)
1745 count_method_bb_distribution[7]++;
1747 count_method_bb_distribution[8]++;
1752 static void print_stack(stackptr s)
1769 if (s->flags & SAVEDVAR)
1770 switch (s->varkind) {
1772 if (s->flags & INMEMORY)
1773 printf(" M%02d", s->regoff);
1774 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1775 printf(" F%02d", s->regoff);
1777 printf(" %3s", regs[s->regoff]);
1780 printf(" I%02d", s->varnum);
1783 printf(" L%02d", s->varnum);
1786 printf(" A%02d", s->varnum);
1789 printf(" !%02d", j);
1792 switch (s->varkind) {
1794 if (s->flags & INMEMORY)
1795 printf(" m%02d", s->regoff);
1796 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1797 printf(" f%02d", s->regoff);
1799 printf(" %3s", regs[s->regoff]);
1802 printf(" i%02d", s->varnum);
1805 printf(" l%02d", s->varnum);
1808 printf(" a%02d", s->varnum);
1811 printf(" ?%02d", j);
1819 static void print_reg(stackptr s) {
1821 if (s->flags & SAVEDVAR)
1822 switch (s->varkind) {
1824 if (s->flags & INMEMORY)
1825 printf(" tm%02d", s->regoff);
1827 printf(" tr%02d", s->regoff);
1830 printf(" s %02d", s->varnum);
1833 printf(" l %02d", s->varnum);
1836 printf(" a %02d", s->varnum);
1839 printf(" ! %02d", s->varnum);
1842 switch (s->varkind) {
1844 if (s->flags & INMEMORY)
1845 printf(" Tm%02d", s->regoff);
1847 printf(" Tr%02d", s->regoff);
1850 printf(" S %02d", s->varnum);
1853 printf(" L %02d", s->varnum);
1856 printf(" A %02d", s->varnum);
1859 printf(" ? %02d", s->varnum);
1869 static char *builtin_name(functionptr bptr)
1871 builtin_descriptor *bdesc = builtin_desc;
1872 while ((bdesc->bptr != NULL) && (bdesc->bptr != bptr))
1878 static char *jit_type[] = {
1887 void show_icmd_method()
1898 utf_fprint(stdout, class->name);
1900 utf_fprint(stdout, method->name);
1902 utf_fprint(stdout, method->descriptor);
1903 printf ("\n\nMax locals: %d\n", (int) maxlocals);
1904 printf ("Max stack: %d\n", (int) maxstack);
1906 printf ("Exceptions (Number: %d):\n", exceptiontablelength);
1907 for (ex = extable; ex != NULL; ex = ex->down) {
1908 printf(" L%03d ... ", ex->start->debug_nr );
1909 printf("L%03d = ", ex->end->debug_nr);
1910 printf("L%03d\n", ex->handler->debug_nr);
1913 printf ("Local Table:\n");
1914 for (i = 0; i < maxlocals; i++) {
1915 printf(" %3d: ", i);
1916 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1917 if (locals[i][j].type >= 0) {
1918 printf(" (%s) ", jit_type[j]);
1919 if (locals[i][j].flags & INMEMORY)
1920 printf("m%2d", locals[i][j].regoff);
1921 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1922 printf("f%02d", locals[i][j].regoff);
1924 printf("%3s", regs[locals[i][j].regoff]);
1930 printf ("Interface Table:\n");
1931 for (i = 0; i < maxstack; i++) {
1932 if ((interfaces[i][0].type >= 0) || (interfaces[i][1].type >= 0) ||
1933 (interfaces[i][2].type >= 0) || (interfaces[i][3].type >= 0) ||
1934 (interfaces[i][4].type >= 0)) {
1935 printf(" %3d: ", i);
1936 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1937 if (interfaces[i][j].type >= 0) {
1938 printf(" (%s) ", jit_type[j]);
1939 if (interfaces[i][j].flags & SAVEDVAR) {
1940 if (interfaces[i][j].flags & INMEMORY)
1941 printf("M%2d", interfaces[i][j].regoff);
1942 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1943 printf("F%02d", interfaces[i][j].regoff);
1945 printf("%3s", regs[interfaces[i][j].regoff]);
1948 if (interfaces[i][j].flags & INMEMORY)
1949 printf("m%2d", interfaces[i][j].regoff);
1950 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1951 printf("f%02d", interfaces[i][j].regoff);
1953 printf("%3s", regs[interfaces[i][j].regoff]);
1961 if (showdisassemble) {
1962 #if defined(__I386__) || defined(__X86_64__)
1966 u1ptr = method->mcode + dseglen;
1967 for (i = 0; i < block[0].mpc; i++, u1ptr++) {
1968 a = disassinstr(u1ptr, i);
1974 s4ptr = (s4 *) (method->mcode + dseglen);
1975 for (i = 0; i < block[0].mpc; i += 4, s4ptr++) {
1976 disassinstr(*s4ptr, i);
1983 for (bptr = block; bptr != NULL; bptr = bptr->next) {
1984 if (bptr->flags != BBDELETED) {
1985 deadcode = bptr->flags <= BBREACHED;
1988 for (j = maxstack; j > 0; j--)
1991 print_stack(bptr->instack);
1992 printf("] L%03d(%d - %d):\n", bptr->debug_nr, bptr->icount, bptr->pre_count);
1993 iptr = bptr->iinstr;
1995 for (i=0; i < bptr->icount; i++, iptr++) {
1998 for (j = maxstack; j > 0; j--)
2002 print_stack(iptr->dst);
2003 printf("] %4d %s", i, icmd_names[iptr->opc]);
2004 switch ((int) iptr->opc) {
2005 case ICMD_IADDCONST:
2006 case ICMD_ISUBCONST:
2007 case ICMD_IMULCONST:
2010 case ICMD_IREM0X10001:
2011 case ICMD_IANDCONST:
2013 case ICMD_IXORCONST:
2014 case ICMD_ISHLCONST:
2015 case ICMD_ISHRCONST:
2016 case ICMD_IUSHRCONST:
2017 case ICMD_LSHLCONST:
2018 case ICMD_LSHRCONST:
2019 case ICMD_LUSHRCONST:
2021 case ICMD_ELSE_ICONST:
2022 case ICMD_IFEQ_ICONST:
2023 case ICMD_IFNE_ICONST:
2024 case ICMD_IFLT_ICONST:
2025 case ICMD_IFGE_ICONST:
2026 case ICMD_IFGT_ICONST:
2027 case ICMD_IFLE_ICONST:
2028 printf(" %d", iptr->val.i);
2030 case ICMD_LADDCONST:
2031 case ICMD_LSUBCONST:
2032 case ICMD_LMULCONST:
2035 case ICMD_LANDCONST:
2037 case ICMD_LXORCONST:
2039 #if defined(__I386__)
2040 printf(" %lld", iptr->val.l);
2042 printf(" %ld", iptr->val.l);
2046 printf(" %f", iptr->val.f);
2049 printf(" %f", iptr->val.d);
2052 printf(" %p", iptr->val.a);
2056 printf(" %d,", ((fieldinfo *) iptr->val.a)->offset);
2057 case ICMD_PUTSTATIC:
2058 case ICMD_GETSTATIC:
2061 ((fieldinfo *) iptr->val.a)->name);
2064 printf(" %d + %d", iptr->op1, iptr->val.i);
2099 printf(" %d", iptr->op1);
2104 ((classinfo *) iptr->val.a)->name);
2107 switch (iptr->op1) {
2134 case ICMD_ANEWARRAY:
2138 ((classinfo *) iptr->val.a)->name);
2141 case ICMD_CHECKCAST:
2142 case ICMD_INSTANCEOF:
2144 classinfo *c = iptr->val.a;
2145 if (c->flags & ACC_INTERFACE)
2146 printf(" (INTERFACE) ");
2148 printf(" (CLASS,%3d) ", c->vftbl->diffval);
2149 utf_fprint(stdout, c->name);
2155 printf(" %s", builtin_name((functionptr) iptr->val.a));
2157 case ICMD_INVOKEVIRTUAL:
2158 case ICMD_INVOKESPECIAL:
2159 case ICMD_INVOKESTATIC:
2160 case ICMD_INVOKEINTERFACE:
2163 ((methodinfo *) iptr->val.a)->class->name);
2166 ((methodinfo *) iptr->val.a)->name);
2174 printf("(%d) L%03d", iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
2182 printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
2187 case ICMD_IFNONNULL:
2188 case ICMD_IF_ICMPEQ:
2189 case ICMD_IF_ICMPNE:
2190 case ICMD_IF_ICMPLT:
2191 case ICMD_IF_ICMPGE:
2192 case ICMD_IF_ICMPGT:
2193 case ICMD_IF_ICMPLE:
2194 case ICMD_IF_LCMPEQ:
2195 case ICMD_IF_LCMPNE:
2196 case ICMD_IF_LCMPLT:
2197 case ICMD_IF_LCMPGE:
2198 case ICMD_IF_LCMPGT:
2199 case ICMD_IF_LCMPLE:
2200 case ICMD_IF_ACMPEQ:
2201 case ICMD_IF_ACMPNE:
2202 printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
2204 case ICMD_TABLESWITCH:
2206 s4ptr = iptr->val.a;
2207 tptr = (void **) iptr->target;
2209 printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
2215 j = *s4ptr++; /* low */
2216 j = *s4ptr++ - j; /* high */
2218 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2223 case ICMD_LOOKUPSWITCH:
2224 s4ptr = iptr->val.a;
2225 tptr = (void **) iptr->target;
2227 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2228 s4ptr++; /* default */
2229 j = *s4ptr; /* count */
2233 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2241 if (showdisassemble && (!deadcode)) {
2242 #if defined(__I386__) || defined(__X86_64__)
2248 u1ptr = method->mcode + dseglen + i;
2250 if (bptr->next != NULL) {
2251 for (; i < bptr->next->mpc; i++, u1ptr++) {
2252 a = disassinstr(u1ptr, i);
2259 for (; u1ptr < (u1 *) (method->mcode + method->mcodelength); i++, u1ptr++) {
2260 a = disassinstr(u1ptr, i);
2269 s4ptr = (s4 *) (method->mcode + dseglen + i);
2271 if (bptr->next != NULL) {
2272 for (; i < bptr->next->mpc; i += 4, s4ptr++) {
2273 disassinstr(*s4ptr, i);
2278 for (; s4ptr < (s4 *) (method->mcode + method->mcodelength); i += 4, s4ptr++) {
2279 disassinstr(*s4ptr, i);
2291 * These are local overrides for various environment variables in Emacs.
2292 * Please do not remove this and leave it at the end of the file, where
2293 * Emacs will automagically detect them.
2294 * ---------------------------------------------------------------------
2297 * indent-tabs-mode: t