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 604 2003-11-11 22:14:20Z twisti $
41 #include "toolbox/loging.h"
42 #include "toolbox/memory.h"
45 /* from codegen.inc */
50 #define COUNT(cnt) cnt++
55 #define STACKRESET {curstack=0;stackdepth=0;}
57 #define TYPEPANIC {show_icmd_method();panic("Stack type mismatch");}
58 #define CURKIND curstack->varkind
59 #define CURTYPE curstack->type
61 #define NEWSTACK(s,v,n) {new->prev=curstack;new->type=s;new->flags=0;\
62 new->varkind=v;new->varnum=n;curstack=new;new++;}
63 #define NEWSTACKn(s,n) NEWSTACK(s,UNDEFVAR,n)
64 #define NEWSTACK0(s) NEWSTACK(s,UNDEFVAR,0)
65 #define NEWXSTACK {NEWSTACK(TYPE_ADR,STACKVAR,0);curstack=0;}
67 #define SETDST {iptr->dst=curstack;}
68 #define POP(s) {if(s!=curstack->type){TYPEPANIC;}\
69 if(curstack->varkind==UNDEFVAR)curstack->varkind=TEMPVAR;\
70 curstack=curstack->prev;}
71 #define POPANY {if(curstack->varkind==UNDEFVAR)curstack->varkind=TEMPVAR;\
72 curstack=curstack->prev;}
73 #define COPY(s,d) {(d)->flags=0;(d)->type=(s)->type;\
74 (d)->varkind=(s)->varkind;(d)->varnum=(s)->varnum;}
76 #define PUSHCONST(s){NEWSTACKn(s,stackdepth);SETDST;stackdepth++;}
77 #define LOAD(s,v,n) {NEWSTACK(s,v,n);SETDST;stackdepth++;}
78 #define STORE(s) {POP(s);SETDST;stackdepth--;}
79 #define OP1_0(s) {POP(s);SETDST;stackdepth--;}
80 #define OP1_0ANY {POPANY;SETDST;stackdepth--;}
81 #define OP0_1(s) {NEWSTACKn(s,stackdepth);SETDST;stackdepth++;}
82 #define OP1_1(s,d) {POP(s);NEWSTACKn(d,stackdepth-1);SETDST;}
83 #define OP2_0(s) {POP(s);POP(s);SETDST;stackdepth-=2;}
84 #define OPTT2_0(t,b){POP(t);POP(b);SETDST;stackdepth-=2;}
85 #define OP2_1(s) {POP(s);POP(s);NEWSTACKn(s,stackdepth-2);SETDST;stackdepth--;}
86 #define OP2IAT_1(s) {POP(TYPE_INT);POP(TYPE_ADR);NEWSTACKn(s,stackdepth-2);\
88 #define OP2IT_1(s) {POP(TYPE_INT);POP(s);NEWSTACKn(s,stackdepth-2);\
90 #define OPTT2_1(s,d){POP(s);POP(s);NEWSTACKn(d,stackdepth-2);SETDST;stackdepth--;}
91 #define OP2_2(s) {POP(s);POP(s);NEWSTACKn(s,stackdepth-2);\
92 NEWSTACKn(s,stackdepth-1);SETDST;}
93 #define OP3TIA_0(s) {POP(s);POP(TYPE_INT);POP(TYPE_ADR);SETDST;stackdepth-=3;}
94 #define OP3_0(s) {POP(s);POP(s);POP(s);SETDST;stackdepth-=3;}
95 #define POPMANY(i) {stackdepth-=i;while(--i>=0){POPANY;}SETDST;}
96 #define DUP {NEWSTACK(CURTYPE,CURKIND,curstack->varnum);SETDST;\
98 #define SWAP {COPY(curstack,new);POPANY;COPY(curstack,new+1);POPANY;\
99 new[0].prev=curstack;new[1].prev=new;\
100 curstack=new+1;new+=2;SETDST;}
101 #define DUP_X1 {COPY(curstack,new);COPY(curstack,new+2);POPANY;\
102 COPY(curstack,new+1);POPANY;new[0].prev=curstack;\
103 new[1].prev=new;new[2].prev=new+1;\
104 curstack=new+2;new+=3;SETDST;stackdepth++;}
105 #define DUP2_X1 {COPY(curstack,new+1);COPY(curstack,new+4);POPANY;\
106 COPY(curstack,new);COPY(curstack,new+3);POPANY;\
107 COPY(curstack,new+2);POPANY;new[0].prev=curstack;\
108 new[1].prev=new;new[2].prev=new+1;\
109 new[3].prev=new+2;new[4].prev=new+3;\
110 curstack=new+4;new+=5;SETDST;stackdepth+=2;}
111 #define DUP_X2 {COPY(curstack,new);COPY(curstack,new+3);POPANY;\
112 COPY(curstack,new+2);POPANY;COPY(curstack,new+1);POPANY;\
113 new[0].prev=curstack;new[1].prev=new;\
114 new[2].prev=new+1;new[3].prev=new+2;\
115 curstack=new+3;new+=4;SETDST;stackdepth++;}
116 #define DUP2_X2 {COPY(curstack,new+1);COPY(curstack,new+5);POPANY;\
117 COPY(curstack,new);COPY(curstack,new+4);POPANY;\
118 COPY(curstack,new+3);POPANY;COPY(curstack,new+2);POPANY;\
119 new[0].prev=curstack;new[1].prev=new;\
120 new[2].prev=new+1;new[3].prev=new+2;\
121 new[4].prev=new+3;new[5].prev=new+4;\
122 curstack=new+5;new+=6;SETDST;stackdepth+=2;}
124 #define COPYCURSTACK(copy) {\
137 copy->varkind=STACKVAR;\
153 if((copy->varkind==STACKVAR)&&(copy->varnum>i))\
154 copy->varkind=TEMPVAR;\
156 copy->varkind=STACKVAR;\
159 interfaces[i][copy->type].type = copy->type;\
160 interfaces[i][copy->type].flags |= copy->flags;\
161 i--;copy=copy->prev;\
166 interfaces[i][copy->type].type = copy->type;\
167 if(copy->varkind==STACKVAR){\
168 if (copy->flags & SAVEDVAR)\
169 interfaces[i][copy->type].flags |= SAVEDVAR;\
171 i--;copy=copy->prev;\
176 #define MARKREACHED(b,c) {\
178 {COPYCURSTACK(c);b->flags=0;b->instack=c;b->indepth=stackdepth;}\
179 else {stackptr s=curstack;stackptr t=b->instack;\
180 if(b->indepth!=stackdepth)\
181 {show_icmd_method();panic("Stack depth mismatch");}\
182 while(s){if (s->type!=t->type)\
184 s=s->prev;t=t->prev;\
190 #ifdef USEBUILTINTABLE
191 static stdopdescriptor *find_builtin(stdopdescriptor *first, stdopdescriptor *last,
194 int len = last - first;
196 stdopdescriptor *middle;
200 middle = first + half;
201 if (middle->opcode < icmd) {
220 int opcode, i, len, loops;
221 int superblockend, repeat, deadcode;
228 int *argren = DMNEW(int, maxlocals);
229 //int *argren = (int *)alloca(maxlocals * sizeof(int)); /* table for argument renaming */
230 for (i = 0; i < maxlocals; i++)
236 block[0].flags = BBREACHED;
237 block[0].instack = 0;
238 block[0].indepth = 0;
240 for (i = 0; i < exceptiontablelength; i++) {
241 bptr = &block[block_index[extable[i].handlerpc]];
242 bptr->flags = BBREACHED;
243 bptr->type = BBTYPE_EXH;
246 bptr->pre_count = 10000;
251 #ifdef CONDITIONAL_LOADCONST
252 b_count = block_count;
254 while (--b_count >= 0) {
255 if (bptr->icount != 0) {
256 iptr = bptr->iinstr + bptr->icount - 1;
289 block[block_index[iptr->op1]].pre_count++;
292 case ICMD_TABLESWITCH:
294 block[block_index[*s4ptr++]].pre_count++; /* default */
295 i = *s4ptr++; /* low */
296 i = *s4ptr++ - i + 1; /* high */
298 block[block_index[*s4ptr++]].pre_count++;
302 case ICMD_LOOKUPSWITCH:
304 block[block_index[*s4ptr++]].pre_count++; /* default */
305 i = *s4ptr++; /* count */
307 block[block_index[s4ptr[1]]].pre_count++;
323 b_count = block_count;
325 superblockend = true;
329 while (--b_count >= 0) {
330 if (bptr->flags == BBDELETED) {
333 else if (superblockend && (bptr->flags < BBREACHED))
335 else if (bptr->flags <= BBREACHED) {
337 stackdepth = bptr->indepth;
338 else if (bptr->flags < BBREACHED) {
340 bptr->instack = copy;
341 bptr->indepth = stackdepth;
343 else if (bptr->indepth != stackdepth) {
345 panic("Stack depth mismatch");
348 curstack = bptr->instack;
350 superblockend = false;
351 bptr->flags = BBFINISHED;
354 b_index = bptr - block;
359 #ifdef USEBUILTINTABLE
361 /* stdopdescriptor *blast = builtintable + sizeof(builtintable) / sizeof(stdopdescriptor); */
362 stdopdescriptor *blast = builtintable + 21 * sizeof(stdopdescriptor);
363 stdopdescriptor *breplace;
364 breplace = find_builtin(builtintable, blast, opcode);
365 if (breplace != blast && opcode == breplace->opcode && !breplace->supported) {
366 iptr[0].opc = breplace->icmd;
367 iptr[0].op1 = breplace->type_d;
368 iptr[0].val.a = breplace->builtin;
369 isleafmethod = false;
370 switch (breplace->icmd) {
385 case ICMD_CHECKASIZE:
387 case ICMD_IFEQ_ICONST:
388 case ICMD_IFNE_ICONST:
389 case ICMD_IFLT_ICONST:
390 case ICMD_IFGE_ICONST:
391 case ICMD_IFGT_ICONST:
392 case ICMD_IFLE_ICONST:
393 case ICMD_ELSE_ICONST:
398 locals[iptr->op1][TYPE_ADR].type = TYPE_ADR;
400 COUNT(count_pcmd_return);
402 superblockend = true;
405 /* pop 0 push 1 const */
408 COUNT(count_pcmd_load);
410 switch (iptr[1].opc) {
412 iptr[0].opc = ICMD_IADDCONST;
414 iptr[1].opc = ICMD_NOP;
415 OP1_1(TYPE_INT,TYPE_INT);
416 COUNT(count_pcmd_op);
419 iptr[0].opc = ICMD_ISUBCONST;
420 goto icmd_iconst_tail;
422 iptr[0].opc = ICMD_IMULCONST;
423 goto icmd_iconst_tail;
425 if (iptr[0].val.i == 0x00000002)
427 else if (iptr[0].val.i == 0x00000004)
429 else if (iptr[0].val.i == 0x00000008)
431 else if (iptr[0].val.i == 0x00000010)
433 else if (iptr[0].val.i == 0x00000020)
435 else if (iptr[0].val.i == 0x00000040)
437 else if (iptr[0].val.i == 0x00000080)
439 else if (iptr[0].val.i == 0x00000100)
441 else if (iptr[0].val.i == 0x00000200)
443 else if (iptr[0].val.i == 0x00000400)
445 else if (iptr[0].val.i == 0x00000800)
447 else if (iptr[0].val.i == 0x00001000)
449 else if (iptr[0].val.i == 0x00002000)
451 else if (iptr[0].val.i == 0x00004000)
453 else if (iptr[0].val.i == 0x00008000)
455 else if (iptr[0].val.i == 0x00010000)
457 else if (iptr[0].val.i == 0x00020000)
459 else if (iptr[0].val.i == 0x00040000)
461 else if (iptr[0].val.i == 0x00080000)
463 else if (iptr[0].val.i == 0x00100000)
465 else if (iptr[0].val.i == 0x00200000)
467 else if (iptr[0].val.i == 0x00400000)
469 else if (iptr[0].val.i == 0x00800000)
471 else if (iptr[0].val.i == 0x01000000)
473 else if (iptr[0].val.i == 0x02000000)
475 else if (iptr[0].val.i == 0x04000000)
477 else if (iptr[0].val.i == 0x08000000)
479 else if (iptr[0].val.i == 0x10000000)
481 else if (iptr[0].val.i == 0x20000000)
483 else if (iptr[0].val.i == 0x40000000)
485 else if (iptr[0].val.i == 0x80000000)
491 iptr[0].opc = ICMD_IDIVPOW2;
492 goto icmd_iconst_tail;
494 #if !defined(NO_DIV_OPT)
495 if (iptr[0].val.i == 0x10001) {
496 iptr[0].opc = ICMD_IREM0X10001;
497 goto icmd_iconst_tail;
500 if ((iptr[0].val.i == 0x00000002) ||
501 (iptr[0].val.i == 0x00000004) ||
502 (iptr[0].val.i == 0x00000008) ||
503 (iptr[0].val.i == 0x00000010) ||
504 (iptr[0].val.i == 0x00000020) ||
505 (iptr[0].val.i == 0x00000040) ||
506 (iptr[0].val.i == 0x00000080) ||
507 (iptr[0].val.i == 0x00000100) ||
508 (iptr[0].val.i == 0x00000200) ||
509 (iptr[0].val.i == 0x00000400) ||
510 (iptr[0].val.i == 0x00000800) ||
511 (iptr[0].val.i == 0x00001000) ||
512 (iptr[0].val.i == 0x00002000) ||
513 (iptr[0].val.i == 0x00004000) ||
514 (iptr[0].val.i == 0x00008000) ||
515 (iptr[0].val.i == 0x00010000) ||
516 (iptr[0].val.i == 0x00020000) ||
517 (iptr[0].val.i == 0x00040000) ||
518 (iptr[0].val.i == 0x00080000) ||
519 (iptr[0].val.i == 0x00100000) ||
520 (iptr[0].val.i == 0x00200000) ||
521 (iptr[0].val.i == 0x00400000) ||
522 (iptr[0].val.i == 0x00800000) ||
523 (iptr[0].val.i == 0x01000000) ||
524 (iptr[0].val.i == 0x02000000) ||
525 (iptr[0].val.i == 0x04000000) ||
526 (iptr[0].val.i == 0x08000000) ||
527 (iptr[0].val.i == 0x10000000) ||
528 (iptr[0].val.i == 0x20000000) ||
529 (iptr[0].val.i == 0x40000000) ||
530 (iptr[0].val.i == 0x80000000)) {
531 iptr[0].opc = ICMD_IREMPOW2;
533 goto icmd_iconst_tail;
538 iptr[0].opc = ICMD_IANDCONST;
539 goto icmd_iconst_tail;
541 iptr[0].opc = ICMD_IORCONST;
542 goto icmd_iconst_tail;
544 iptr[0].opc = ICMD_IXORCONST;
545 goto icmd_iconst_tail;
547 iptr[0].opc = ICMD_ISHLCONST;
548 goto icmd_iconst_tail;
550 iptr[0].opc = ICMD_ISHRCONST;
551 goto icmd_iconst_tail;
553 iptr[0].opc = ICMD_IUSHRCONST;
554 goto icmd_iconst_tail;
555 #if SUPPORT_LONG_SHIFT
557 iptr[0].opc = ICMD_LSHLCONST;
558 goto icmd_lconst_tail;
560 iptr[0].opc = ICMD_LSHRCONST;
561 goto icmd_lconst_tail;
563 iptr[0].opc = ICMD_LUSHRCONST;
564 goto icmd_lconst_tail;
567 iptr[0].opc = ICMD_IFEQ;
569 iptr[0].op1 = iptr[1].op1;
572 /* iptr[1].opc = ICMD_NOP; */
574 tbptr = block + block_index[iptr->op1];
576 iptr[0].target = (void *) tbptr;
578 MARKREACHED(tbptr, copy);
579 COUNT(count_pcmd_bra);
582 iptr[0].opc = ICMD_IFLT;
583 goto icmd_if_icmp_tail;
585 iptr[0].opc = ICMD_IFLE;
586 goto icmd_if_icmp_tail;
588 iptr[0].opc = ICMD_IFNE;
589 goto icmd_if_icmp_tail;
591 iptr[0].opc = ICMD_IFGT;
592 goto icmd_if_icmp_tail;
594 iptr[0].opc = ICMD_IFGE;
595 goto icmd_if_icmp_tail;
604 COUNT(count_pcmd_load);
606 switch (iptr[1].opc) {
609 iptr[0].opc = ICMD_LADDCONST;
611 iptr[1].opc = ICMD_NOP;
612 OP1_1(TYPE_LNG,TYPE_LNG);
613 COUNT(count_pcmd_op);
616 iptr[0].opc = ICMD_LSUBCONST;
617 goto icmd_lconst_tail;
619 #if SUPPORT_LONG_MULDIV
621 iptr[0].opc = ICMD_LMULCONST;
622 goto icmd_lconst_tail;
624 if (iptr[0].val.l == 0x00000002)
626 else if (iptr[0].val.l == 0x00000004)
628 else if (iptr[0].val.l == 0x00000008)
630 else if (iptr[0].val.l == 0x00000010)
632 else if (iptr[0].val.l == 0x00000020)
634 else if (iptr[0].val.l == 0x00000040)
636 else if (iptr[0].val.l == 0x00000080)
638 else if (iptr[0].val.l == 0x00000100)
640 else if (iptr[0].val.l == 0x00000200)
642 else if (iptr[0].val.l == 0x00000400)
644 else if (iptr[0].val.l == 0x00000800)
646 else if (iptr[0].val.l == 0x00001000)
648 else if (iptr[0].val.l == 0x00002000)
650 else if (iptr[0].val.l == 0x00004000)
652 else if (iptr[0].val.l == 0x00008000)
654 else if (iptr[0].val.l == 0x00010000)
656 else if (iptr[0].val.l == 0x00020000)
658 else if (iptr[0].val.l == 0x00040000)
660 else if (iptr[0].val.l == 0x00080000)
662 else if (iptr[0].val.l == 0x00100000)
664 else if (iptr[0].val.l == 0x00200000)
666 else if (iptr[0].val.l == 0x00400000)
668 else if (iptr[0].val.l == 0x00800000)
670 else if (iptr[0].val.l == 0x01000000)
672 else if (iptr[0].val.l == 0x02000000)
674 else if (iptr[0].val.l == 0x04000000)
676 else if (iptr[0].val.l == 0x08000000)
678 else if (iptr[0].val.l == 0x10000000)
680 else if (iptr[0].val.l == 0x20000000)
682 else if (iptr[0].val.l == 0x40000000)
684 else if (iptr[0].val.l == 0x80000000)
690 iptr[0].opc = ICMD_LDIVPOW2;
691 goto icmd_lconst_tail;
693 #if !defined(NO_DIV_OPT)
694 if (iptr[0].val.l == 0x10001) {
695 iptr[0].opc = ICMD_LREM0X10001;
696 goto icmd_lconst_tail;
699 if ((iptr[0].val.l == 0x00000002) ||
700 (iptr[0].val.l == 0x00000004) ||
701 (iptr[0].val.l == 0x00000008) ||
702 (iptr[0].val.l == 0x00000010) ||
703 (iptr[0].val.l == 0x00000020) ||
704 (iptr[0].val.l == 0x00000040) ||
705 (iptr[0].val.l == 0x00000080) ||
706 (iptr[0].val.l == 0x00000100) ||
707 (iptr[0].val.l == 0x00000200) ||
708 (iptr[0].val.l == 0x00000400) ||
709 (iptr[0].val.l == 0x00000800) ||
710 (iptr[0].val.l == 0x00001000) ||
711 (iptr[0].val.l == 0x00002000) ||
712 (iptr[0].val.l == 0x00004000) ||
713 (iptr[0].val.l == 0x00008000) ||
714 (iptr[0].val.l == 0x00010000) ||
715 (iptr[0].val.l == 0x00020000) ||
716 (iptr[0].val.l == 0x00040000) ||
717 (iptr[0].val.l == 0x00080000) ||
718 (iptr[0].val.l == 0x00100000) ||
719 (iptr[0].val.l == 0x00200000) ||
720 (iptr[0].val.l == 0x00400000) ||
721 (iptr[0].val.l == 0x00800000) ||
722 (iptr[0].val.l == 0x01000000) ||
723 (iptr[0].val.l == 0x02000000) ||
724 (iptr[0].val.l == 0x04000000) ||
725 (iptr[0].val.l == 0x08000000) ||
726 (iptr[0].val.l == 0x10000000) ||
727 (iptr[0].val.l == 0x20000000) ||
728 (iptr[0].val.l == 0x40000000) ||
729 (iptr[0].val.l == 0x80000000)) {
730 iptr[0].opc = ICMD_LREMPOW2;
732 goto icmd_lconst_tail;
739 iptr[0].opc = ICMD_LANDCONST;
740 goto icmd_lconst_tail;
742 iptr[0].opc = ICMD_LORCONST;
743 goto icmd_lconst_tail;
745 iptr[0].opc = ICMD_LXORCONST;
746 goto icmd_lconst_tail;
748 #if defined(NOLONG_CONDITIONAL)
750 if ((len > 1) && (iptr[2].val.i == 0)) {
751 switch (iptr[2].opc) {
753 iptr[0].opc = ICMD_IF_LEQ;
754 icmd_lconst_lcmp_tail:
755 iptr[0].op1 = iptr[2].op1;
758 /* iptr[1].opc = ICMD_NOP;
759 iptr[2].opc = ICMD_NOP; */
761 tbptr = block + block_index[iptr->op1];
763 iptr[0].target = (void *) tbptr;
765 MARKREACHED(tbptr, copy);
766 COUNT(count_pcmd_bra);
767 COUNT(count_pcmd_op);
770 iptr[0].opc = ICMD_IF_LNE;
771 goto icmd_lconst_lcmp_tail;
773 iptr[0].opc = ICMD_IF_LLT;
774 goto icmd_lconst_lcmp_tail;
776 iptr[0].opc = ICMD_IF_LGT;
777 goto icmd_lconst_lcmp_tail;
779 iptr[0].opc = ICMD_IF_LLE;
780 goto icmd_lconst_lcmp_tail;
782 iptr[0].opc = ICMD_IF_LGE;
783 goto icmd_lconst_lcmp_tail;
786 } /* switch (iptr[2].opc) */
787 } /* if (iptr[2].val.i == 0) */
800 COUNT(count_pcmd_load);
804 COUNT(count_pcmd_load);
808 COUNT(count_pcmd_load);
812 /* pop 0 push 1 load */
819 COUNT(count_load_instruction);
820 i = opcode-ICMD_ILOAD;
821 iptr->op1 = argren[iptr->op1];
822 locals[iptr->op1][i].type = i;
823 LOAD(i, LOCALVAR, iptr->op1);
833 COUNT(count_check_null);
834 COUNT(count_check_bound);
835 COUNT(count_pcmd_mem);
836 OP2IAT_1(opcode-ICMD_IALOAD);
842 COUNT(count_check_null);
843 COUNT(count_check_bound);
844 COUNT(count_pcmd_mem);
848 /* pop 0 push 0 iinc */
854 count_store_depth[10]++;
856 count_store_depth[i]++;
861 if ((copy->varkind == LOCALVAR) &&
862 (copy->varnum == iptr->op1)) {
863 copy->varkind = TEMPVAR;
872 /* pop 1 push 0 store */
881 i = opcode - ICMD_ISTORE;
882 locals[iptr->op1][i].type = i;
887 count_store_length[20]++;
889 count_store_length[i]++;
892 count_store_depth[10]++;
894 count_store_depth[i]++;
896 copy = curstack->prev;
899 if ((copy->varkind == LOCALVAR) &&
900 (copy->varnum == iptr->op1)) {
901 copy->varkind = TEMPVAR;
907 if ((new - curstack) == 1) {
908 curstack->varkind = LOCALVAR;
909 curstack->varnum = iptr->op1;
911 STORE(opcode-ICMD_ISTORE);
921 COUNT(count_check_null);
922 COUNT(count_check_bound);
923 COUNT(count_pcmd_mem);
924 OP3TIA_0(opcode-ICMD_IASTORE);
929 COUNT(count_check_null);
930 COUNT(count_check_bound);
931 COUNT(count_pcmd_mem);
946 COUNT(count_pcmd_return);
947 OP1_0(opcode-ICMD_IRETURN);
948 superblockend = true;
952 COUNT(count_check_null);
956 superblockend = true;
960 COUNT(count_pcmd_mem);
964 /* pop 1 push 0 branch */
968 COUNT(count_pcmd_bra);
970 tbptr = block + block_index[iptr->op1];
972 iptr[0].target = (void *) tbptr;
974 MARKREACHED(tbptr, copy);
983 COUNT(count_pcmd_bra);
984 #ifdef CONDITIONAL_LOADCONST
986 tbptr = block + b_index;
987 if ((b_count >= 3) &&
988 ((b_index + 2) == block_index[iptr[0].op1]) &&
989 (tbptr[1].pre_count == 1) &&
990 (iptr[1].opc == ICMD_ICONST) &&
991 (iptr[2].opc == ICMD_GOTO) &&
992 ((b_index + 3) == block_index[iptr[2].op1]) &&
993 (tbptr[2].pre_count == 1) &&
994 (iptr[3].opc == ICMD_ICONST)) {
995 OP1_1(TYPE_INT, TYPE_INT);
996 switch (iptr[0].opc) {
998 iptr[0].opc = ICMD_IFNE_ICONST;
1001 iptr[0].opc = ICMD_IFEQ_ICONST;
1004 iptr[0].opc = ICMD_IFGE_ICONST;
1007 iptr[0].opc = ICMD_IFLT_ICONST;
1010 iptr[0].opc = ICMD_IFLE_ICONST;
1013 iptr[0].opc = ICMD_IFGT_ICONST;
1016 iptr[0].val.i = iptr[1].val.i;
1017 iptr[1].opc = ICMD_ELSE_ICONST;
1018 iptr[1].val.i = iptr[3].val.i;
1019 iptr[2].opc = ICMD_NOP;
1020 iptr[3].opc = ICMD_NOP;
1021 tbptr[1].flags = BBDELETED;
1022 tbptr[2].flags = BBDELETED;
1023 tbptr[1].icount = 0;
1024 tbptr[2].icount = 0;
1025 if (tbptr[3].pre_count == 2) {
1026 len += tbptr[3].icount + 3;
1027 bptr->icount += tbptr[3].icount + 3;
1028 tbptr[3].flags = BBDELETED;
1029 tbptr[3].icount = 0;
1042 tbptr = block + block_index[iptr->op1];
1044 iptr[0].target = (void *) tbptr;
1046 MARKREACHED(tbptr, copy);
1049 /* pop 0 push 0 branch */
1052 COUNT(count_pcmd_bra);
1053 tbptr = block + block_index[iptr->op1];
1055 iptr[0].target = (void *) tbptr;
1057 MARKREACHED(tbptr, copy);
1059 superblockend = true;
1062 /* pop 1 push 0 table branch */
1064 case ICMD_TABLESWITCH:
1065 COUNT(count_pcmd_table);
1067 s4ptr = iptr->val.a;
1068 tbptr = block + block_index[*s4ptr++]; /* default */
1069 MARKREACHED(tbptr, copy);
1070 i = *s4ptr++; /* low */
1071 i = *s4ptr++ - i + 1; /* high */
1073 tptr = DMNEW(void*, i+1);
1074 iptr->target = (void *) tptr;
1076 tptr[0] = (void *) tbptr;
1080 tbptr = block + block_index[*s4ptr++];
1082 tptr[0] = (void *) tbptr;
1085 MARKREACHED(tbptr, copy);
1088 superblockend = true;
1091 /* pop 1 push 0 table branch */
1093 case ICMD_LOOKUPSWITCH:
1094 COUNT(count_pcmd_table);
1096 s4ptr = iptr->val.a;
1097 tbptr = block + block_index[*s4ptr++]; /* default */
1098 MARKREACHED(tbptr, copy);
1099 i = *s4ptr++; /* count */
1101 tptr = DMNEW(void*, i+1);
1102 iptr->target = (void *) tptr;
1104 tptr[0] = (void *) tbptr;
1108 tbptr = block + block_index[s4ptr[1]];
1110 tptr[0] = (void *) tbptr;
1113 MARKREACHED(tbptr, copy);
1117 superblockend = true;
1120 case ICMD_NULLCHECKPOP:
1121 case ICMD_MONITORENTER:
1122 COUNT(count_check_null);
1123 case ICMD_MONITOREXIT:
1127 /* pop 2 push 0 branch */
1129 case ICMD_IF_ICMPEQ:
1130 case ICMD_IF_ICMPNE:
1131 case ICMD_IF_ICMPLT:
1132 case ICMD_IF_ICMPGE:
1133 case ICMD_IF_ICMPGT:
1134 case ICMD_IF_ICMPLE:
1135 COUNT(count_pcmd_bra);
1137 tbptr = block + block_index[iptr->op1];
1139 iptr[0].target = (void *) tbptr;
1141 MARKREACHED(tbptr, copy);
1144 case ICMD_IF_ACMPEQ:
1145 case ICMD_IF_ACMPNE:
1146 COUNT(count_pcmd_bra);
1148 tbptr = block + block_index[iptr->op1];
1150 iptr[0].target = (void *) tbptr;
1152 MARKREACHED(tbptr, copy);
1158 COUNT(count_check_null);
1159 COUNT(count_pcmd_mem);
1160 OPTT2_0(iptr->op1,TYPE_ADR);
1164 if (! IS_2_WORD_TYPE(curstack->type)) {
1165 OP1_0ANY; /* second pop */
1168 iptr->opc = ICMD_POP;
1172 /* pop 0 push 1 dup */
1175 COUNT(count_dup_instruction);
1180 if (IS_2_WORD_TYPE(curstack->type)) {
1181 iptr->opc = ICMD_DUP;
1186 NEWSTACK(copy->prev->type, copy->prev->varkind,
1187 copy->prev->varnum);
1188 NEWSTACK(copy->type, copy->varkind,
1195 /* pop 2 push 3 dup */
1202 if (IS_2_WORD_TYPE(curstack->type)) {
1203 iptr->opc = ICMD_DUP_X1;
1211 /* pop 3 push 4 dup */
1214 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1215 iptr->opc = ICMD_DUP_X1;
1224 if (IS_2_WORD_TYPE(curstack->type)) {
1225 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1226 iptr->opc = ICMD_DUP_X1;
1230 iptr->opc = ICMD_DUP_X2;
1235 if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1236 iptr->opc = ICMD_DUP2_X1;
1244 /* pop 2 push 2 swap */
1253 #if !SUPPORT_DIVISION
1254 iptr[0].opc = ICMD_BUILTIN2;
1255 iptr[0].op1 = TYPE_INT;
1256 iptr[0].val.a = (functionptr) asm_builtin_idiv;
1257 isleafmethod = false;
1262 #if !SUPPORT_DIVISION
1263 iptr[0].opc = ICMD_BUILTIN2;
1264 iptr[0].op1 = TYPE_INT;
1265 iptr[0].val.a = (functionptr) asm_builtin_irem;
1266 isleafmethod = false;
1280 COUNT(count_pcmd_op);
1285 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_MULDIV)
1286 iptr[0].opc = ICMD_BUILTIN2;
1287 iptr[0].op1 = TYPE_LNG;
1288 iptr[0].val.a = (functionptr) asm_builtin_ldiv;
1289 isleafmethod = false;
1294 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_MULDIV)
1295 iptr[0].opc = ICMD_BUILTIN2;
1296 iptr[0].op1 = TYPE_LNG;
1297 iptr[0].val.a = (functionptr) asm_builtin_lrem;
1298 isleafmethod = false;
1309 COUNT(count_pcmd_op);
1316 COUNT(count_pcmd_op);
1325 COUNT(count_pcmd_op);
1334 COUNT(count_pcmd_op);
1339 COUNT(count_pcmd_op);
1340 #ifndef NOLONG_CONDITIONAL
1341 if ((len > 0) && (iptr[1].val.i == 0)) {
1342 switch (iptr[1].opc) {
1344 iptr[0].opc = ICMD_IF_LCMPEQ;
1346 iptr[0].op1 = iptr[1].op1;
1349 /* iptr[1].opc = ICMD_NOP; */
1351 tbptr = block + block_index[iptr->op1];
1353 iptr[0].target = (void *) tbptr;
1355 MARKREACHED(tbptr, copy);
1356 COUNT(count_pcmd_bra);
1359 iptr[0].opc = ICMD_IF_LCMPNE;
1360 goto icmd_lcmp_if_tail;
1362 iptr[0].opc = ICMD_IF_LCMPLT;
1363 goto icmd_lcmp_if_tail;
1365 iptr[0].opc = ICMD_IF_LCMPGT;
1366 goto icmd_lcmp_if_tail;
1368 iptr[0].opc = ICMD_IF_LCMPLE;
1369 goto icmd_lcmp_if_tail;
1371 iptr[0].opc = ICMD_IF_LCMPGE;
1372 goto icmd_lcmp_if_tail;
1374 OPTT2_1(TYPE_LNG, TYPE_INT);
1379 OPTT2_1(TYPE_LNG, TYPE_INT);
1383 COUNT(count_pcmd_op);
1384 OPTT2_1(TYPE_FLT, TYPE_INT);
1388 COUNT(count_pcmd_op);
1389 OPTT2_1(TYPE_DBL, TYPE_INT);
1397 case ICMD_INT2SHORT:
1398 COUNT(count_pcmd_op);
1399 OP1_1(TYPE_INT, TYPE_INT);
1402 COUNT(count_pcmd_op);
1403 OP1_1(TYPE_LNG, TYPE_LNG);
1406 COUNT(count_pcmd_op);
1407 OP1_1(TYPE_FLT, TYPE_FLT);
1410 COUNT(count_pcmd_op);
1411 OP1_1(TYPE_DBL, TYPE_DBL);
1415 COUNT(count_pcmd_op);
1416 OP1_1(TYPE_INT, TYPE_LNG);
1419 COUNT(count_pcmd_op);
1420 OP1_1(TYPE_INT, TYPE_FLT);
1423 COUNT(count_pcmd_op);
1424 OP1_1(TYPE_INT, TYPE_DBL);
1427 COUNT(count_pcmd_op);
1428 OP1_1(TYPE_LNG, TYPE_INT);
1431 COUNT(count_pcmd_op);
1432 OP1_1(TYPE_LNG, TYPE_FLT);
1435 COUNT(count_pcmd_op);
1436 OP1_1(TYPE_LNG, TYPE_DBL);
1439 COUNT(count_pcmd_op);
1440 OP1_1(TYPE_FLT, TYPE_INT);
1443 COUNT(count_pcmd_op);
1444 OP1_1(TYPE_FLT, TYPE_LNG);
1447 COUNT(count_pcmd_op);
1448 OP1_1(TYPE_FLT, TYPE_DBL);
1451 COUNT(count_pcmd_op);
1452 OP1_1(TYPE_DBL, TYPE_INT);
1455 COUNT(count_pcmd_op);
1456 OP1_1(TYPE_DBL, TYPE_LNG);
1459 COUNT(count_pcmd_op);
1460 OP1_1(TYPE_DBL, TYPE_FLT);
1463 case ICMD_CHECKCAST:
1464 OP1_1(TYPE_ADR, TYPE_ADR);
1467 case ICMD_ARRAYLENGTH:
1468 case ICMD_INSTANCEOF:
1469 OP1_1(TYPE_ADR, TYPE_INT);
1473 case ICMD_ANEWARRAY:
1474 OP1_1(TYPE_INT, TYPE_ADR);
1478 COUNT(count_check_null);
1479 COUNT(count_pcmd_mem);
1480 OP1_1(TYPE_ADR, iptr->op1);
1485 case ICMD_GETSTATIC:
1486 COUNT(count_pcmd_mem);
1496 tbptr = block + block_index[iptr->op1];
1498 iptr[0].target = (void *) tbptr;
1500 tbptr->type=BBTYPE_SBR;
1501 MARKREACHED(tbptr, copy);
1505 /* pop many push any */
1507 case ICMD_INVOKEVIRTUAL:
1508 case ICMD_INVOKESPECIAL:
1509 case ICMD_INVOKEINTERFACE:
1510 case ICMD_INVOKESTATIC:
1511 COUNT(count_pcmd_met);
1513 methodinfo *m = iptr->val.a;
1514 if (m->flags & ACC_STATIC)
1515 {COUNT(count_check_null);}
1517 if (i > arguments_num)
1519 #if defined(__X86_64__)
1527 (IS_FLT_DBL_TYPE(copy->type)) ? farg++ : iarg++;
1531 stackargs += (iarg < intreg_argnum) ? 0 : (iarg - intreg_argnum);
1532 stackargs += (farg < fltreg_argnum) ? 0 : (farg - fltreg_argnum);
1537 if (!(copy->flags & SAVEDVAR)) {
1538 copy->varkind = ARGVAR;
1539 if (IS_FLT_DBL_TYPE(copy->type)) {
1540 if (--farg < fltreg_argnum) {
1541 copy->varnum = farg;
1543 copy->varnum = --stackargs + intreg_argnum;
1546 if (--iarg < intreg_argnum) {
1547 copy->varnum = iarg;
1549 copy->varnum = --stackargs + intreg_argnum;
1553 (IS_FLT_DBL_TYPE(copy->type)) ? --farg : --iarg;
1561 if (! (copy->flags & SAVEDVAR)) {
1562 copy->varkind = ARGVAR;
1569 copy->flags |= SAVEDVAR;
1574 if (m->returntype != TYPE_VOID) {
1575 OP0_1(m->returntype);
1581 if (! (curstack->flags & SAVEDVAR)) {
1582 curstack->varkind = ARGVAR;
1583 curstack->varnum = 2;
1585 if (3 > arguments_num) {
1592 if (!(curstack->flags & SAVEDVAR)) {
1593 curstack->varkind = ARGVAR;
1594 curstack->varnum = 1;
1596 if (2 > arguments_num) {
1603 if (!(curstack->flags & SAVEDVAR)) {
1604 curstack->varkind = ARGVAR;
1605 curstack->varnum = 0;
1607 if (1 > arguments_num) {
1613 copy->flags |= SAVEDVAR;
1616 if (iptr->op1 != TYPE_VOID)
1620 case ICMD_MULTIANEWARRAY:
1622 if ((i + intreg_argnum) > arguments_num)
1623 arguments_num = i + intreg_argnum;
1626 if (! (copy->flags & SAVEDVAR)) {
1627 copy->varkind = ARGVAR;
1628 copy->varnum = i + intreg_argnum;
1633 copy->flags |= SAVEDVAR;
1641 case ICMD_CLEAR_ARGREN:
1642 for (i = iptr->op1; i<maxlocals; i++)
1644 iptr->opc = opcode = ICMD_NOP;
1648 case ICMD_READONLY_ARG:
1649 case ICMD_READONLY_ARG+1:
1650 case ICMD_READONLY_ARG+2:
1651 case ICMD_READONLY_ARG+3:
1652 case ICMD_READONLY_ARG+4:
1654 if (curstack->varkind == LOCALVAR) {
1655 i = curstack->varnum;
1656 argren[iptr->op1] = i;
1659 opcode = iptr->opc = opcode - ICMD_READONLY_ARG + ICMD_ISTORE;
1665 printf("ICMD %d at %d\n", iptr->opc, (int)(iptr-instr));
1666 panic("Missing ICMD code during stack analysis");
1669 } /* while instructions */
1670 bptr->outstack = curstack;
1671 bptr->outdepth = stackdepth;
1675 superblockend = true;
1677 } /* while blocks */
1678 } while (repeat && !deadcode);
1681 if (block_count > count_max_basic_blocks)
1682 count_max_basic_blocks = block_count;
1683 count_basic_blocks += block_count;
1684 if (instr_count > count_max_javainstr)
1685 count_max_javainstr = instr_count;
1686 count_javainstr += instr_count;
1687 if (stack_count > count_upper_bound_new_stack)
1688 count_upper_bound_new_stack = stack_count;
1689 if ((new - stack) > count_max_new_stack)
1690 count_max_new_stack = (new - stack);
1692 b_count = block_count;
1694 while (--b_count >= 0) {
1695 if (bptr->flags > BBREACHED) {
1696 if (bptr->indepth >= 10)
1697 count_block_stack[10]++;
1699 count_block_stack[bptr->indepth]++;
1702 count_block_size_distribution[len]++;
1704 count_block_size_distribution[10]++;
1706 count_block_size_distribution[11]++;
1708 count_block_size_distribution[12]++;
1710 count_block_size_distribution[13]++;
1712 count_block_size_distribution[14]++;
1714 count_block_size_distribution[15]++;
1716 count_block_size_distribution[16]++;
1718 count_block_size_distribution[17]++;
1724 count_analyse_iterations[0]++;
1725 else if (loops == 2)
1726 count_analyse_iterations[1]++;
1727 else if (loops == 3)
1728 count_analyse_iterations[2]++;
1729 else if (loops == 4)
1730 count_analyse_iterations[3]++;
1732 count_analyse_iterations[4]++;
1734 if (block_count <= 5)
1735 count_method_bb_distribution[0]++;
1736 else if (block_count <= 10)
1737 count_method_bb_distribution[1]++;
1738 else if (block_count <= 15)
1739 count_method_bb_distribution[2]++;
1740 else if (block_count <= 20)
1741 count_method_bb_distribution[3]++;
1742 else if (block_count <= 30)
1743 count_method_bb_distribution[4]++;
1744 else if (block_count <= 40)
1745 count_method_bb_distribution[5]++;
1746 else if (block_count <= 50)
1747 count_method_bb_distribution[6]++;
1748 else if (block_count <= 75)
1749 count_method_bb_distribution[7]++;
1751 count_method_bb_distribution[8]++;
1756 static void print_stack(stackptr s)
1773 if (s->flags & SAVEDVAR)
1774 switch (s->varkind) {
1776 if (s->flags & INMEMORY)
1777 printf(" M%02d", s->regoff);
1778 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1779 printf(" F%02d", s->regoff);
1781 printf(" %3s", regs[s->regoff]);
1784 printf(" I%02d", s->varnum);
1787 printf(" L%02d", s->varnum);
1790 printf(" A%02d", s->varnum);
1793 printf(" !%02d", j);
1796 switch (s->varkind) {
1798 if (s->flags & INMEMORY)
1799 printf(" m%02d", s->regoff);
1800 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1801 printf(" f%02d", s->regoff);
1803 printf(" %3s", regs[s->regoff]);
1806 printf(" i%02d", s->varnum);
1809 printf(" l%02d", s->varnum);
1812 printf(" a%02d", s->varnum);
1815 printf(" ?%02d", j);
1823 static void print_reg(stackptr s) {
1825 if (s->flags & SAVEDVAR)
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);
1846 switch (s->varkind) {
1848 if (s->flags & INMEMORY)
1849 printf(" Tm%02d", s->regoff);
1851 printf(" Tr%02d", s->regoff);
1854 printf(" S %02d", s->varnum);
1857 printf(" L %02d", s->varnum);
1860 printf(" A %02d", s->varnum);
1863 printf(" ? %02d", s->varnum);
1873 static char *builtin_name(functionptr bptr)
1875 builtin_descriptor *bdesc = builtin_desc;
1876 while ((bdesc->bptr != NULL) && (bdesc->bptr != bptr))
1882 static char *jit_type[] = {
1891 void show_icmd_method()
1902 utf_fprint(stdout, class->name);
1904 utf_fprint(stdout, method->name);
1906 utf_fprint(stdout, method->descriptor);
1907 printf ("\n\nMax locals: %d\n", (int) maxlocals);
1908 printf ("Max stack: %d\n", (int) maxstack);
1910 printf ("Exceptions (Number: %d):\n", exceptiontablelength);
1911 for (ex = extable; ex != NULL; ex = ex->down) {
1912 printf(" L%03d ... ", ex->start->debug_nr );
1913 printf("L%03d = ", ex->end->debug_nr);
1914 printf("L%03d\n", ex->handler->debug_nr);
1917 printf ("Local Table:\n");
1918 for (i = 0; i < maxlocals; i++) {
1919 printf(" %3d: ", i);
1920 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1921 if (locals[i][j].type >= 0) {
1922 printf(" (%s) ", jit_type[j]);
1923 if (locals[i][j].flags & INMEMORY)
1924 printf("m%2d", locals[i][j].regoff);
1925 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1926 printf("f%02d", locals[i][j].regoff);
1928 printf("%3s", regs[locals[i][j].regoff]);
1934 printf ("Interface Table:\n");
1935 for (i = 0; i < maxstack; i++) {
1936 if ((interfaces[i][0].type >= 0) || (interfaces[i][1].type >= 0) ||
1937 (interfaces[i][2].type >= 0) || (interfaces[i][3].type >= 0) ||
1938 (interfaces[i][4].type >= 0)) {
1939 printf(" %3d: ", i);
1940 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1941 if (interfaces[i][j].type >= 0) {
1942 printf(" (%s) ", jit_type[j]);
1943 if (interfaces[i][j].flags & SAVEDVAR) {
1944 if (interfaces[i][j].flags & INMEMORY)
1945 printf("M%2d", interfaces[i][j].regoff);
1946 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1947 printf("F%02d", interfaces[i][j].regoff);
1949 printf("%3s", regs[interfaces[i][j].regoff]);
1952 if (interfaces[i][j].flags & INMEMORY)
1953 printf("m%2d", interfaces[i][j].regoff);
1954 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1955 printf("f%02d", interfaces[i][j].regoff);
1957 printf("%3s", regs[interfaces[i][j].regoff]);
1965 if (showdisassemble) {
1966 #if defined(__I386__) || defined(__X86_64__)
1970 u1ptr = method->mcode + dseglen;
1971 for (i = 0; i < block[0].mpc; i++, u1ptr++) {
1972 a = disassinstr(u1ptr, i);
1978 s4ptr = (s4 *) (method->mcode + dseglen);
1979 for (i = 0; i < block[0].mpc; i += 4, s4ptr++) {
1980 disassinstr(*s4ptr, i);
1987 for (bptr = block; bptr != NULL; bptr = bptr->next) {
1988 if (bptr->flags != BBDELETED) {
1989 deadcode = bptr->flags <= BBREACHED;
1992 for (j = maxstack; j > 0; j--)
1995 print_stack(bptr->instack);
1996 printf("] L%03d(%d - %d):\n", bptr->debug_nr, bptr->icount, bptr->pre_count);
1997 iptr = bptr->iinstr;
1999 for (i=0; i < bptr->icount; i++, iptr++) {
2002 for (j = maxstack; j > 0; j--)
2006 print_stack(iptr->dst);
2007 printf("] %4d %s", i, icmd_names[iptr->opc]);
2008 switch ((int) iptr->opc) {
2009 case ICMD_IADDCONST:
2010 case ICMD_ISUBCONST:
2011 case ICMD_IMULCONST:
2014 case ICMD_IREM0X10001:
2015 case ICMD_IANDCONST:
2017 case ICMD_IXORCONST:
2018 case ICMD_ISHLCONST:
2019 case ICMD_ISHRCONST:
2020 case ICMD_IUSHRCONST:
2021 case ICMD_LSHLCONST:
2022 case ICMD_LSHRCONST:
2023 case ICMD_LUSHRCONST:
2025 case ICMD_ELSE_ICONST:
2026 case ICMD_IFEQ_ICONST:
2027 case ICMD_IFNE_ICONST:
2028 case ICMD_IFLT_ICONST:
2029 case ICMD_IFGE_ICONST:
2030 case ICMD_IFGT_ICONST:
2031 case ICMD_IFLE_ICONST:
2032 printf(" %d", iptr->val.i);
2034 case ICMD_LADDCONST:
2035 case ICMD_LSUBCONST:
2036 case ICMD_LMULCONST:
2039 case ICMD_LANDCONST:
2041 case ICMD_LXORCONST:
2043 #if defined(__I386__)
2044 printf(" %lld", iptr->val.l);
2046 printf(" %ld", iptr->val.l);
2050 printf(" %f", iptr->val.f);
2053 printf(" %f", iptr->val.d);
2056 printf(" %p", iptr->val.a);
2060 printf(" %d,", ((fieldinfo *) iptr->val.a)->offset);
2061 case ICMD_PUTSTATIC:
2062 case ICMD_GETSTATIC:
2065 ((fieldinfo *) iptr->val.a)->name);
2068 printf(" %d + %d", iptr->op1, iptr->val.i);
2103 printf(" %d", iptr->op1);
2108 ((classinfo *) iptr->val.a)->name);
2111 switch (iptr->op1) {
2138 case ICMD_ANEWARRAY:
2142 ((classinfo *) iptr->val.a)->name);
2145 case ICMD_CHECKCAST:
2146 case ICMD_INSTANCEOF:
2148 classinfo *c = iptr->val.a;
2149 if (c->flags & ACC_INTERFACE)
2150 printf(" (INTERFACE) ");
2152 printf(" (CLASS,%3d) ", c->vftbl->diffval);
2153 utf_fprint(stdout, c->name);
2159 printf(" %s", builtin_name((functionptr) iptr->val.a));
2161 case ICMD_INVOKEVIRTUAL:
2162 case ICMD_INVOKESPECIAL:
2163 case ICMD_INVOKESTATIC:
2164 case ICMD_INVOKEINTERFACE:
2167 ((methodinfo *) iptr->val.a)->class->name);
2170 ((methodinfo *) iptr->val.a)->name);
2178 printf("(%d) L%03d", iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
2186 printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
2191 case ICMD_IFNONNULL:
2192 case ICMD_IF_ICMPEQ:
2193 case ICMD_IF_ICMPNE:
2194 case ICMD_IF_ICMPLT:
2195 case ICMD_IF_ICMPGE:
2196 case ICMD_IF_ICMPGT:
2197 case ICMD_IF_ICMPLE:
2198 case ICMD_IF_LCMPEQ:
2199 case ICMD_IF_LCMPNE:
2200 case ICMD_IF_LCMPLT:
2201 case ICMD_IF_LCMPGE:
2202 case ICMD_IF_LCMPGT:
2203 case ICMD_IF_LCMPLE:
2204 case ICMD_IF_ACMPEQ:
2205 case ICMD_IF_ACMPNE:
2206 printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
2208 case ICMD_TABLESWITCH:
2210 s4ptr = iptr->val.a;
2211 tptr = (void **) iptr->target;
2213 printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
2219 j = *s4ptr++; /* low */
2220 j = *s4ptr++ - j; /* high */
2222 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2227 case ICMD_LOOKUPSWITCH:
2228 s4ptr = iptr->val.a;
2229 tptr = (void **) iptr->target;
2231 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2232 s4ptr++; /* default */
2233 j = *s4ptr; /* count */
2237 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2245 if (showdisassemble && (!deadcode)) {
2246 #if defined(__I386__) || defined(__X86_64__)
2252 u1ptr = method->mcode + dseglen + i;
2254 if (bptr->next != NULL) {
2255 for (; i < bptr->next->mpc; i++, u1ptr++) {
2256 a = disassinstr(u1ptr, i);
2263 for (; u1ptr < (u1 *) (method->mcode + method->mcodelength); i++, u1ptr++) {
2264 a = disassinstr(u1ptr, i);
2273 s4ptr = (s4 *) (method->mcode + dseglen + i);
2275 if (bptr->next != NULL) {
2276 for (; i < bptr->next->mpc; i += 4, s4ptr++) {
2277 disassinstr(*s4ptr, i);
2282 for (; s4ptr < (s4 *) (method->mcode + method->mcodelength); i += 4, s4ptr++) {
2283 disassinstr(*s4ptr, i);
2295 * These are local overrides for various environment variables in Emacs.
2296 * Please do not remove this and leave it at the end of the file, where
2297 * Emacs will automagically detect them.
2298 * ---------------------------------------------------------------------
2301 * indent-tabs-mode: t