1 /* jit/stack.c *****************************************************************
3 Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
5 See file COPYRIGHT for information on usage and disclaimer of warranties
7 Parser for JavaVM to intermediate code translation
9 Authors: Andreas Krall EMAIL: cacao@complang.tuwien.ac.at
11 Last Change: 1997/11/18
13 *******************************************************************************/
16 #define COUNT(cnt) cnt++
21 #define STACKRESET {curstack=0;stackdepth=0;}
23 #define TYPEPANIC {show_icmd_method();panic("Stack type mismatch");}
24 #define CURKIND curstack->varkind
25 #define CURTYPE curstack->type
27 #define NEWSTACK(s,v,n) {new->prev=curstack;new->type=s;new->flags=0;\
28 new->varkind=v;new->varnum=n;curstack=new;new++;}
29 #define NEWSTACKn(s,n) NEWSTACK(s,UNDEFVAR,n)
30 #define NEWSTACK0(s) NEWSTACK(s,UNDEFVAR,0)
31 #define NEWXSTACK {NEWSTACK(TYPE_ADR,STACKVAR,0);curstack=0;}
33 #define SETDST {iptr->dst=curstack;}
34 #define POP(s) {if(s!=curstack->type){TYPEPANIC;}\
35 if(curstack->varkind==UNDEFVAR)curstack->varkind=TEMPVAR;\
36 curstack=curstack->prev;}
37 #define POPANY {if(curstack->varkind==UNDEFVAR)curstack->varkind=TEMPVAR;\
38 curstack=curstack->prev;}
39 #define COPY(s,d) {(d)->flags=0;(d)->type=(s)->type;\
40 (d)->varkind=(s)->varkind;(d)->varnum=(s)->varnum;}
42 #define PUSHCONST(s){NEWSTACKn(s,stackdepth);SETDST;stackdepth++;}
43 #define LOAD(s,v,n) {NEWSTACK(s,v,n);SETDST;stackdepth++;}
44 #define STORE(s) {POP(s);SETDST;stackdepth--;}
45 #define OP1_0(s) {POP(s);SETDST;stackdepth--;}
46 #define OP1_0ANY {POPANY;SETDST;stackdepth--;}
47 #define OP0_1(s) {NEWSTACKn(s,stackdepth);SETDST;stackdepth++;}
48 #define OP1_1(s,d) {POP(s);NEWSTACKn(d,stackdepth-1);SETDST;}
49 #define OP2_0(s) {POP(s);POP(s);SETDST;stackdepth-=2;}
50 #define OPTT2_0(t,b){POP(t);POP(b);SETDST;stackdepth-=2;}
51 #define OP2_1(s) {POP(s);POP(s);NEWSTACKn(s,stackdepth-2);SETDST;stackdepth--;}
52 #define OP2IAT_1(s) {POP(TYPE_INT);POP(TYPE_ADR);NEWSTACKn(s,stackdepth-2);\
54 #define OP2IT_1(s) {POP(TYPE_INT);POP(s);NEWSTACKn(s,stackdepth-2);\
56 #define OPTT2_1(s,d){POP(s);POP(s);NEWSTACKn(d,stackdepth-2);SETDST;stackdepth--;}
57 #define OP2_2(s) {POP(s);POP(s);NEWSTACKn(s,stackdepth-2);\
58 NEWSTACKn(s,stackdepth-1);SETDST;}
59 #define OP3TIA_0(s) {POP(s);POP(TYPE_INT);POP(TYPE_ADR);SETDST;stackdepth-=3;}
60 #define OP3_0(s) {POP(s);POP(s);POP(s);SETDST;stackdepth-=3;}
61 #define POPMANY(i) {stackdepth-=i;while(--i>=0){POPANY;}SETDST;}
62 #define DUP {NEWSTACK(CURTYPE,CURKIND,curstack->varnum);SETDST;\
64 #define SWAP {COPY(curstack,new);POPANY;COPY(curstack,new+1);POPANY;\
65 new[0].prev=curstack;new[1].prev=new;\
66 curstack=new+1;new+=2;SETDST;}
67 #define DUP_X1 {COPY(curstack,new);COPY(curstack,new+2);POPANY;\
68 COPY(curstack,new+1);POPANY;new[0].prev=curstack;\
69 new[1].prev=new;new[2].prev=new+1;\
70 curstack=new+2;new+=3;SETDST;stackdepth++;}
71 #define DUP2_X1 {COPY(curstack,new+1);COPY(curstack,new+4);POPANY;\
72 COPY(curstack,new);COPY(curstack,new+3);POPANY;\
73 COPY(curstack,new+2);POPANY;new[0].prev=curstack;\
74 new[1].prev=new;new[2].prev=new+1;\
75 new[3].prev=new+2;new[4].prev=new+3;\
76 curstack=new+4;new+=5;SETDST;stackdepth+=2;}
77 #define DUP_X2 {COPY(curstack,new);COPY(curstack,new+3);POPANY;\
78 COPY(curstack,new+2);POPANY;COPY(curstack,new+1);POPANY;\
79 new[0].prev=curstack;new[1].prev=new;\
80 new[2].prev=new+1;new[3].prev=new+2;\
81 curstack=new+3;new+=4;SETDST;stackdepth++;}
82 #define DUP2_X2 {COPY(curstack,new+1);COPY(curstack,new+5);POPANY;\
83 COPY(curstack,new);COPY(curstack,new+4);POPANY;\
84 COPY(curstack,new+3);POPANY;COPY(curstack,new+2);POPANY;\
85 new[0].prev=curstack;new[1].prev=new;\
86 new[2].prev=new+1;new[3].prev=new+2;\
87 new[4].prev=new+3;new[5].prev=new+4;\
88 curstack=new+5;new+=6;SETDST;stackdepth+=2;}
90 #define COPYCURSTACK(copy) {\
103 copy->varkind=STACKVAR;\
119 if((copy->varkind==STACKVAR)&&(copy->varnum>i))\
120 copy->varkind=TEMPVAR;\
122 copy->varkind=STACKVAR;\
125 interfaces[i][copy->type].type = copy->type;\
126 interfaces[i][copy->type].flags |= copy->flags;\
127 i--;copy=copy->prev;\
132 interfaces[i][copy->type].type = copy->type;\
133 if(copy->varkind==STACKVAR){\
134 if (copy->flags & SAVEDVAR)\
135 interfaces[i][copy->type].flags |= SAVEDVAR;\
137 i--;copy=copy->prev;\
142 #define MARKREACHED(b,c) {\
144 {COPYCURSTACK(c);b->flags=0;b->instack=c;b->indepth=stackdepth;}\
145 else {stackptr s=curstack;stackptr t=b->instack;\
146 if(b->indepth!=stackdepth)\
147 {show_icmd_method();panic("Stack depth mismatch");}\
148 while(s){if (s->type!=t->type)\
150 s=s->prev;t=t->prev;\
155 #ifdef USEBUILTINTABLE
156 static stdopdescriptor *find_builtin(stdopdescriptor *first, stdopdescriptor *last,
159 int len = last - first;
161 stdopdescriptor *middle;
165 middle = first + half;
166 if (middle->opcode < icmd) {
176 static void show_icmd_method();
178 static void analyse_stack()
180 int b_count, b_index;
182 stackptr curstack, new, copy;
183 int opcode, i, len, loops;
184 int superblockend, repeat, deadcode;
185 instruction *iptr = instr;
186 basicblock *bptr, *tbptr;
190 // int *argren = DMNEW(int, maxlocals);
191 int *argren = (int *)alloca(maxlocals * sizeof(int)); /* table for argument renaming */
192 for (i = 0; i < maxlocals; i++)
198 block[0].flags = BBREACHED;
199 block[0].instack = 0;
200 block[0].indepth = 0;
202 for (i = 0; i < exceptiontablelength; i++) {
203 bptr = &block[block_index[extable[i].handlerpc]];
204 bptr->flags = BBREACHED;
205 bptr->type = BBTYPE_EXH;
208 bptr->pre_count = 10000;
213 #ifdef CONDITIONAL_LOADCONST
214 b_count = block_count;
216 while (--b_count >= 0) {
217 if (bptr->icount != 0) {
218 iptr = bptr->iinstr + bptr->icount - 1;
251 block[block_index[iptr->op1]].pre_count++;
254 case ICMD_TABLESWITCH:
256 block[block_index[*s4ptr++]].pre_count++; /* default */
257 i = *s4ptr++; /* low */
258 i = *s4ptr++ - i + 1; /* high */
260 block[block_index[*s4ptr++]].pre_count++;
264 case ICMD_LOOKUPSWITCH:
266 block[block_index[*s4ptr++]].pre_count++; /* default */
267 i = *s4ptr++; /* count */
269 block[block_index[s4ptr[1]]].pre_count++;
285 b_count = block_count;
287 superblockend = true;
291 while (--b_count >= 0) {
292 if (bptr->flags == BBDELETED) {
295 else if (superblockend && (bptr->flags < BBREACHED))
297 else if (bptr->flags <= BBREACHED) {
299 stackdepth = bptr->indepth;
300 else if (bptr->flags < BBREACHED) {
302 bptr->instack = copy;
303 bptr->indepth = stackdepth;
305 else if (bptr->indepth != stackdepth) {
307 panic("Stack depth mismatch");
310 curstack = bptr->instack;
312 superblockend = false;
313 bptr->flags = BBFINISHED;
316 b_index = bptr - block;
321 #ifdef USEBUILTINTABLE
323 stdopdescriptor *blast = builtintable + sizeof(builtintable)/sizeof(stdopdescriptor);
324 stdopdescriptor *breplace;
325 breplace = find_builtin(builtintable, blast, opcode);
326 if (breplace != blast && opcode == breplace->opcode && !breplace->supported) {
327 iptr[0].opc = breplace->icmd;
328 iptr[0].op1 = breplace->type_d;
329 iptr[0].val.a = breplace->builtin;
330 isleafmethod = false;
331 switch (breplace->icmd) {
346 case ICMD_CHECKASIZE:
348 case ICMD_IFEQ_ICONST:
349 case ICMD_IFNE_ICONST:
350 case ICMD_IFLT_ICONST:
351 case ICMD_IFGE_ICONST:
352 case ICMD_IFGT_ICONST:
353 case ICMD_IFLE_ICONST:
354 case ICMD_ELSE_ICONST:
359 locals[iptr->op1][TYPE_ADR].type = TYPE_ADR;
361 COUNT(count_pcmd_return);
363 superblockend = true;
366 /* pop 0 push 1 const */
369 COUNT(count_pcmd_load);
371 switch (iptr[1].opc) {
373 iptr[0].opc = ICMD_IADDCONST;
375 iptr[1].opc = ICMD_NOP;
376 OP1_1(TYPE_INT,TYPE_INT);
377 COUNT(count_pcmd_op);
380 iptr[0].opc = ICMD_ISUBCONST;
381 goto icmd_iconst_tail;
383 iptr[0].opc = ICMD_IMULCONST;
384 goto icmd_iconst_tail;
386 if (iptr[0].val.i == 0x00000002)
388 else if (iptr[0].val.i == 0x00000004)
390 else if (iptr[0].val.i == 0x00000008)
392 else if (iptr[0].val.i == 0x00000010)
394 else if (iptr[0].val.i == 0x00000020)
396 else if (iptr[0].val.i == 0x00000040)
398 else if (iptr[0].val.i == 0x00000080)
400 else if (iptr[0].val.i == 0x00000100)
402 else if (iptr[0].val.i == 0x00000200)
404 else if (iptr[0].val.i == 0x00000400)
406 else if (iptr[0].val.i == 0x00000800)
408 else if (iptr[0].val.i == 0x00001000)
410 else if (iptr[0].val.i == 0x00002000)
412 else if (iptr[0].val.i == 0x00004000)
414 else if (iptr[0].val.i == 0x00008000)
416 else if (iptr[0].val.i == 0x00010000)
418 else if (iptr[0].val.i == 0x00020000)
420 else if (iptr[0].val.i == 0x00040000)
422 else if (iptr[0].val.i == 0x00080000)
424 else if (iptr[0].val.i == 0x00100000)
426 else if (iptr[0].val.i == 0x00200000)
428 else if (iptr[0].val.i == 0x00400000)
430 else if (iptr[0].val.i == 0x00800000)
432 else if (iptr[0].val.i == 0x01000000)
434 else if (iptr[0].val.i == 0x02000000)
436 else if (iptr[0].val.i == 0x04000000)
438 else if (iptr[0].val.i == 0x08000000)
440 else if (iptr[0].val.i == 0x10000000)
442 else if (iptr[0].val.i == 0x20000000)
444 else if (iptr[0].val.i == 0x40000000)
446 else if (iptr[0].val.i == 0x80000000)
452 iptr[0].opc = ICMD_IDIVPOW2;
453 goto icmd_iconst_tail;
455 #if !defined(NO_DIV_OPT)
456 if (iptr[0].val.i == 0x10001) {
457 iptr[0].opc = ICMD_IREM0X10001;
458 goto icmd_iconst_tail;
461 if ((iptr[0].val.i == 0x00000002) ||
462 (iptr[0].val.i == 0x00000004) ||
463 (iptr[0].val.i == 0x00000008) ||
464 (iptr[0].val.i == 0x00000010) ||
465 (iptr[0].val.i == 0x00000020) ||
466 (iptr[0].val.i == 0x00000040) ||
467 (iptr[0].val.i == 0x00000080) ||
468 (iptr[0].val.i == 0x00000100) ||
469 (iptr[0].val.i == 0x00000200) ||
470 (iptr[0].val.i == 0x00000400) ||
471 (iptr[0].val.i == 0x00000800) ||
472 (iptr[0].val.i == 0x00001000) ||
473 (iptr[0].val.i == 0x00002000) ||
474 (iptr[0].val.i == 0x00004000) ||
475 (iptr[0].val.i == 0x00008000) ||
476 (iptr[0].val.i == 0x00010000) ||
477 (iptr[0].val.i == 0x00020000) ||
478 (iptr[0].val.i == 0x00040000) ||
479 (iptr[0].val.i == 0x00080000) ||
480 (iptr[0].val.i == 0x00100000) ||
481 (iptr[0].val.i == 0x00200000) ||
482 (iptr[0].val.i == 0x00400000) ||
483 (iptr[0].val.i == 0x00800000) ||
484 (iptr[0].val.i == 0x01000000) ||
485 (iptr[0].val.i == 0x02000000) ||
486 (iptr[0].val.i == 0x04000000) ||
487 (iptr[0].val.i == 0x08000000) ||
488 (iptr[0].val.i == 0x10000000) ||
489 (iptr[0].val.i == 0x20000000) ||
490 (iptr[0].val.i == 0x40000000) ||
491 (iptr[0].val.i == 0x80000000)) {
492 iptr[0].opc = ICMD_IREMPOW2;
494 goto icmd_iconst_tail;
499 iptr[0].opc = ICMD_IANDCONST;
500 goto icmd_iconst_tail;
502 iptr[0].opc = ICMD_IORCONST;
503 goto icmd_iconst_tail;
505 iptr[0].opc = ICMD_IXORCONST;
506 goto icmd_iconst_tail;
508 iptr[0].opc = ICMD_ISHLCONST;
509 goto icmd_iconst_tail;
511 iptr[0].opc = ICMD_ISHRCONST;
512 goto icmd_iconst_tail;
514 iptr[0].opc = ICMD_IUSHRCONST;
515 goto icmd_iconst_tail;
516 #if SUPPORT_LONG_SHIFT
518 iptr[0].opc = ICMD_LSHLCONST;
519 goto icmd_lconst_tail;
521 iptr[0].opc = ICMD_LSHRCONST;
522 goto icmd_lconst_tail;
524 iptr[0].opc = ICMD_LUSHRCONST;
525 goto icmd_lconst_tail;
528 iptr[0].opc = ICMD_IFEQ;
530 iptr[0].op1 = iptr[1].op1;
533 /* iptr[1].opc = ICMD_NOP; */
535 tbptr = block + block_index[iptr->op1];
537 iptr[0].target = (void *) tbptr;
539 MARKREACHED(tbptr, copy);
540 COUNT(count_pcmd_bra);
543 iptr[0].opc = ICMD_IFLT;
544 goto icmd_if_icmp_tail;
546 iptr[0].opc = ICMD_IFLE;
547 goto icmd_if_icmp_tail;
549 iptr[0].opc = ICMD_IFNE;
550 goto icmd_if_icmp_tail;
552 iptr[0].opc = ICMD_IFGT;
553 goto icmd_if_icmp_tail;
555 iptr[0].opc = ICMD_IFGE;
556 goto icmd_if_icmp_tail;
565 COUNT(count_pcmd_load);
567 switch (iptr[1].opc) {
570 iptr[0].opc = ICMD_LADDCONST;
572 iptr[1].opc = ICMD_NOP;
573 OP1_1(TYPE_LNG,TYPE_LNG);
574 COUNT(count_pcmd_op);
577 iptr[0].opc = ICMD_LSUBCONST;
578 goto icmd_lconst_tail;
580 #if SUPPORT_LONG_MULDIV
582 iptr[0].opc = ICMD_LMULCONST;
583 goto icmd_lconst_tail;
585 if (iptr[0].val.l == 0x00000002)
587 else if (iptr[0].val.l == 0x00000004)
589 else if (iptr[0].val.l == 0x00000008)
591 else if (iptr[0].val.l == 0x00000010)
593 else if (iptr[0].val.l == 0x00000020)
595 else if (iptr[0].val.l == 0x00000040)
597 else if (iptr[0].val.l == 0x00000080)
599 else if (iptr[0].val.l == 0x00000100)
601 else if (iptr[0].val.l == 0x00000200)
603 else if (iptr[0].val.l == 0x00000400)
605 else if (iptr[0].val.l == 0x00000800)
607 else if (iptr[0].val.l == 0x00001000)
609 else if (iptr[0].val.l == 0x00002000)
611 else if (iptr[0].val.l == 0x00004000)
613 else if (iptr[0].val.l == 0x00008000)
615 else if (iptr[0].val.l == 0x00010000)
617 else if (iptr[0].val.l == 0x00020000)
619 else if (iptr[0].val.l == 0x00040000)
621 else if (iptr[0].val.l == 0x00080000)
623 else if (iptr[0].val.l == 0x00100000)
625 else if (iptr[0].val.l == 0x00200000)
627 else if (iptr[0].val.l == 0x00400000)
629 else if (iptr[0].val.l == 0x00800000)
631 else if (iptr[0].val.l == 0x01000000)
633 else if (iptr[0].val.l == 0x02000000)
635 else if (iptr[0].val.l == 0x04000000)
637 else if (iptr[0].val.l == 0x08000000)
639 else if (iptr[0].val.l == 0x10000000)
641 else if (iptr[0].val.l == 0x20000000)
643 else if (iptr[0].val.l == 0x40000000)
645 else if (iptr[0].val.l == 0x80000000)
651 iptr[0].opc = ICMD_LDIVPOW2;
652 goto icmd_lconst_tail;
654 #if !defined(NO_DIV_OPT)
655 if (iptr[0].val.l == 0x10001) {
656 iptr[0].opc = ICMD_LREM0X10001;
657 goto icmd_lconst_tail;
660 if ((iptr[0].val.l == 0x00000002) ||
661 (iptr[0].val.l == 0x00000004) ||
662 (iptr[0].val.l == 0x00000008) ||
663 (iptr[0].val.l == 0x00000010) ||
664 (iptr[0].val.l == 0x00000020) ||
665 (iptr[0].val.l == 0x00000040) ||
666 (iptr[0].val.l == 0x00000080) ||
667 (iptr[0].val.l == 0x00000100) ||
668 (iptr[0].val.l == 0x00000200) ||
669 (iptr[0].val.l == 0x00000400) ||
670 (iptr[0].val.l == 0x00000800) ||
671 (iptr[0].val.l == 0x00001000) ||
672 (iptr[0].val.l == 0x00002000) ||
673 (iptr[0].val.l == 0x00004000) ||
674 (iptr[0].val.l == 0x00008000) ||
675 (iptr[0].val.l == 0x00010000) ||
676 (iptr[0].val.l == 0x00020000) ||
677 (iptr[0].val.l == 0x00040000) ||
678 (iptr[0].val.l == 0x00080000) ||
679 (iptr[0].val.l == 0x00100000) ||
680 (iptr[0].val.l == 0x00200000) ||
681 (iptr[0].val.l == 0x00400000) ||
682 (iptr[0].val.l == 0x00800000) ||
683 (iptr[0].val.l == 0x01000000) ||
684 (iptr[0].val.l == 0x02000000) ||
685 (iptr[0].val.l == 0x04000000) ||
686 (iptr[0].val.l == 0x08000000) ||
687 (iptr[0].val.l == 0x10000000) ||
688 (iptr[0].val.l == 0x20000000) ||
689 (iptr[0].val.l == 0x40000000) ||
690 (iptr[0].val.l == 0x80000000)) {
691 iptr[0].opc = ICMD_LREMPOW2;
693 goto icmd_lconst_tail;
700 iptr[0].opc = ICMD_LANDCONST;
701 goto icmd_lconst_tail;
703 iptr[0].opc = ICMD_LORCONST;
704 goto icmd_lconst_tail;
706 iptr[0].opc = ICMD_LXORCONST;
707 goto icmd_lconst_tail;
709 #if defined(NOLONG_CONDITIONAL)
711 if ((len > 1) && (iptr[2].val.i == 0)) {
712 switch (iptr[2].opc) {
714 iptr[0].opc = ICMD_IF_LEQ;
715 icmd_lconst_lcmp_tail:
716 iptr[0].op1 = iptr[2].op1;
719 /* iptr[1].opc = ICMD_NOP;
720 iptr[2].opc = ICMD_NOP; */
722 tbptr = block + block_index[iptr->op1];
724 iptr[0].target = (void *) tbptr;
726 MARKREACHED(tbptr, copy);
727 COUNT(count_pcmd_bra);
728 COUNT(count_pcmd_op);
731 iptr[0].opc = ICMD_IF_LNE;
732 goto icmd_lconst_lcmp_tail;
734 iptr[0].opc = ICMD_IF_LLT;
735 goto icmd_lconst_lcmp_tail;
737 iptr[0].opc = ICMD_IF_LGT;
738 goto icmd_lconst_lcmp_tail;
740 iptr[0].opc = ICMD_IF_LLE;
741 goto icmd_lconst_lcmp_tail;
743 iptr[0].opc = ICMD_IF_LGE;
744 goto icmd_lconst_lcmp_tail;
747 } /* switch (iptr[2].opc) */
748 } /* if (iptr[2].val.i == 0) */
761 COUNT(count_pcmd_load);
765 COUNT(count_pcmd_load);
769 COUNT(count_pcmd_load);
773 /* pop 0 push 1 load */
780 COUNT(count_load_instruction);
781 i = opcode-ICMD_ILOAD;
782 iptr->op1 = argren[iptr->op1];
783 locals[ iptr->op1 ][i].type = i;
784 LOAD(i, LOCALVAR, iptr->op1);
794 COUNT(count_check_null);
795 COUNT(count_check_bound);
796 COUNT(count_pcmd_mem);
797 OP2IAT_1(opcode-ICMD_IALOAD);
803 COUNT(count_check_null);
804 COUNT(count_check_bound);
805 COUNT(count_pcmd_mem);
809 /* pop 0 push 0 iinc */
815 count_store_depth[10]++;
817 count_store_depth[i]++;
822 if ((copy->varkind == LOCALVAR) &&
823 (copy->varnum == iptr->op1)) {
824 copy->varkind = TEMPVAR;
833 /* pop 1 push 0 store */
842 i = opcode-ICMD_ISTORE;
843 locals[iptr->op1][i].type = i;
848 count_store_length[20]++;
850 count_store_length[i]++;
853 count_store_depth[10]++;
855 count_store_depth[i]++;
857 copy = curstack->prev;
860 if ((copy->varkind == LOCALVAR) &&
861 (copy->varnum == iptr->op1)) {
862 copy->varkind = TEMPVAR;
868 if ((new - curstack) == 1) {
869 curstack->varkind = LOCALVAR;
870 curstack->varnum = iptr->op1;
872 STORE(opcode-ICMD_ISTORE);
882 COUNT(count_check_null);
883 COUNT(count_check_bound);
884 COUNT(count_pcmd_mem);
885 OP3TIA_0(opcode-ICMD_IASTORE);
890 COUNT(count_check_null);
891 COUNT(count_check_bound);
892 COUNT(count_pcmd_mem);
907 COUNT(count_pcmd_return);
908 OP1_0(opcode-ICMD_IRETURN);
909 superblockend = true;
913 COUNT(count_check_null);
917 superblockend = true;
921 COUNT(count_pcmd_mem);
925 /* pop 1 push 0 branch */
929 COUNT(count_pcmd_bra);
931 tbptr = block + block_index[iptr->op1];
933 iptr[0].target = (void *) tbptr;
935 MARKREACHED(tbptr, copy);
944 COUNT(count_pcmd_bra);
945 #ifdef CONDITIONAL_LOADCONST
947 tbptr = block + b_index;
948 if ((b_count >= 3) &&
949 ((b_index + 2) == block_index[iptr[0].op1]) &&
950 (tbptr[1].pre_count == 1) &&
951 (iptr[1].opc == ICMD_ICONST) &&
952 (iptr[2].opc == ICMD_GOTO) &&
953 ((b_index + 3) == block_index[iptr[2].op1]) &&
954 (tbptr[2].pre_count == 1) &&
955 (iptr[3].opc == ICMD_ICONST)) {
956 OP1_1(TYPE_INT, TYPE_INT);
957 switch (iptr[0].opc) {
959 iptr[0].opc = ICMD_IFNE_ICONST;
962 iptr[0].opc = ICMD_IFEQ_ICONST;
965 iptr[0].opc = ICMD_IFGE_ICONST;
968 iptr[0].opc = ICMD_IFLT_ICONST;
971 iptr[0].opc = ICMD_IFLE_ICONST;
974 iptr[0].opc = ICMD_IFGT_ICONST;
977 iptr[0].val.i = iptr[1].val.i;
978 iptr[1].opc = ICMD_ELSE_ICONST;
979 iptr[1].val.i = iptr[3].val.i;
980 iptr[2].opc = ICMD_NOP;
981 iptr[3].opc = ICMD_NOP;
982 tbptr[1].flags = BBDELETED;
983 tbptr[2].flags = BBDELETED;
986 if (tbptr[3].pre_count == 2) {
987 len += tbptr[3].icount + 3;
988 bptr->icount += tbptr[3].icount + 3;
989 tbptr[3].flags = BBDELETED;
1003 tbptr = block + block_index[iptr->op1];
1005 iptr[0].target = (void *) tbptr;
1007 MARKREACHED(tbptr, copy);
1010 /* pop 0 push 0 branch */
1013 COUNT(count_pcmd_bra);
1014 tbptr = block + block_index[iptr->op1];
1016 iptr[0].target = (void *) tbptr;
1018 MARKREACHED(tbptr, copy);
1020 superblockend = true;
1023 /* pop 1 push 0 table branch */
1025 case ICMD_TABLESWITCH:
1026 COUNT(count_pcmd_table);
1028 s4ptr = iptr->val.a;
1029 tbptr = block + block_index[*s4ptr++]; /* default */
1030 MARKREACHED(tbptr, copy);
1031 i = *s4ptr++; /* low */
1032 i = *s4ptr++ - i + 1; /* high */
1034 tptr = DMNEW(void*, i+1);
1035 iptr->target = (void *) tptr;
1037 tptr[0] = (void *) tbptr;
1041 tbptr = block + block_index[*s4ptr++];
1043 tptr[0] = (void *) tbptr;
1046 MARKREACHED(tbptr, copy);
1049 superblockend = true;
1052 /* pop 1 push 0 table branch */
1054 case ICMD_LOOKUPSWITCH:
1055 COUNT(count_pcmd_table);
1057 s4ptr = iptr->val.a;
1058 tbptr = block + block_index[*s4ptr++]; /* default */
1059 MARKREACHED(tbptr, copy);
1060 i = *s4ptr++; /* count */
1062 tptr = DMNEW(void*, i+1);
1063 iptr->target = (void *) tptr;
1065 tptr[0] = (void *) tbptr;
1069 tbptr = block + block_index[s4ptr[1]];
1071 tptr[0] = (void *) tbptr;
1074 MARKREACHED(tbptr, copy);
1078 superblockend = true;
1081 case ICMD_NULLCHECKPOP:
1082 case ICMD_MONITORENTER:
1083 COUNT(count_check_null);
1084 case ICMD_MONITOREXIT:
1088 /* pop 2 push 0 branch */
1090 case ICMD_IF_ICMPEQ:
1091 case ICMD_IF_ICMPNE:
1092 case ICMD_IF_ICMPLT:
1093 case ICMD_IF_ICMPGE:
1094 case ICMD_IF_ICMPGT:
1095 case ICMD_IF_ICMPLE:
1096 COUNT(count_pcmd_bra);
1098 tbptr = block + block_index[iptr->op1];
1100 iptr[0].target = (void *) tbptr;
1102 MARKREACHED(tbptr, copy);
1105 case ICMD_IF_ACMPEQ:
1106 case ICMD_IF_ACMPNE:
1107 COUNT(count_pcmd_bra);
1109 tbptr = block + block_index[iptr->op1];
1111 iptr[0].target = (void *) tbptr;
1113 MARKREACHED(tbptr, copy);
1119 COUNT(count_check_null);
1120 COUNT(count_pcmd_mem);
1121 OPTT2_0(iptr->op1,TYPE_ADR);
1125 if (! IS_2_WORD_TYPE(curstack->type)) {
1126 OP1_0ANY; /* second pop */
1129 iptr->opc = ICMD_POP;
1133 /* pop 0 push 1 dup */
1136 COUNT(count_dup_instruction);
1141 if (IS_2_WORD_TYPE(curstack->type)) {
1142 iptr->opc = ICMD_DUP;
1147 NEWSTACK(copy->prev->type, copy->prev->varkind,
1148 copy->prev->varnum);
1149 NEWSTACK(copy->type, copy->varkind,
1156 /* pop 2 push 3 dup */
1163 if (IS_2_WORD_TYPE(curstack->type)) {
1164 iptr->opc = ICMD_DUP_X1;
1172 /* pop 3 push 4 dup */
1175 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1176 iptr->opc = ICMD_DUP_X1;
1185 if (IS_2_WORD_TYPE(curstack->type)) {
1186 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1187 iptr->opc = ICMD_DUP_X1;
1191 iptr->opc = ICMD_DUP_X2;
1196 if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1197 iptr->opc = ICMD_DUP2_X1;
1205 /* pop 2 push 2 swap */
1214 #if !SUPPORT_DIVISION
1215 iptr[0].opc = ICMD_BUILTIN2;
1216 iptr[0].op1 = TYPE_INT;
1217 iptr[0].val.a = (functionptr) asm_builtin_idiv;
1218 isleafmethod = false;
1223 #if !SUPPORT_DIVISION
1224 iptr[0].opc = ICMD_BUILTIN2;
1225 iptr[0].op1 = TYPE_INT;
1226 iptr[0].val.a = (functionptr) asm_builtin_irem;
1227 isleafmethod = false;
1241 COUNT(count_pcmd_op);
1246 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_MULDIV)
1247 iptr[0].opc = ICMD_BUILTIN2;
1248 iptr[0].op1 = TYPE_LNG;
1249 iptr[0].val.a = (functionptr) asm_builtin_ldiv;
1250 isleafmethod = false;
1255 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_MULDIV)
1256 iptr[0].opc = ICMD_BUILTIN2;
1257 iptr[0].op1 = TYPE_LNG;
1258 iptr[0].val.a = (functionptr) asm_builtin_lrem;
1259 isleafmethod = false;
1270 COUNT(count_pcmd_op);
1277 COUNT(count_pcmd_op);
1286 COUNT(count_pcmd_op);
1295 COUNT(count_pcmd_op);
1300 COUNT(count_pcmd_op);
1301 #ifndef NOLONG_CONDITIONAL
1302 if ((len > 0) && (iptr[1].val.i == 0)) {
1303 switch (iptr[1].opc) {
1305 iptr[0].opc = ICMD_IF_LCMPEQ;
1307 iptr[0].op1 = iptr[1].op1;
1310 /* iptr[1].opc = ICMD_NOP; */
1312 tbptr = block + block_index[iptr->op1];
1314 iptr[0].target = (void *) tbptr;
1316 MARKREACHED(tbptr, copy);
1317 COUNT(count_pcmd_bra);
1320 iptr[0].opc = ICMD_IF_LCMPNE;
1321 goto icmd_lcmp_if_tail;
1323 iptr[0].opc = ICMD_IF_LCMPLT;
1324 goto icmd_lcmp_if_tail;
1326 iptr[0].opc = ICMD_IF_LCMPGT;
1327 goto icmd_lcmp_if_tail;
1329 iptr[0].opc = ICMD_IF_LCMPLE;
1330 goto icmd_lcmp_if_tail;
1332 iptr[0].opc = ICMD_IF_LCMPGE;
1333 goto icmd_lcmp_if_tail;
1335 OPTT2_1(TYPE_LNG, TYPE_INT);
1340 OPTT2_1(TYPE_LNG, TYPE_INT);
1344 COUNT(count_pcmd_op);
1345 OPTT2_1(TYPE_FLT, TYPE_INT);
1349 COUNT(count_pcmd_op);
1350 OPTT2_1(TYPE_DBL, TYPE_INT);
1358 case ICMD_INT2SHORT:
1359 COUNT(count_pcmd_op);
1360 OP1_1(TYPE_INT, TYPE_INT);
1363 COUNT(count_pcmd_op);
1364 OP1_1(TYPE_LNG, TYPE_LNG);
1367 COUNT(count_pcmd_op);
1368 OP1_1(TYPE_FLT, TYPE_FLT);
1371 COUNT(count_pcmd_op);
1372 OP1_1(TYPE_DBL, TYPE_DBL);
1376 COUNT(count_pcmd_op);
1377 OP1_1(TYPE_INT, TYPE_LNG);
1380 COUNT(count_pcmd_op);
1381 OP1_1(TYPE_INT, TYPE_FLT);
1384 COUNT(count_pcmd_op);
1385 OP1_1(TYPE_INT, TYPE_DBL);
1388 COUNT(count_pcmd_op);
1389 OP1_1(TYPE_LNG, TYPE_INT);
1392 COUNT(count_pcmd_op);
1393 OP1_1(TYPE_LNG, TYPE_FLT);
1396 COUNT(count_pcmd_op);
1397 OP1_1(TYPE_LNG, TYPE_DBL);
1400 COUNT(count_pcmd_op);
1401 OP1_1(TYPE_FLT, TYPE_INT);
1404 COUNT(count_pcmd_op);
1405 OP1_1(TYPE_FLT, TYPE_LNG);
1408 COUNT(count_pcmd_op);
1409 OP1_1(TYPE_FLT, TYPE_DBL);
1412 COUNT(count_pcmd_op);
1413 OP1_1(TYPE_DBL, TYPE_INT);
1416 COUNT(count_pcmd_op);
1417 OP1_1(TYPE_DBL, TYPE_LNG);
1420 COUNT(count_pcmd_op);
1421 OP1_1(TYPE_DBL, TYPE_FLT);
1424 case ICMD_CHECKCAST:
1425 OP1_1(TYPE_ADR, TYPE_ADR);
1428 case ICMD_ARRAYLENGTH:
1429 case ICMD_INSTANCEOF:
1430 OP1_1(TYPE_ADR, TYPE_INT);
1434 case ICMD_ANEWARRAY:
1435 OP1_1(TYPE_INT, TYPE_ADR);
1439 COUNT(count_check_null);
1440 COUNT(count_pcmd_mem);
1441 OP1_1(TYPE_ADR, iptr->op1);
1446 case ICMD_GETSTATIC:
1447 COUNT(count_pcmd_mem);
1457 tbptr = block + block_index[iptr->op1];
1459 iptr[0].target = (void *) tbptr;
1461 tbptr->type=BBTYPE_SBR;
1462 MARKREACHED(tbptr, copy);
1466 /* pop many push any */
1468 case ICMD_INVOKEVIRTUAL:
1469 case ICMD_INVOKESPECIAL:
1470 case ICMD_INVOKEINTERFACE:
1471 case ICMD_INVOKESTATIC:
1472 COUNT(count_pcmd_met);
1474 methodinfo *m = iptr->val.a;
1475 if (m->flags & ACC_STATIC)
1476 {COUNT(count_check_null);}
1478 if (i > arguments_num)
1480 #if defined(__X86_64__)
1488 (IS_FLT_DBL_TYPE(copy->type)) ? farg++ : iarg++;
1492 stackargs += (iarg < intreg_argnum) ? 0 : (iarg - intreg_argnum);
1493 stackargs += (farg < fltreg_argnum) ? 0 : (farg - fltreg_argnum);
1498 if (!(copy->flags & SAVEDVAR)) {
1499 copy->varkind = ARGVAR;
1500 if (IS_FLT_DBL_TYPE(copy->type)) {
1501 if (--farg < fltreg_argnum) {
1502 copy->varnum = farg;
1504 copy->varnum = --stackargs + intreg_argnum;
1507 if (--iarg < intreg_argnum) {
1508 copy->varnum = iarg;
1510 copy->varnum = --stackargs + intreg_argnum;
1514 (IS_FLT_DBL_TYPE(copy->type)) ? --farg : --iarg;
1522 if (! (copy->flags & SAVEDVAR)) {
1523 copy->varkind = ARGVAR;
1530 copy->flags |= SAVEDVAR;
1535 if (m->returntype != TYPE_VOID) {
1536 OP0_1(m->returntype);
1542 if (! (curstack->flags & SAVEDVAR)) {
1543 curstack->varkind = ARGVAR;
1544 curstack->varnum = 2;
1546 if (3 > arguments_num) {
1553 if (! (curstack->flags & SAVEDVAR)) {
1554 curstack->varkind = ARGVAR;
1555 curstack->varnum = 1;
1557 if (2 > arguments_num) {
1563 if (! (curstack->flags & SAVEDVAR)) {
1564 curstack->varkind = ARGVAR;
1565 curstack->varnum = 0;
1567 if (1 > arguments_num) {
1573 copy->flags |= SAVEDVAR;
1576 if (iptr->op1 != TYPE_VOID)
1580 case ICMD_MULTIANEWARRAY:
1582 if ((i + intreg_argnum) > arguments_num)
1583 arguments_num = i + intreg_argnum;
1586 if (! (copy->flags & SAVEDVAR)) {
1587 copy->varkind = ARGVAR;
1588 copy->varnum = i + intreg_argnum;
1593 copy->flags |= SAVEDVAR;
1601 case ICMD_CLEAR_ARGREN:
1602 for (i = iptr->op1; i<maxlocals; i++)
1604 iptr->opc = opcode = ICMD_NOP;
1608 case ICMD_READONLY_ARG:
1609 case ICMD_READONLY_ARG+1:
1610 case ICMD_READONLY_ARG+2:
1611 case ICMD_READONLY_ARG+3:
1612 case ICMD_READONLY_ARG+4:
1614 if (curstack->varkind == LOCALVAR) {
1615 i = curstack->varnum;
1616 argren[iptr->op1] = i;
1619 opcode = iptr->opc = opcode - ICMD_READONLY_ARG + ICMD_ISTORE;
1625 printf("ICMD %d at %d\n", iptr->opc, (int)(iptr-instr));
1626 panic("Missing ICMD code during stack analysis");
1629 } /* while instructions */
1630 bptr->outstack = curstack;
1631 bptr->outdepth = stackdepth;
1635 superblockend = true;
1637 } /* while blocks */
1638 } while (repeat && ! deadcode);
1641 if (block_count > count_max_basic_blocks)
1642 count_max_basic_blocks = block_count;
1643 count_basic_blocks += block_count;
1644 if (instr_count > count_max_javainstr)
1645 count_max_javainstr = instr_count;
1646 count_javainstr += instr_count;
1647 if (stack_count > count_upper_bound_new_stack)
1648 count_upper_bound_new_stack = stack_count;
1649 if ((new - stack) > count_max_new_stack)
1650 count_max_new_stack = (new - stack);
1652 b_count = block_count;
1654 while (--b_count >= 0) {
1655 if (bptr->flags > BBREACHED) {
1656 if (bptr->indepth >= 10)
1657 count_block_stack[10]++;
1659 count_block_stack[bptr->indepth]++;
1662 count_block_size_distribution[len]++;
1664 count_block_size_distribution[10]++;
1666 count_block_size_distribution[11]++;
1668 count_block_size_distribution[12]++;
1670 count_block_size_distribution[13]++;
1672 count_block_size_distribution[14]++;
1674 count_block_size_distribution[15]++;
1676 count_block_size_distribution[16]++;
1678 count_block_size_distribution[17]++;
1684 count_analyse_iterations[0]++;
1685 else if (loops == 2)
1686 count_analyse_iterations[1]++;
1687 else if (loops == 3)
1688 count_analyse_iterations[2]++;
1689 else if (loops == 4)
1690 count_analyse_iterations[3]++;
1692 count_analyse_iterations[4]++;
1694 if (block_count <= 5)
1695 count_method_bb_distribution[0]++;
1696 else if (block_count <= 10)
1697 count_method_bb_distribution[1]++;
1698 else if (block_count <= 15)
1699 count_method_bb_distribution[2]++;
1700 else if (block_count <= 20)
1701 count_method_bb_distribution[3]++;
1702 else if (block_count <= 30)
1703 count_method_bb_distribution[4]++;
1704 else if (block_count <= 40)
1705 count_method_bb_distribution[5]++;
1706 else if (block_count <= 50)
1707 count_method_bb_distribution[6]++;
1708 else if (block_count <= 75)
1709 count_method_bb_distribution[7]++;
1711 count_method_bb_distribution[8]++;
1716 static void print_stack(stackptr s) {
1732 if (s->flags & SAVEDVAR)
1733 switch (s->varkind) {
1735 if (s->flags & INMEMORY)
1736 printf(" M%02d", s->regoff);
1737 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1738 printf(" F%02d", s->regoff);
1740 printf(" %3s", regs[s->regoff]);
1743 printf(" I%02d", s->varnum);
1746 printf(" L%02d", s->varnum);
1749 printf(" A%02d", s->varnum);
1752 printf(" !%02d", j);
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);
1782 static void print_reg(stackptr s) {
1784 if (s->flags & SAVEDVAR)
1785 switch (s->varkind) {
1787 if (s->flags & INMEMORY)
1788 printf(" tm%02d", s->regoff);
1790 printf(" tr%02d", s->regoff);
1793 printf(" s %02d", s->varnum);
1796 printf(" l %02d", s->varnum);
1799 printf(" a %02d", s->varnum);
1802 printf(" ! %02d", s->varnum);
1805 switch (s->varkind) {
1807 if (s->flags & INMEMORY)
1808 printf(" Tm%02d", s->regoff);
1810 printf(" Tr%02d", s->regoff);
1813 printf(" S %02d", s->varnum);
1816 printf(" L %02d", s->varnum);
1819 printf(" A %02d", s->varnum);
1822 printf(" ? %02d", s->varnum);
1832 static char *builtin_name(functionptr bptr)
1834 builtin_descriptor *bdesc = builtin_desc;
1835 while ((bdesc->bptr != NULL) && (bdesc->bptr != bptr))
1841 static char *jit_type[] = {
1850 static void show_icmd_method()
1861 utf_fprint(stdout, class->name);
1863 utf_fprint(stdout, method->name);
1865 utf_fprint(stdout, method->descriptor);
1866 printf ("\n\nMax locals: %d\n", (int) maxlocals);
1867 printf ("Max stack: %d\n", (int) maxstack);
1869 printf ("Exceptions (Number: %d):\n", exceptiontablelength);
1870 for (ex = extable; ex != NULL; ex = ex->down) {
1871 printf(" L%03d ... ", ex->start->debug_nr );
1872 printf("L%03d = ", ex->end->debug_nr);
1873 printf("L%03d\n", ex->handler->debug_nr);
1876 printf ("Local Table:\n");
1877 for (i = 0; i < maxlocals; i++) {
1878 printf(" %3d: ", i);
1879 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1880 if (locals[i][j].type >= 0) {
1881 printf(" (%s) ", jit_type[j]);
1882 if (locals[i][j].flags & INMEMORY)
1883 printf("m%2d", locals[i][j].regoff);
1884 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1885 printf("f%02d", locals[i][j].regoff);
1887 printf("%3s", regs[locals[i][j].regoff]);
1893 printf ("Interface Table:\n");
1894 for (i = 0; i < maxstack; i++) {
1895 if ((interfaces[i][0].type >= 0) || (interfaces[i][1].type >= 0) ||
1896 (interfaces[i][2].type >= 0) || (interfaces[i][3].type >= 0) ||
1897 (interfaces[i][4].type >= 0)) {
1898 printf(" %3d: ", i);
1899 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1900 if (interfaces[i][j].type >= 0) {
1901 printf(" (%s) ", jit_type[j]);
1902 if (interfaces[i][j].flags & SAVEDVAR) {
1903 if (interfaces[i][j].flags & INMEMORY)
1904 printf("M%2d", interfaces[i][j].regoff);
1905 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1906 printf("F%02d", interfaces[i][j].regoff);
1908 printf("%3s", regs[interfaces[i][j].regoff]);
1911 if (interfaces[i][j].flags & INMEMORY)
1912 printf("m%2d", interfaces[i][j].regoff);
1913 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1914 printf("f%02d", interfaces[i][j].regoff);
1916 printf("%3s", regs[interfaces[i][j].regoff]);
1924 if (showdisassemble) {
1925 #if defined(__I386__) || defined(__X86_64__)
1928 u1ptr = method->mcode + dseglen;
1929 for (i = 0; i < block[0].mpc; i++, u1ptr++) {
1930 disassinstr(u1ptr, i);
1936 s4ptr = (s4 *) (method->mcode + dseglen);
1937 for (i = 0; i < block[0].mpc; i += 4, s4ptr++) {
1938 disassinstr(*s4ptr, i);
1945 for (bptr = block; bptr != NULL; bptr = bptr->next)
1946 if (bptr->flags != BBDELETED) {
1947 deadcode = bptr->flags <= BBREACHED;
1950 for (j = maxstack; j > 0; j--)
1953 print_stack(bptr->instack);
1954 printf("] L%03d(%d - %d):\n", bptr->debug_nr, bptr->icount, bptr->pre_count);
1955 iptr = bptr->iinstr;
1957 for (i=0; i < bptr->icount; i++, iptr++) {
1960 for (j = maxstack; j > 0; j--)
1964 print_stack(iptr->dst);
1965 printf("] %4d %s", i, icmd_names[iptr->opc]);
1966 switch ((int) iptr->opc) {
1967 case ICMD_IADDCONST:
1968 case ICMD_ISUBCONST:
1969 case ICMD_IMULCONST:
1972 case ICMD_IREM0X10001:
1973 case ICMD_IANDCONST:
1975 case ICMD_IXORCONST:
1976 case ICMD_ISHLCONST:
1977 case ICMD_ISHRCONST:
1978 case ICMD_IUSHRCONST:
1979 case ICMD_LSHLCONST:
1980 case ICMD_LSHRCONST:
1981 case ICMD_LUSHRCONST:
1983 case ICMD_ELSE_ICONST:
1984 case ICMD_IFEQ_ICONST:
1985 case ICMD_IFNE_ICONST:
1986 case ICMD_IFLT_ICONST:
1987 case ICMD_IFGE_ICONST:
1988 case ICMD_IFGT_ICONST:
1989 case ICMD_IFLE_ICONST:
1990 printf(" %d", iptr->val.i);
1992 case ICMD_LADDCONST:
1993 case ICMD_LSUBCONST:
1994 case ICMD_LMULCONST:
1997 case ICMD_LANDCONST:
1999 case ICMD_LXORCONST:
2001 #if defined(__I386__)
2002 printf(" %lld", iptr->val.l);
2004 printf(" %ld", iptr->val.l);
2008 printf(" %f", iptr->val.f);
2011 printf(" %f", iptr->val.d);
2014 printf(" %p", iptr->val.a);
2018 printf(" %d,", ((fieldinfo *) iptr->val.a)->offset);
2019 case ICMD_PUTSTATIC:
2020 case ICMD_GETSTATIC:
2023 ((fieldinfo *) iptr->val.a)->name);
2026 printf(" %d + %d", iptr->op1, iptr->val.i);
2061 printf(" %d", iptr->op1);
2066 ((classinfo *) iptr->val.a)->name);
2069 switch (iptr->op1) {
2096 case ICMD_ANEWARRAY:
2100 ((classinfo *) iptr->val.a)->name);
2103 case ICMD_CHECKCAST:
2104 case ICMD_INSTANCEOF:
2106 classinfo *c = iptr->val.a;
2107 if (c->flags & ACC_INTERFACE)
2108 printf(" (INTERFACE) ");
2110 printf(" (CLASS,%3d) ", c->vftbl->diffval);
2111 utf_fprint(stdout, c->name);
2117 printf(" %s", builtin_name((functionptr) iptr->val.a));
2119 case ICMD_INVOKEVIRTUAL:
2120 case ICMD_INVOKESPECIAL:
2121 case ICMD_INVOKESTATIC:
2122 case ICMD_INVOKEINTERFACE:
2125 ((methodinfo *) iptr->val.a)->class->name);
2128 ((methodinfo *) iptr->val.a)->name);
2136 printf("(%d) L%03d", iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
2144 printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
2149 case ICMD_IFNONNULL:
2150 case ICMD_IF_ICMPEQ:
2151 case ICMD_IF_ICMPNE:
2152 case ICMD_IF_ICMPLT:
2153 case ICMD_IF_ICMPGE:
2154 case ICMD_IF_ICMPGT:
2155 case ICMD_IF_ICMPLE:
2156 case ICMD_IF_LCMPEQ:
2157 case ICMD_IF_LCMPNE:
2158 case ICMD_IF_LCMPLT:
2159 case ICMD_IF_LCMPGE:
2160 case ICMD_IF_LCMPGT:
2161 case ICMD_IF_LCMPLE:
2162 case ICMD_IF_ACMPEQ:
2163 case ICMD_IF_ACMPNE:
2164 printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
2166 case ICMD_TABLESWITCH:
2168 s4ptr = iptr->val.a;
2169 tptr = (void **) iptr->target;
2171 printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
2177 j = *s4ptr++; /* low */
2178 j = *s4ptr++ - j; /* high */
2180 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2185 case ICMD_LOOKUPSWITCH:
2186 s4ptr = iptr->val.a;
2187 tptr = (void **) iptr->target;
2189 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2190 s4ptr++; /* default */
2191 j = *s4ptr; /* count */
2195 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2203 if (showdisassemble && (!deadcode)) {
2204 #if defined(__I386__) || defined(__X86_64__)
2209 u1ptr = method->mcode + dseglen + i;
2211 if (bptr->next != NULL) {
2212 for (; i < bptr->next->mpc; i++, u1ptr++) {
2213 disassinstr(u1ptr, i);
2220 for (; u1ptr < (u1 *) (method->mcode + method->mcodelength); i++, u1ptr++) {
2221 disassinstr(u1ptr, i);
2230 s4ptr = (s4 *) (method->mcode + dseglen + i);
2232 if (bptr->next != NULL) {
2233 for (; i < bptr->next->mpc; i += 4, s4ptr++) {
2234 disassinstr(*s4ptr, i);
2239 for (; s4ptr < (s4 *) (method->mcode + method->mcodelength); i += 4, s4ptr++) {
2240 disassinstr(*s4ptr, i);
2250 s4ptr = (s4 *) (method->mcode + dseglen + i);
2251 if (showdisassemble && (s4ptr < (s4 *) (method->mcode + method->mcodelength))) {
2253 for (; s4ptr < (s4 *) (method->mcode + method->mcodelength); i += 4, s4ptr++) {
2254 disassinstr(*s4ptr, i);
2263 * These are local overrides for various environment variables in Emacs.
2264 * Please do not remove this and leave it at the end of the file, where
2265 * Emacs will automagically detect them.
2266 * ---------------------------------------------------------------------
2269 * indent-tabs-mode: t