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 624 2003-11-13 14:06:52Z twisti $
42 #include "toolbox/loging.h"
43 #include "toolbox/memory.h"
46 /* from codegen.inc */
51 #define COUNT(cnt) cnt++
56 #define STACKRESET {curstack=0;stackdepth=0;}
58 #define TYPEPANIC {show_icmd_method();panic("Stack type mismatch");}
59 #define CURKIND curstack->varkind
60 #define CURTYPE curstack->type
62 #define NEWSTACK(s,v,n) {new->prev=curstack;new->type=s;new->flags=0;\
63 new->varkind=v;new->varnum=n;curstack=new;new++;}
64 #define NEWSTACKn(s,n) NEWSTACK(s,UNDEFVAR,n)
65 #define NEWSTACK0(s) NEWSTACK(s,UNDEFVAR,0)
66 #define NEWXSTACK {NEWSTACK(TYPE_ADR,STACKVAR,0);curstack=0;}
68 #define SETDST {iptr->dst=curstack;}
69 #define POP(s) {if(s!=curstack->type){TYPEPANIC;}\
70 if(curstack->varkind==UNDEFVAR)curstack->varkind=TEMPVAR;\
71 curstack=curstack->prev;}
72 #define POPANY {if(curstack->varkind==UNDEFVAR)curstack->varkind=TEMPVAR;\
73 curstack=curstack->prev;}
74 #define COPY(s,d) {(d)->flags=0;(d)->type=(s)->type;\
75 (d)->varkind=(s)->varkind;(d)->varnum=(s)->varnum;}
77 #define PUSHCONST(s){NEWSTACKn(s,stackdepth);SETDST;stackdepth++;}
78 #define LOAD(s,v,n) {NEWSTACK(s,v,n);SETDST;stackdepth++;}
79 #define STORE(s) {POP(s);SETDST;stackdepth--;}
80 #define OP1_0(s) {POP(s);SETDST;stackdepth--;}
81 #define OP1_0ANY {POPANY;SETDST;stackdepth--;}
82 #define OP0_1(s) {NEWSTACKn(s,stackdepth);SETDST;stackdepth++;}
83 #define OP1_1(s,d) {POP(s);NEWSTACKn(d,stackdepth-1);SETDST;}
84 #define OP2_0(s) {POP(s);POP(s);SETDST;stackdepth-=2;}
85 #define OPTT2_0(t,b){POP(t);POP(b);SETDST;stackdepth-=2;}
86 #define OP2_1(s) {POP(s);POP(s);NEWSTACKn(s,stackdepth-2);SETDST;stackdepth--;}
87 #define OP2IAT_1(s) {POP(TYPE_INT);POP(TYPE_ADR);NEWSTACKn(s,stackdepth-2);\
89 #define OP2IT_1(s) {POP(TYPE_INT);POP(s);NEWSTACKn(s,stackdepth-2);\
91 #define OPTT2_1(s,d){POP(s);POP(s);NEWSTACKn(d,stackdepth-2);SETDST;stackdepth--;}
92 #define OP2_2(s) {POP(s);POP(s);NEWSTACKn(s,stackdepth-2);\
93 NEWSTACKn(s,stackdepth-1);SETDST;}
94 #define OP3TIA_0(s) {POP(s);POP(TYPE_INT);POP(TYPE_ADR);SETDST;stackdepth-=3;}
95 #define OP3_0(s) {POP(s);POP(s);POP(s);SETDST;stackdepth-=3;}
96 #define POPMANY(i) {stackdepth-=i;while(--i>=0){POPANY;}SETDST;}
97 #define DUP {NEWSTACK(CURTYPE,CURKIND,curstack->varnum);SETDST;\
99 #define SWAP {COPY(curstack,new);POPANY;COPY(curstack,new+1);POPANY;\
100 new[0].prev=curstack;new[1].prev=new;\
101 curstack=new+1;new+=2;SETDST;}
102 #define DUP_X1 {COPY(curstack,new);COPY(curstack,new+2);POPANY;\
103 COPY(curstack,new+1);POPANY;new[0].prev=curstack;\
104 new[1].prev=new;new[2].prev=new+1;\
105 curstack=new+2;new+=3;SETDST;stackdepth++;}
106 #define DUP2_X1 {COPY(curstack,new+1);COPY(curstack,new+4);POPANY;\
107 COPY(curstack,new);COPY(curstack,new+3);POPANY;\
108 COPY(curstack,new+2);POPANY;new[0].prev=curstack;\
109 new[1].prev=new;new[2].prev=new+1;\
110 new[3].prev=new+2;new[4].prev=new+3;\
111 curstack=new+4;new+=5;SETDST;stackdepth+=2;}
112 #define DUP_X2 {COPY(curstack,new);COPY(curstack,new+3);POPANY;\
113 COPY(curstack,new+2);POPANY;COPY(curstack,new+1);POPANY;\
114 new[0].prev=curstack;new[1].prev=new;\
115 new[2].prev=new+1;new[3].prev=new+2;\
116 curstack=new+3;new+=4;SETDST;stackdepth++;}
117 #define DUP2_X2 {COPY(curstack,new+1);COPY(curstack,new+5);POPANY;\
118 COPY(curstack,new);COPY(curstack,new+4);POPANY;\
119 COPY(curstack,new+3);POPANY;COPY(curstack,new+2);POPANY;\
120 new[0].prev=curstack;new[1].prev=new;\
121 new[2].prev=new+1;new[3].prev=new+2;\
122 new[4].prev=new+3;new[5].prev=new+4;\
123 curstack=new+5;new+=6;SETDST;stackdepth+=2;}
125 #define COPYCURSTACK(copy) {\
138 copy->varkind=STACKVAR;\
154 if((copy->varkind==STACKVAR)&&(copy->varnum>i))\
155 copy->varkind=TEMPVAR;\
157 copy->varkind=STACKVAR;\
160 interfaces[i][copy->type].type = copy->type;\
161 interfaces[i][copy->type].flags |= copy->flags;\
162 i--;copy=copy->prev;\
167 interfaces[i][copy->type].type = copy->type;\
168 if(copy->varkind==STACKVAR){\
169 if (copy->flags & SAVEDVAR)\
170 interfaces[i][copy->type].flags |= SAVEDVAR;\
172 i--;copy=copy->prev;\
177 #define MARKREACHED(b,c) {\
179 {COPYCURSTACK(c);b->flags=0;b->instack=c;b->indepth=stackdepth;}\
180 else {stackptr s=curstack;stackptr t=b->instack;\
181 if(b->indepth!=stackdepth)\
182 {show_icmd_method();panic("Stack depth mismatch");}\
183 while(s){if (s->type!=t->type)\
185 s=s->prev;t=t->prev;\
199 int opcode, i, len, loops;
200 int superblockend, repeat, deadcode;
207 int *argren = DMNEW(int, maxlocals);
208 //int *argren = (int *)alloca(maxlocals * sizeof(int)); /* table for argument renaming */
209 for (i = 0; i < maxlocals; i++)
215 block[0].flags = BBREACHED;
216 block[0].instack = 0;
217 block[0].indepth = 0;
219 for (i = 0; i < exceptiontablelength; i++) {
220 bptr = &block[block_index[extable[i].handlerpc]];
221 bptr->flags = BBREACHED;
222 bptr->type = BBTYPE_EXH;
225 bptr->pre_count = 10000;
230 #ifdef CONDITIONAL_LOADCONST
231 b_count = block_count;
233 while (--b_count >= 0) {
234 if (bptr->icount != 0) {
235 iptr = bptr->iinstr + bptr->icount - 1;
268 block[block_index[iptr->op1]].pre_count++;
271 case ICMD_TABLESWITCH:
273 block[block_index[*s4ptr++]].pre_count++; /* default */
274 i = *s4ptr++; /* low */
275 i = *s4ptr++ - i + 1; /* high */
277 block[block_index[*s4ptr++]].pre_count++;
281 case ICMD_LOOKUPSWITCH:
283 block[block_index[*s4ptr++]].pre_count++; /* default */
284 i = *s4ptr++; /* count */
286 block[block_index[s4ptr[1]]].pre_count++;
302 b_count = block_count;
304 superblockend = true;
308 while (--b_count >= 0) {
309 if (bptr->flags == BBDELETED) {
312 else if (superblockend && (bptr->flags < BBREACHED))
314 else if (bptr->flags <= BBREACHED) {
316 stackdepth = bptr->indepth;
317 else if (bptr->flags < BBREACHED) {
319 bptr->instack = copy;
320 bptr->indepth = stackdepth;
322 else if (bptr->indepth != stackdepth) {
324 panic("Stack depth mismatch");
327 curstack = bptr->instack;
329 superblockend = false;
330 bptr->flags = BBFINISHED;
333 b_index = bptr - block;
338 #ifdef USEBUILTINTABLE
340 stdopdescriptor *breplace;
341 breplace = find_builtin(opcode);
343 /* if (breplace != blast && opcode == breplace->opcode && !breplace->supported) { */
344 if (opcode == breplace->opcode && !breplace->supported) {
345 iptr[0].opc = breplace->icmd;
346 iptr[0].op1 = breplace->type_d;
347 iptr[0].val.a = breplace->builtin;
348 isleafmethod = false;
349 switch (breplace->icmd) {
364 case ICMD_CHECKASIZE:
366 case ICMD_IFEQ_ICONST:
367 case ICMD_IFNE_ICONST:
368 case ICMD_IFLT_ICONST:
369 case ICMD_IFGE_ICONST:
370 case ICMD_IFGT_ICONST:
371 case ICMD_IFLE_ICONST:
372 case ICMD_ELSE_ICONST:
377 locals[iptr->op1][TYPE_ADR].type = TYPE_ADR;
379 COUNT(count_pcmd_return);
381 superblockend = true;
384 /* pop 0 push 1 const */
387 COUNT(count_pcmd_load);
389 switch (iptr[1].opc) {
391 iptr[0].opc = ICMD_IADDCONST;
393 iptr[1].opc = ICMD_NOP;
394 OP1_1(TYPE_INT,TYPE_INT);
395 COUNT(count_pcmd_op);
398 iptr[0].opc = ICMD_ISUBCONST;
399 goto icmd_iconst_tail;
401 iptr[0].opc = ICMD_IMULCONST;
402 goto icmd_iconst_tail;
404 if (iptr[0].val.i == 0x00000002)
406 else if (iptr[0].val.i == 0x00000004)
408 else if (iptr[0].val.i == 0x00000008)
410 else if (iptr[0].val.i == 0x00000010)
412 else if (iptr[0].val.i == 0x00000020)
414 else if (iptr[0].val.i == 0x00000040)
416 else if (iptr[0].val.i == 0x00000080)
418 else if (iptr[0].val.i == 0x00000100)
420 else if (iptr[0].val.i == 0x00000200)
422 else if (iptr[0].val.i == 0x00000400)
424 else if (iptr[0].val.i == 0x00000800)
426 else if (iptr[0].val.i == 0x00001000)
428 else if (iptr[0].val.i == 0x00002000)
430 else if (iptr[0].val.i == 0x00004000)
432 else if (iptr[0].val.i == 0x00008000)
434 else if (iptr[0].val.i == 0x00010000)
436 else if (iptr[0].val.i == 0x00020000)
438 else if (iptr[0].val.i == 0x00040000)
440 else if (iptr[0].val.i == 0x00080000)
442 else if (iptr[0].val.i == 0x00100000)
444 else if (iptr[0].val.i == 0x00200000)
446 else if (iptr[0].val.i == 0x00400000)
448 else if (iptr[0].val.i == 0x00800000)
450 else if (iptr[0].val.i == 0x01000000)
452 else if (iptr[0].val.i == 0x02000000)
454 else if (iptr[0].val.i == 0x04000000)
456 else if (iptr[0].val.i == 0x08000000)
458 else if (iptr[0].val.i == 0x10000000)
460 else if (iptr[0].val.i == 0x20000000)
462 else if (iptr[0].val.i == 0x40000000)
464 else if (iptr[0].val.i == 0x80000000)
470 iptr[0].opc = ICMD_IDIVPOW2;
471 goto icmd_iconst_tail;
473 #if !defined(NO_DIV_OPT)
474 if (iptr[0].val.i == 0x10001) {
475 iptr[0].opc = ICMD_IREM0X10001;
476 goto icmd_iconst_tail;
479 if ((iptr[0].val.i == 0x00000002) ||
480 (iptr[0].val.i == 0x00000004) ||
481 (iptr[0].val.i == 0x00000008) ||
482 (iptr[0].val.i == 0x00000010) ||
483 (iptr[0].val.i == 0x00000020) ||
484 (iptr[0].val.i == 0x00000040) ||
485 (iptr[0].val.i == 0x00000080) ||
486 (iptr[0].val.i == 0x00000100) ||
487 (iptr[0].val.i == 0x00000200) ||
488 (iptr[0].val.i == 0x00000400) ||
489 (iptr[0].val.i == 0x00000800) ||
490 (iptr[0].val.i == 0x00001000) ||
491 (iptr[0].val.i == 0x00002000) ||
492 (iptr[0].val.i == 0x00004000) ||
493 (iptr[0].val.i == 0x00008000) ||
494 (iptr[0].val.i == 0x00010000) ||
495 (iptr[0].val.i == 0x00020000) ||
496 (iptr[0].val.i == 0x00040000) ||
497 (iptr[0].val.i == 0x00080000) ||
498 (iptr[0].val.i == 0x00100000) ||
499 (iptr[0].val.i == 0x00200000) ||
500 (iptr[0].val.i == 0x00400000) ||
501 (iptr[0].val.i == 0x00800000) ||
502 (iptr[0].val.i == 0x01000000) ||
503 (iptr[0].val.i == 0x02000000) ||
504 (iptr[0].val.i == 0x04000000) ||
505 (iptr[0].val.i == 0x08000000) ||
506 (iptr[0].val.i == 0x10000000) ||
507 (iptr[0].val.i == 0x20000000) ||
508 (iptr[0].val.i == 0x40000000) ||
509 (iptr[0].val.i == 0x80000000)) {
510 iptr[0].opc = ICMD_IREMPOW2;
512 goto icmd_iconst_tail;
517 iptr[0].opc = ICMD_IANDCONST;
518 goto icmd_iconst_tail;
520 iptr[0].opc = ICMD_IORCONST;
521 goto icmd_iconst_tail;
523 iptr[0].opc = ICMD_IXORCONST;
524 goto icmd_iconst_tail;
526 iptr[0].opc = ICMD_ISHLCONST;
527 goto icmd_iconst_tail;
529 iptr[0].opc = ICMD_ISHRCONST;
530 goto icmd_iconst_tail;
532 iptr[0].opc = ICMD_IUSHRCONST;
533 goto icmd_iconst_tail;
534 #if SUPPORT_LONG_SHIFT
536 iptr[0].opc = ICMD_LSHLCONST;
537 goto icmd_lconst_tail;
539 iptr[0].opc = ICMD_LSHRCONST;
540 goto icmd_lconst_tail;
542 iptr[0].opc = ICMD_LUSHRCONST;
543 goto icmd_lconst_tail;
546 iptr[0].opc = ICMD_IFEQ;
548 iptr[0].op1 = iptr[1].op1;
551 /* iptr[1].opc = ICMD_NOP; */
553 tbptr = block + block_index[iptr->op1];
555 iptr[0].target = (void *) tbptr;
557 MARKREACHED(tbptr, copy);
558 COUNT(count_pcmd_bra);
561 iptr[0].opc = ICMD_IFLT;
562 goto icmd_if_icmp_tail;
564 iptr[0].opc = ICMD_IFLE;
565 goto icmd_if_icmp_tail;
567 iptr[0].opc = ICMD_IFNE;
568 goto icmd_if_icmp_tail;
570 iptr[0].opc = ICMD_IFGT;
571 goto icmd_if_icmp_tail;
573 iptr[0].opc = ICMD_IFGE;
574 goto icmd_if_icmp_tail;
583 COUNT(count_pcmd_load);
585 switch (iptr[1].opc) {
588 iptr[0].opc = ICMD_LADDCONST;
590 iptr[1].opc = ICMD_NOP;
591 OP1_1(TYPE_LNG,TYPE_LNG);
592 COUNT(count_pcmd_op);
595 iptr[0].opc = ICMD_LSUBCONST;
596 goto icmd_lconst_tail;
600 iptr[0].opc = ICMD_LMULCONST;
601 goto icmd_lconst_tail;
605 if (iptr[0].val.l == 0x00000002)
607 else if (iptr[0].val.l == 0x00000004)
609 else if (iptr[0].val.l == 0x00000008)
611 else if (iptr[0].val.l == 0x00000010)
613 else if (iptr[0].val.l == 0x00000020)
615 else if (iptr[0].val.l == 0x00000040)
617 else if (iptr[0].val.l == 0x00000080)
619 else if (iptr[0].val.l == 0x00000100)
621 else if (iptr[0].val.l == 0x00000200)
623 else if (iptr[0].val.l == 0x00000400)
625 else if (iptr[0].val.l == 0x00000800)
627 else if (iptr[0].val.l == 0x00001000)
629 else if (iptr[0].val.l == 0x00002000)
631 else if (iptr[0].val.l == 0x00004000)
633 else if (iptr[0].val.l == 0x00008000)
635 else if (iptr[0].val.l == 0x00010000)
637 else if (iptr[0].val.l == 0x00020000)
639 else if (iptr[0].val.l == 0x00040000)
641 else if (iptr[0].val.l == 0x00080000)
643 else if (iptr[0].val.l == 0x00100000)
645 else if (iptr[0].val.l == 0x00200000)
647 else if (iptr[0].val.l == 0x00400000)
649 else if (iptr[0].val.l == 0x00800000)
651 else if (iptr[0].val.l == 0x01000000)
653 else if (iptr[0].val.l == 0x02000000)
655 else if (iptr[0].val.l == 0x04000000)
657 else if (iptr[0].val.l == 0x08000000)
659 else if (iptr[0].val.l == 0x10000000)
661 else if (iptr[0].val.l == 0x20000000)
663 else if (iptr[0].val.l == 0x40000000)
665 else if (iptr[0].val.l == 0x80000000)
671 iptr[0].opc = ICMD_LDIVPOW2;
672 goto icmd_lconst_tail;
674 #if !defined(NO_DIV_OPT)
675 if (iptr[0].val.l == 0x10001) {
676 iptr[0].opc = ICMD_LREM0X10001;
677 goto icmd_lconst_tail;
680 if ((iptr[0].val.l == 0x00000002) ||
681 (iptr[0].val.l == 0x00000004) ||
682 (iptr[0].val.l == 0x00000008) ||
683 (iptr[0].val.l == 0x00000010) ||
684 (iptr[0].val.l == 0x00000020) ||
685 (iptr[0].val.l == 0x00000040) ||
686 (iptr[0].val.l == 0x00000080) ||
687 (iptr[0].val.l == 0x00000100) ||
688 (iptr[0].val.l == 0x00000200) ||
689 (iptr[0].val.l == 0x00000400) ||
690 (iptr[0].val.l == 0x00000800) ||
691 (iptr[0].val.l == 0x00001000) ||
692 (iptr[0].val.l == 0x00002000) ||
693 (iptr[0].val.l == 0x00004000) ||
694 (iptr[0].val.l == 0x00008000) ||
695 (iptr[0].val.l == 0x00010000) ||
696 (iptr[0].val.l == 0x00020000) ||
697 (iptr[0].val.l == 0x00040000) ||
698 (iptr[0].val.l == 0x00080000) ||
699 (iptr[0].val.l == 0x00100000) ||
700 (iptr[0].val.l == 0x00200000) ||
701 (iptr[0].val.l == 0x00400000) ||
702 (iptr[0].val.l == 0x00800000) ||
703 (iptr[0].val.l == 0x01000000) ||
704 (iptr[0].val.l == 0x02000000) ||
705 (iptr[0].val.l == 0x04000000) ||
706 (iptr[0].val.l == 0x08000000) ||
707 (iptr[0].val.l == 0x10000000) ||
708 (iptr[0].val.l == 0x20000000) ||
709 (iptr[0].val.l == 0x40000000) ||
710 (iptr[0].val.l == 0x80000000)) {
711 iptr[0].opc = ICMD_LREMPOW2;
713 goto icmd_lconst_tail;
720 iptr[0].opc = ICMD_LANDCONST;
721 goto icmd_lconst_tail;
723 iptr[0].opc = ICMD_LORCONST;
724 goto icmd_lconst_tail;
726 iptr[0].opc = ICMD_LXORCONST;
727 goto icmd_lconst_tail;
729 #if !defined(NOLONG_CONDITIONAL)
731 if ((len > 1) && (iptr[2].val.i == 0)) {
732 switch (iptr[2].opc) {
734 iptr[0].opc = ICMD_IF_LEQ;
735 icmd_lconst_lcmp_tail:
736 iptr[0].op1 = iptr[2].op1;
739 /* iptr[1].opc = ICMD_NOP;
740 iptr[2].opc = ICMD_NOP; */
742 tbptr = block + block_index[iptr->op1];
744 iptr[0].target = (void *) tbptr;
746 MARKREACHED(tbptr, copy);
747 COUNT(count_pcmd_bra);
748 COUNT(count_pcmd_op);
751 iptr[0].opc = ICMD_IF_LNE;
752 goto icmd_lconst_lcmp_tail;
754 iptr[0].opc = ICMD_IF_LLT;
755 goto icmd_lconst_lcmp_tail;
757 iptr[0].opc = ICMD_IF_LGT;
758 goto icmd_lconst_lcmp_tail;
760 iptr[0].opc = ICMD_IF_LLE;
761 goto icmd_lconst_lcmp_tail;
763 iptr[0].opc = ICMD_IF_LGE;
764 goto icmd_lconst_lcmp_tail;
767 } /* switch (iptr[2].opc) */
768 } /* if (iptr[2].val.i == 0) */
781 COUNT(count_pcmd_load);
785 COUNT(count_pcmd_load);
789 COUNT(count_pcmd_load);
793 /* pop 0 push 1 load */
800 COUNT(count_load_instruction);
801 i = opcode-ICMD_ILOAD;
802 iptr->op1 = argren[iptr->op1];
803 locals[iptr->op1][i].type = i;
804 LOAD(i, LOCALVAR, iptr->op1);
814 COUNT(count_check_null);
815 COUNT(count_check_bound);
816 COUNT(count_pcmd_mem);
817 OP2IAT_1(opcode-ICMD_IALOAD);
823 COUNT(count_check_null);
824 COUNT(count_check_bound);
825 COUNT(count_pcmd_mem);
829 /* pop 0 push 0 iinc */
835 count_store_depth[10]++;
837 count_store_depth[i]++;
842 if ((copy->varkind == LOCALVAR) &&
843 (copy->varnum == iptr->op1)) {
844 copy->varkind = TEMPVAR;
853 /* pop 1 push 0 store */
862 i = opcode - ICMD_ISTORE;
863 locals[iptr->op1][i].type = i;
868 count_store_length[20]++;
870 count_store_length[i]++;
873 count_store_depth[10]++;
875 count_store_depth[i]++;
877 copy = curstack->prev;
880 if ((copy->varkind == LOCALVAR) &&
881 (copy->varnum == iptr->op1)) {
882 copy->varkind = TEMPVAR;
888 if ((new - curstack) == 1) {
889 curstack->varkind = LOCALVAR;
890 curstack->varnum = iptr->op1;
892 STORE(opcode-ICMD_ISTORE);
902 COUNT(count_check_null);
903 COUNT(count_check_bound);
904 COUNT(count_pcmd_mem);
905 OP3TIA_0(opcode-ICMD_IASTORE);
910 COUNT(count_check_null);
911 COUNT(count_check_bound);
912 COUNT(count_pcmd_mem);
927 COUNT(count_pcmd_return);
928 OP1_0(opcode-ICMD_IRETURN);
929 superblockend = true;
933 COUNT(count_check_null);
937 superblockend = true;
941 COUNT(count_pcmd_mem);
945 /* pop 1 push 0 branch */
949 COUNT(count_pcmd_bra);
951 tbptr = block + block_index[iptr->op1];
953 iptr[0].target = (void *) tbptr;
955 MARKREACHED(tbptr, copy);
964 COUNT(count_pcmd_bra);
965 #ifdef CONDITIONAL_LOADCONST
967 tbptr = block + b_index;
968 if ((b_count >= 3) &&
969 ((b_index + 2) == block_index[iptr[0].op1]) &&
970 (tbptr[1].pre_count == 1) &&
971 (iptr[1].opc == ICMD_ICONST) &&
972 (iptr[2].opc == ICMD_GOTO) &&
973 ((b_index + 3) == block_index[iptr[2].op1]) &&
974 (tbptr[2].pre_count == 1) &&
975 (iptr[3].opc == ICMD_ICONST)) {
976 OP1_1(TYPE_INT, TYPE_INT);
977 switch (iptr[0].opc) {
979 iptr[0].opc = ICMD_IFNE_ICONST;
982 iptr[0].opc = ICMD_IFEQ_ICONST;
985 iptr[0].opc = ICMD_IFGE_ICONST;
988 iptr[0].opc = ICMD_IFLT_ICONST;
991 iptr[0].opc = ICMD_IFLE_ICONST;
994 iptr[0].opc = ICMD_IFGT_ICONST;
997 iptr[0].val.i = iptr[1].val.i;
998 iptr[1].opc = ICMD_ELSE_ICONST;
999 iptr[1].val.i = iptr[3].val.i;
1000 iptr[2].opc = ICMD_NOP;
1001 iptr[3].opc = ICMD_NOP;
1002 tbptr[1].flags = BBDELETED;
1003 tbptr[2].flags = BBDELETED;
1004 tbptr[1].icount = 0;
1005 tbptr[2].icount = 0;
1006 if (tbptr[3].pre_count == 2) {
1007 len += tbptr[3].icount + 3;
1008 bptr->icount += tbptr[3].icount + 3;
1009 tbptr[3].flags = BBDELETED;
1010 tbptr[3].icount = 0;
1023 tbptr = block + block_index[iptr->op1];
1025 iptr[0].target = (void *) tbptr;
1027 MARKREACHED(tbptr, copy);
1030 /* pop 0 push 0 branch */
1033 COUNT(count_pcmd_bra);
1034 tbptr = block + block_index[iptr->op1];
1036 iptr[0].target = (void *) tbptr;
1038 MARKREACHED(tbptr, copy);
1040 superblockend = true;
1043 /* pop 1 push 0 table branch */
1045 case ICMD_TABLESWITCH:
1046 COUNT(count_pcmd_table);
1048 s4ptr = iptr->val.a;
1049 tbptr = block + block_index[*s4ptr++]; /* default */
1050 MARKREACHED(tbptr, copy);
1051 i = *s4ptr++; /* low */
1052 i = *s4ptr++ - i + 1; /* high */
1054 tptr = DMNEW(void*, i+1);
1055 iptr->target = (void *) tptr;
1057 tptr[0] = (void *) tbptr;
1061 tbptr = block + block_index[*s4ptr++];
1063 tptr[0] = (void *) tbptr;
1066 MARKREACHED(tbptr, copy);
1069 superblockend = true;
1072 /* pop 1 push 0 table branch */
1074 case ICMD_LOOKUPSWITCH:
1075 COUNT(count_pcmd_table);
1077 s4ptr = iptr->val.a;
1078 tbptr = block + block_index[*s4ptr++]; /* default */
1079 MARKREACHED(tbptr, copy);
1080 i = *s4ptr++; /* count */
1082 tptr = DMNEW(void*, i+1);
1083 iptr->target = (void *) tptr;
1085 tptr[0] = (void *) tbptr;
1089 tbptr = block + block_index[s4ptr[1]];
1091 tptr[0] = (void *) tbptr;
1094 MARKREACHED(tbptr, copy);
1098 superblockend = true;
1101 case ICMD_NULLCHECKPOP:
1102 case ICMD_MONITORENTER:
1103 COUNT(count_check_null);
1104 case ICMD_MONITOREXIT:
1108 /* pop 2 push 0 branch */
1110 case ICMD_IF_ICMPEQ:
1111 case ICMD_IF_ICMPNE:
1112 case ICMD_IF_ICMPLT:
1113 case ICMD_IF_ICMPGE:
1114 case ICMD_IF_ICMPGT:
1115 case ICMD_IF_ICMPLE:
1116 COUNT(count_pcmd_bra);
1118 tbptr = block + block_index[iptr->op1];
1120 iptr[0].target = (void *) tbptr;
1122 MARKREACHED(tbptr, copy);
1125 case ICMD_IF_ACMPEQ:
1126 case ICMD_IF_ACMPNE:
1127 COUNT(count_pcmd_bra);
1129 tbptr = block + block_index[iptr->op1];
1131 iptr[0].target = (void *) tbptr;
1133 MARKREACHED(tbptr, copy);
1139 COUNT(count_check_null);
1140 COUNT(count_pcmd_mem);
1141 OPTT2_0(iptr->op1,TYPE_ADR);
1145 if (! IS_2_WORD_TYPE(curstack->type)) {
1146 OP1_0ANY; /* second pop */
1149 iptr->opc = ICMD_POP;
1153 /* pop 0 push 1 dup */
1156 COUNT(count_dup_instruction);
1161 if (IS_2_WORD_TYPE(curstack->type)) {
1162 iptr->opc = ICMD_DUP;
1167 NEWSTACK(copy->prev->type, copy->prev->varkind,
1168 copy->prev->varnum);
1169 NEWSTACK(copy->type, copy->varkind,
1176 /* pop 2 push 3 dup */
1183 if (IS_2_WORD_TYPE(curstack->type)) {
1184 iptr->opc = ICMD_DUP_X1;
1192 /* pop 3 push 4 dup */
1195 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1196 iptr->opc = ICMD_DUP_X1;
1205 if (IS_2_WORD_TYPE(curstack->type)) {
1206 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1207 iptr->opc = ICMD_DUP_X1;
1211 iptr->opc = ICMD_DUP_X2;
1216 if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1217 iptr->opc = ICMD_DUP2_X1;
1225 /* pop 2 push 2 swap */
1234 #if !SUPPORT_DIVISION
1235 iptr[0].opc = ICMD_BUILTIN2;
1236 iptr[0].op1 = TYPE_INT;
1237 iptr[0].val.a = (functionptr) asm_builtin_idiv;
1238 isleafmethod = false;
1243 #if !SUPPORT_DIVISION
1244 iptr[0].opc = ICMD_BUILTIN2;
1245 iptr[0].op1 = TYPE_INT;
1246 iptr[0].val.a = (functionptr) asm_builtin_irem;
1247 isleafmethod = false;
1261 COUNT(count_pcmd_op);
1266 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1267 iptr[0].opc = ICMD_BUILTIN2;
1268 iptr[0].op1 = TYPE_LNG;
1269 iptr[0].val.a = (functionptr) asm_builtin_ldiv;
1270 isleafmethod = false;
1275 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1276 iptr[0].opc = ICMD_BUILTIN2;
1277 iptr[0].op1 = TYPE_LNG;
1278 iptr[0].val.a = (functionptr) asm_builtin_lrem;
1279 isleafmethod = false;
1290 COUNT(count_pcmd_op);
1297 COUNT(count_pcmd_op);
1306 COUNT(count_pcmd_op);
1315 COUNT(count_pcmd_op);
1320 COUNT(count_pcmd_op);
1321 #if !defined(NOLONG_CONDITIONAL)
1322 if ((len > 0) && (iptr[1].val.i == 0)) {
1323 switch (iptr[1].opc) {
1325 iptr[0].opc = ICMD_IF_LCMPEQ;
1327 iptr[0].op1 = iptr[1].op1;
1330 /* iptr[1].opc = ICMD_NOP; */
1332 tbptr = block + block_index[iptr->op1];
1334 iptr[0].target = (void *) tbptr;
1336 MARKREACHED(tbptr, copy);
1337 COUNT(count_pcmd_bra);
1340 iptr[0].opc = ICMD_IF_LCMPNE;
1341 goto icmd_lcmp_if_tail;
1343 iptr[0].opc = ICMD_IF_LCMPLT;
1344 goto icmd_lcmp_if_tail;
1346 iptr[0].opc = ICMD_IF_LCMPGT;
1347 goto icmd_lcmp_if_tail;
1349 iptr[0].opc = ICMD_IF_LCMPLE;
1350 goto icmd_lcmp_if_tail;
1352 iptr[0].opc = ICMD_IF_LCMPGE;
1353 goto icmd_lcmp_if_tail;
1355 OPTT2_1(TYPE_LNG, TYPE_INT);
1360 OPTT2_1(TYPE_LNG, TYPE_INT);
1364 COUNT(count_pcmd_op);
1365 OPTT2_1(TYPE_FLT, TYPE_INT);
1369 COUNT(count_pcmd_op);
1370 OPTT2_1(TYPE_DBL, TYPE_INT);
1378 case ICMD_INT2SHORT:
1379 COUNT(count_pcmd_op);
1380 OP1_1(TYPE_INT, TYPE_INT);
1383 COUNT(count_pcmd_op);
1384 OP1_1(TYPE_LNG, TYPE_LNG);
1387 COUNT(count_pcmd_op);
1388 OP1_1(TYPE_FLT, TYPE_FLT);
1391 COUNT(count_pcmd_op);
1392 OP1_1(TYPE_DBL, TYPE_DBL);
1396 COUNT(count_pcmd_op);
1397 OP1_1(TYPE_INT, TYPE_LNG);
1400 COUNT(count_pcmd_op);
1401 OP1_1(TYPE_INT, TYPE_FLT);
1404 COUNT(count_pcmd_op);
1405 OP1_1(TYPE_INT, TYPE_DBL);
1408 COUNT(count_pcmd_op);
1409 OP1_1(TYPE_LNG, TYPE_INT);
1412 COUNT(count_pcmd_op);
1413 OP1_1(TYPE_LNG, TYPE_FLT);
1416 COUNT(count_pcmd_op);
1417 OP1_1(TYPE_LNG, TYPE_DBL);
1420 COUNT(count_pcmd_op);
1421 OP1_1(TYPE_FLT, TYPE_INT);
1424 COUNT(count_pcmd_op);
1425 OP1_1(TYPE_FLT, TYPE_LNG);
1428 COUNT(count_pcmd_op);
1429 OP1_1(TYPE_FLT, TYPE_DBL);
1432 COUNT(count_pcmd_op);
1433 OP1_1(TYPE_DBL, TYPE_INT);
1436 COUNT(count_pcmd_op);
1437 OP1_1(TYPE_DBL, TYPE_LNG);
1440 COUNT(count_pcmd_op);
1441 OP1_1(TYPE_DBL, TYPE_FLT);
1444 case ICMD_CHECKCAST:
1445 OP1_1(TYPE_ADR, TYPE_ADR);
1448 case ICMD_ARRAYLENGTH:
1449 case ICMD_INSTANCEOF:
1450 OP1_1(TYPE_ADR, TYPE_INT);
1454 case ICMD_ANEWARRAY:
1455 OP1_1(TYPE_INT, TYPE_ADR);
1459 COUNT(count_check_null);
1460 COUNT(count_pcmd_mem);
1461 OP1_1(TYPE_ADR, iptr->op1);
1466 case ICMD_GETSTATIC:
1467 COUNT(count_pcmd_mem);
1477 tbptr = block + block_index[iptr->op1];
1479 iptr[0].target = (void *) tbptr;
1481 tbptr->type=BBTYPE_SBR;
1482 MARKREACHED(tbptr, copy);
1486 /* pop many push any */
1488 case ICMD_INVOKEVIRTUAL:
1489 case ICMD_INVOKESPECIAL:
1490 case ICMD_INVOKEINTERFACE:
1491 case ICMD_INVOKESTATIC:
1492 COUNT(count_pcmd_met);
1494 methodinfo *m = iptr->val.a;
1495 if (m->flags & ACC_STATIC)
1496 {COUNT(count_check_null);}
1498 if (i > arguments_num)
1500 #if defined(__X86_64__)
1508 (IS_FLT_DBL_TYPE(copy->type)) ? farg++ : iarg++;
1512 stackargs += (iarg < intreg_argnum) ? 0 : (iarg - intreg_argnum);
1513 stackargs += (farg < fltreg_argnum) ? 0 : (farg - fltreg_argnum);
1518 if (!(copy->flags & SAVEDVAR)) {
1519 copy->varkind = ARGVAR;
1520 if (IS_FLT_DBL_TYPE(copy->type)) {
1521 if (--farg < fltreg_argnum) {
1522 copy->varnum = farg;
1524 copy->varnum = --stackargs + intreg_argnum;
1527 if (--iarg < intreg_argnum) {
1528 copy->varnum = iarg;
1530 copy->varnum = --stackargs + intreg_argnum;
1534 (IS_FLT_DBL_TYPE(copy->type)) ? --farg : --iarg;
1542 if (! (copy->flags & SAVEDVAR)) {
1543 copy->varkind = ARGVAR;
1550 copy->flags |= SAVEDVAR;
1555 if (m->returntype != TYPE_VOID) {
1556 OP0_1(m->returntype);
1562 if (! (curstack->flags & SAVEDVAR)) {
1563 curstack->varkind = ARGVAR;
1564 curstack->varnum = 2;
1566 if (3 > arguments_num) {
1573 if (!(curstack->flags & SAVEDVAR)) {
1574 curstack->varkind = ARGVAR;
1575 curstack->varnum = 1;
1577 if (2 > arguments_num) {
1584 if (!(curstack->flags & SAVEDVAR)) {
1585 curstack->varkind = ARGVAR;
1586 curstack->varnum = 0;
1588 if (1 > arguments_num) {
1594 copy->flags |= SAVEDVAR;
1597 if (iptr->op1 != TYPE_VOID)
1601 case ICMD_MULTIANEWARRAY:
1603 if ((i + intreg_argnum) > arguments_num)
1604 arguments_num = i + intreg_argnum;
1607 if (! (copy->flags & SAVEDVAR)) {
1608 copy->varkind = ARGVAR;
1609 copy->varnum = i + intreg_argnum;
1614 copy->flags |= SAVEDVAR;
1622 case ICMD_CLEAR_ARGREN:
1623 for (i = iptr->op1; i<maxlocals; i++)
1625 iptr->opc = opcode = ICMD_NOP;
1629 case ICMD_READONLY_ARG:
1630 case ICMD_READONLY_ARG+1:
1631 case ICMD_READONLY_ARG+2:
1632 case ICMD_READONLY_ARG+3:
1633 case ICMD_READONLY_ARG+4:
1635 if (curstack->varkind == LOCALVAR) {
1636 i = curstack->varnum;
1637 argren[iptr->op1] = i;
1640 opcode = iptr->opc = opcode - ICMD_READONLY_ARG + ICMD_ISTORE;
1646 printf("ICMD %d at %d\n", iptr->opc, (int)(iptr-instr));
1647 panic("Missing ICMD code during stack analysis");
1650 } /* while instructions */
1651 bptr->outstack = curstack;
1652 bptr->outdepth = stackdepth;
1656 superblockend = true;
1658 } /* while blocks */
1659 } while (repeat && !deadcode);
1662 if (block_count > count_max_basic_blocks)
1663 count_max_basic_blocks = block_count;
1664 count_basic_blocks += block_count;
1665 if (instr_count > count_max_javainstr)
1666 count_max_javainstr = instr_count;
1667 count_javainstr += instr_count;
1668 if (stack_count > count_upper_bound_new_stack)
1669 count_upper_bound_new_stack = stack_count;
1670 if ((new - stack) > count_max_new_stack)
1671 count_max_new_stack = (new - stack);
1673 b_count = block_count;
1675 while (--b_count >= 0) {
1676 if (bptr->flags > BBREACHED) {
1677 if (bptr->indepth >= 10)
1678 count_block_stack[10]++;
1680 count_block_stack[bptr->indepth]++;
1683 count_block_size_distribution[len]++;
1685 count_block_size_distribution[10]++;
1687 count_block_size_distribution[11]++;
1689 count_block_size_distribution[12]++;
1691 count_block_size_distribution[13]++;
1693 count_block_size_distribution[14]++;
1695 count_block_size_distribution[15]++;
1697 count_block_size_distribution[16]++;
1699 count_block_size_distribution[17]++;
1705 count_analyse_iterations[0]++;
1706 else if (loops == 2)
1707 count_analyse_iterations[1]++;
1708 else if (loops == 3)
1709 count_analyse_iterations[2]++;
1710 else if (loops == 4)
1711 count_analyse_iterations[3]++;
1713 count_analyse_iterations[4]++;
1715 if (block_count <= 5)
1716 count_method_bb_distribution[0]++;
1717 else if (block_count <= 10)
1718 count_method_bb_distribution[1]++;
1719 else if (block_count <= 15)
1720 count_method_bb_distribution[2]++;
1721 else if (block_count <= 20)
1722 count_method_bb_distribution[3]++;
1723 else if (block_count <= 30)
1724 count_method_bb_distribution[4]++;
1725 else if (block_count <= 40)
1726 count_method_bb_distribution[5]++;
1727 else if (block_count <= 50)
1728 count_method_bb_distribution[6]++;
1729 else if (block_count <= 75)
1730 count_method_bb_distribution[7]++;
1732 count_method_bb_distribution[8]++;
1737 static void print_stack(stackptr s)
1754 if (s->flags & SAVEDVAR)
1755 switch (s->varkind) {
1757 if (s->flags & INMEMORY)
1758 printf(" M%02d", s->regoff);
1759 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1760 printf(" F%02d", s->regoff);
1762 printf(" %3s", regs[s->regoff]);
1765 printf(" I%02d", s->varnum);
1768 printf(" L%02d", s->varnum);
1771 printf(" A%02d", s->varnum);
1774 printf(" !%02d", j);
1777 switch (s->varkind) {
1779 if (s->flags & INMEMORY)
1780 printf(" m%02d", s->regoff);
1781 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1782 printf(" f%02d", s->regoff);
1784 printf(" %3s", regs[s->regoff]);
1787 printf(" i%02d", s->varnum);
1790 printf(" l%02d", s->varnum);
1793 printf(" a%02d", s->varnum);
1796 printf(" ?%02d", j);
1804 static void print_reg(stackptr s) {
1806 if (s->flags & SAVEDVAR)
1807 switch (s->varkind) {
1809 if (s->flags & INMEMORY)
1810 printf(" tm%02d", s->regoff);
1812 printf(" tr%02d", s->regoff);
1815 printf(" s %02d", s->varnum);
1818 printf(" l %02d", s->varnum);
1821 printf(" a %02d", s->varnum);
1824 printf(" ! %02d", s->varnum);
1827 switch (s->varkind) {
1829 if (s->flags & INMEMORY)
1830 printf(" Tm%02d", s->regoff);
1832 printf(" Tr%02d", s->regoff);
1835 printf(" S %02d", s->varnum);
1838 printf(" L %02d", s->varnum);
1841 printf(" A %02d", s->varnum);
1844 printf(" ? %02d", s->varnum);
1854 static char *builtin_name(functionptr bptr)
1856 builtin_descriptor *bdesc = builtin_desc;
1857 while ((bdesc->bptr != NULL) && (bdesc->bptr != bptr))
1863 static char *jit_type[] = {
1872 void show_icmd_method()
1883 utf_fprint(stdout, class->name);
1885 utf_fprint(stdout, method->name);
1887 utf_fprint(stdout, method->descriptor);
1888 printf ("\n\nMax locals: %d\n", (int) maxlocals);
1889 printf ("Max stack: %d\n", (int) maxstack);
1891 printf ("Exceptions (Number: %d):\n", exceptiontablelength);
1892 for (ex = extable; ex != NULL; ex = ex->down) {
1893 printf(" L%03d ... ", ex->start->debug_nr );
1894 printf("L%03d = ", ex->end->debug_nr);
1895 printf("L%03d\n", ex->handler->debug_nr);
1898 printf ("Local Table:\n");
1899 for (i = 0; i < maxlocals; i++) {
1900 printf(" %3d: ", i);
1901 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1902 if (locals[i][j].type >= 0) {
1903 printf(" (%s) ", jit_type[j]);
1904 if (locals[i][j].flags & INMEMORY)
1905 printf("m%2d", locals[i][j].regoff);
1906 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1907 printf("f%02d", locals[i][j].regoff);
1909 printf("%3s", regs[locals[i][j].regoff]);
1915 printf ("Interface Table:\n");
1916 for (i = 0; i < maxstack; i++) {
1917 if ((interfaces[i][0].type >= 0) || (interfaces[i][1].type >= 0) ||
1918 (interfaces[i][2].type >= 0) || (interfaces[i][3].type >= 0) ||
1919 (interfaces[i][4].type >= 0)) {
1920 printf(" %3d: ", i);
1921 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1922 if (interfaces[i][j].type >= 0) {
1923 printf(" (%s) ", jit_type[j]);
1924 if (interfaces[i][j].flags & SAVEDVAR) {
1925 if (interfaces[i][j].flags & INMEMORY)
1926 printf("M%2d", interfaces[i][j].regoff);
1927 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1928 printf("F%02d", interfaces[i][j].regoff);
1930 printf("%3s", regs[interfaces[i][j].regoff]);
1933 if (interfaces[i][j].flags & INMEMORY)
1934 printf("m%2d", interfaces[i][j].regoff);
1935 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1936 printf("f%02d", interfaces[i][j].regoff);
1938 printf("%3s", regs[interfaces[i][j].regoff]);
1946 if (showdisassemble) {
1947 #if defined(__I386__) || defined(__X86_64__)
1951 u1ptr = method->mcode + dseglen;
1952 for (i = 0; i < block[0].mpc; i++, u1ptr++) {
1953 a = disassinstr(u1ptr, i);
1959 s4ptr = (s4 *) (method->mcode + dseglen);
1960 for (i = 0; i < block[0].mpc; i += 4, s4ptr++) {
1961 disassinstr(*s4ptr, i);
1968 for (bptr = block; bptr != NULL; bptr = bptr->next) {
1969 if (bptr->flags != BBDELETED) {
1970 deadcode = bptr->flags <= BBREACHED;
1973 for (j = maxstack; j > 0; j--)
1976 print_stack(bptr->instack);
1977 printf("] L%03d(%d - %d):\n", bptr->debug_nr, bptr->icount, bptr->pre_count);
1978 iptr = bptr->iinstr;
1980 for (i=0; i < bptr->icount; i++, iptr++) {
1983 for (j = maxstack; j > 0; j--)
1987 print_stack(iptr->dst);
1988 printf("] %4d %s", i, icmd_names[iptr->opc]);
1989 switch ((int) iptr->opc) {
1990 case ICMD_IADDCONST:
1991 case ICMD_ISUBCONST:
1992 case ICMD_IMULCONST:
1995 case ICMD_IREM0X10001:
1996 case ICMD_IANDCONST:
1998 case ICMD_IXORCONST:
1999 case ICMD_ISHLCONST:
2000 case ICMD_ISHRCONST:
2001 case ICMD_IUSHRCONST:
2002 case ICMD_LSHLCONST:
2003 case ICMD_LSHRCONST:
2004 case ICMD_LUSHRCONST:
2006 case ICMD_ELSE_ICONST:
2007 case ICMD_IFEQ_ICONST:
2008 case ICMD_IFNE_ICONST:
2009 case ICMD_IFLT_ICONST:
2010 case ICMD_IFGE_ICONST:
2011 case ICMD_IFGT_ICONST:
2012 case ICMD_IFLE_ICONST:
2013 printf(" %d", iptr->val.i);
2015 case ICMD_LADDCONST:
2016 case ICMD_LSUBCONST:
2017 case ICMD_LMULCONST:
2020 case ICMD_LANDCONST:
2022 case ICMD_LXORCONST:
2024 #if defined(__I386__)
2025 printf(" %lld", iptr->val.l);
2027 printf(" %ld", iptr->val.l);
2031 printf(" %f", iptr->val.f);
2034 printf(" %f", iptr->val.d);
2037 printf(" %p", iptr->val.a);
2041 printf(" %d,", ((fieldinfo *) iptr->val.a)->offset);
2042 case ICMD_PUTSTATIC:
2043 case ICMD_GETSTATIC:
2046 ((fieldinfo *) iptr->val.a)->name);
2049 printf(" %d + %d", iptr->op1, iptr->val.i);
2084 printf(" %d", iptr->op1);
2089 ((classinfo *) iptr->val.a)->name);
2092 switch (iptr->op1) {
2119 case ICMD_ANEWARRAY:
2123 ((classinfo *) iptr->val.a)->name);
2126 case ICMD_CHECKCAST:
2127 case ICMD_INSTANCEOF:
2129 classinfo *c = iptr->val.a;
2130 if (c->flags & ACC_INTERFACE)
2131 printf(" (INTERFACE) ");
2133 printf(" (CLASS,%3d) ", c->vftbl->diffval);
2134 utf_fprint(stdout, c->name);
2140 printf(" %s", builtin_name((functionptr) iptr->val.a));
2142 case ICMD_INVOKEVIRTUAL:
2143 case ICMD_INVOKESPECIAL:
2144 case ICMD_INVOKESTATIC:
2145 case ICMD_INVOKEINTERFACE:
2148 ((methodinfo *) iptr->val.a)->class->name);
2151 ((methodinfo *) iptr->val.a)->name);
2159 printf("(%d) L%03d", iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
2167 printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
2172 case ICMD_IFNONNULL:
2173 case ICMD_IF_ICMPEQ:
2174 case ICMD_IF_ICMPNE:
2175 case ICMD_IF_ICMPLT:
2176 case ICMD_IF_ICMPGE:
2177 case ICMD_IF_ICMPGT:
2178 case ICMD_IF_ICMPLE:
2179 case ICMD_IF_LCMPEQ:
2180 case ICMD_IF_LCMPNE:
2181 case ICMD_IF_LCMPLT:
2182 case ICMD_IF_LCMPGE:
2183 case ICMD_IF_LCMPGT:
2184 case ICMD_IF_LCMPLE:
2185 case ICMD_IF_ACMPEQ:
2186 case ICMD_IF_ACMPNE:
2187 printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
2189 case ICMD_TABLESWITCH:
2191 s4ptr = iptr->val.a;
2192 tptr = (void **) iptr->target;
2194 printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
2200 j = *s4ptr++; /* low */
2201 j = *s4ptr++ - j; /* high */
2203 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2208 case ICMD_LOOKUPSWITCH:
2209 s4ptr = iptr->val.a;
2210 tptr = (void **) iptr->target;
2212 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2213 s4ptr++; /* default */
2214 j = *s4ptr; /* count */
2218 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2226 if (showdisassemble && (!deadcode)) {
2227 #if defined(__I386__) || defined(__X86_64__)
2233 u1ptr = method->mcode + dseglen + i;
2235 if (bptr->next != NULL) {
2236 for (; i < bptr->next->mpc; i++, u1ptr++) {
2237 a = disassinstr(u1ptr, i);
2244 for (; u1ptr < (u1 *) (method->mcode + method->mcodelength); i++, u1ptr++) {
2245 a = disassinstr(u1ptr, i);
2254 s4ptr = (s4 *) (method->mcode + dseglen + i);
2256 if (bptr->next != NULL) {
2257 for (; i < bptr->next->mpc; i += 4, s4ptr++) {
2258 disassinstr(*s4ptr, i);
2263 for (; s4ptr < (s4 *) (method->mcode + method->mcodelength); i += 4, s4ptr++) {
2264 disassinstr(*s4ptr, i);
2276 * These are local overrides for various environment variables in Emacs.
2277 * Please do not remove this and leave it at the end of the file, where
2278 * Emacs will automagically detect them.
2279 * ---------------------------------------------------------------------
2282 * indent-tabs-mode: t