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;
191 // int *argren = DMNEW(int, maxlocals);
192 int *argren = (int *)alloca(maxlocals * sizeof(int)); /* table for argument renaming */
193 for (i = 0; i < maxlocals; i++)
199 block[0].flags = BBREACHED;
200 block[0].instack = 0;
201 block[0].indepth = 0;
203 for (i = 0; i < exceptiontablelength; i++) {
204 bptr = &block[block_index[extable[i].handlerpc]];
205 bptr->flags = BBREACHED;
206 bptr->type = BBTYPE_EXH;
209 bptr->pre_count = 10000;
214 #ifdef CONDITIONAL_LOADCONST
215 b_count = block_count;
217 while (--b_count >= 0) {
218 if (bptr->icount != 0) {
219 iptr = bptr->iinstr + bptr->icount - 1;
252 block[block_index[iptr->op1]].pre_count++;
255 case ICMD_TABLESWITCH:
257 block[block_index[*s4ptr++]].pre_count++; /* default */
258 i = *s4ptr++; /* low */
259 i = *s4ptr++ - i + 1; /* high */
261 block[block_index[*s4ptr++]].pre_count++;
265 case ICMD_LOOKUPSWITCH:
267 block[block_index[*s4ptr++]].pre_count++; /* default */
268 i = *s4ptr++; /* count */
270 block[block_index[s4ptr[1]]].pre_count++;
286 b_count = block_count;
288 superblockend = true;
292 while (--b_count >= 0) {
293 if (bptr->flags == BBDELETED) {
296 else if (superblockend && (bptr->flags < BBREACHED))
298 else if (bptr->flags <= BBREACHED) {
300 stackdepth = bptr->indepth;
301 else if (bptr->flags < BBREACHED) {
303 bptr->instack = copy;
304 bptr->indepth = stackdepth;
306 else if (bptr->indepth != stackdepth) {
308 panic("Stack depth mismatch");
311 curstack = bptr->instack;
313 superblockend = false;
314 bptr->flags = BBFINISHED;
317 b_index = bptr - block;
322 #ifdef USEBUILTINTABLE
324 stdopdescriptor *blast = builtintable + sizeof(builtintable)/sizeof(stdopdescriptor);
325 stdopdescriptor *breplace;
326 breplace = find_builtin(builtintable, blast, opcode);
327 if (breplace != blast && opcode == breplace->opcode && !breplace->supported) {
328 iptr[0].opc = breplace->icmd;
329 iptr[0].op1 = breplace->type_d;
330 iptr[0].val.a = breplace->builtin;
331 isleafmethod = false;
332 switch (breplace->icmd) {
347 case ICMD_CHECKASIZE:
349 case ICMD_IFEQ_ICONST:
350 case ICMD_IFNE_ICONST:
351 case ICMD_IFLT_ICONST:
352 case ICMD_IFGE_ICONST:
353 case ICMD_IFGT_ICONST:
354 case ICMD_IFLE_ICONST:
355 case ICMD_ELSE_ICONST:
360 locals[iptr->op1][TYPE_ADR].type = TYPE_ADR;
362 COUNT(count_pcmd_return);
364 superblockend = true;
367 /* pop 0 push 1 const */
370 COUNT(count_pcmd_load);
372 switch (iptr[1].opc) {
374 iptr[0].opc = ICMD_IADDCONST;
376 iptr[1].opc = ICMD_NOP;
377 OP1_1(TYPE_INT,TYPE_INT);
378 COUNT(count_pcmd_op);
381 iptr[0].opc = ICMD_ISUBCONST;
382 goto icmd_iconst_tail;
384 iptr[0].opc = ICMD_IMULCONST;
385 goto icmd_iconst_tail;
387 if (iptr[0].val.i == 0x00000002)
389 else if (iptr[0].val.i == 0x00000004)
391 else if (iptr[0].val.i == 0x00000008)
393 else if (iptr[0].val.i == 0x00000010)
395 else if (iptr[0].val.i == 0x00000020)
397 else if (iptr[0].val.i == 0x00000040)
399 else if (iptr[0].val.i == 0x00000080)
401 else if (iptr[0].val.i == 0x00000100)
403 else if (iptr[0].val.i == 0x00000200)
405 else if (iptr[0].val.i == 0x00000400)
407 else if (iptr[0].val.i == 0x00000800)
409 else if (iptr[0].val.i == 0x00001000)
411 else if (iptr[0].val.i == 0x00002000)
413 else if (iptr[0].val.i == 0x00004000)
415 else if (iptr[0].val.i == 0x00008000)
417 else if (iptr[0].val.i == 0x00010000)
419 else if (iptr[0].val.i == 0x00020000)
421 else if (iptr[0].val.i == 0x00040000)
423 else if (iptr[0].val.i == 0x00080000)
425 else if (iptr[0].val.i == 0x00100000)
427 else if (iptr[0].val.i == 0x00200000)
429 else if (iptr[0].val.i == 0x00400000)
431 else if (iptr[0].val.i == 0x00800000)
433 else if (iptr[0].val.i == 0x01000000)
435 else if (iptr[0].val.i == 0x02000000)
437 else if (iptr[0].val.i == 0x04000000)
439 else if (iptr[0].val.i == 0x08000000)
441 else if (iptr[0].val.i == 0x10000000)
443 else if (iptr[0].val.i == 0x20000000)
445 else if (iptr[0].val.i == 0x40000000)
447 else if (iptr[0].val.i == 0x80000000)
453 iptr[0].opc = ICMD_IDIVPOW2;
454 goto icmd_iconst_tail;
456 #if !defined(__I386__) && !defined(NO_DIV_OPT)
457 if (iptr[0].val.i == 0x10001) {
458 iptr[0].opc = ICMD_IREM0X10001;
459 goto icmd_iconst_tail;
462 if ((iptr[0].val.i == 0x00000002) ||
463 (iptr[0].val.i == 0x00000004) ||
464 (iptr[0].val.i == 0x00000008) ||
465 (iptr[0].val.i == 0x00000010) ||
466 (iptr[0].val.i == 0x00000020) ||
467 (iptr[0].val.i == 0x00000040) ||
468 (iptr[0].val.i == 0x00000080) ||
469 (iptr[0].val.i == 0x00000100) ||
470 (iptr[0].val.i == 0x00000200) ||
471 (iptr[0].val.i == 0x00000400) ||
472 (iptr[0].val.i == 0x00000800) ||
473 (iptr[0].val.i == 0x00001000) ||
474 (iptr[0].val.i == 0x00002000) ||
475 (iptr[0].val.i == 0x00004000) ||
476 (iptr[0].val.i == 0x00008000) ||
477 (iptr[0].val.i == 0x00010000) ||
478 (iptr[0].val.i == 0x00020000) ||
479 (iptr[0].val.i == 0x00040000) ||
480 (iptr[0].val.i == 0x00080000) ||
481 (iptr[0].val.i == 0x00100000) ||
482 (iptr[0].val.i == 0x00200000) ||
483 (iptr[0].val.i == 0x00400000) ||
484 (iptr[0].val.i == 0x00800000) ||
485 (iptr[0].val.i == 0x01000000) ||
486 (iptr[0].val.i == 0x02000000) ||
487 (iptr[0].val.i == 0x04000000) ||
488 (iptr[0].val.i == 0x08000000) ||
489 (iptr[0].val.i == 0x10000000) ||
490 (iptr[0].val.i == 0x20000000) ||
491 (iptr[0].val.i == 0x40000000) ||
492 (iptr[0].val.i == 0x80000000)) {
493 iptr[0].opc = ICMD_IREMPOW2;
495 goto icmd_iconst_tail;
500 iptr[0].opc = ICMD_IANDCONST;
501 goto icmd_iconst_tail;
503 iptr[0].opc = ICMD_IORCONST;
504 goto icmd_iconst_tail;
506 iptr[0].opc = ICMD_IXORCONST;
507 goto icmd_iconst_tail;
509 iptr[0].opc = ICMD_ISHLCONST;
510 goto icmd_iconst_tail;
512 iptr[0].opc = ICMD_ISHRCONST;
513 goto icmd_iconst_tail;
515 iptr[0].opc = ICMD_IUSHRCONST;
516 goto icmd_iconst_tail;
517 #if SUPPORT_LONG_SHIFT
519 iptr[0].opc = ICMD_LSHLCONST;
520 goto icmd_lconst_tail;
522 iptr[0].opc = ICMD_LSHRCONST;
523 goto icmd_lconst_tail;
525 iptr[0].opc = ICMD_LUSHRCONST;
526 goto icmd_lconst_tail;
529 iptr[0].opc = ICMD_IFEQ;
531 iptr[0].op1 = iptr[1].op1;
534 /* iptr[1].opc = ICMD_NOP; */
536 tbptr = block + block_index[iptr->op1];
538 iptr[0].target = (void *) tbptr;
540 MARKREACHED(tbptr, copy);
541 COUNT(count_pcmd_bra);
544 iptr[0].opc = ICMD_IFLT;
545 goto icmd_if_icmp_tail;
547 iptr[0].opc = ICMD_IFLE;
548 goto icmd_if_icmp_tail;
550 iptr[0].opc = ICMD_IFNE;
551 goto icmd_if_icmp_tail;
553 iptr[0].opc = ICMD_IFGT;
554 goto icmd_if_icmp_tail;
556 iptr[0].opc = ICMD_IFGE;
557 goto icmd_if_icmp_tail;
566 COUNT(count_pcmd_load);
568 switch (iptr[1].opc) {
571 iptr[0].opc = ICMD_LADDCONST;
573 iptr[1].opc = ICMD_NOP;
574 OP1_1(TYPE_LNG,TYPE_LNG);
575 COUNT(count_pcmd_op);
578 iptr[0].opc = ICMD_LSUBCONST;
579 goto icmd_lconst_tail;
581 #if SUPPORT_LONG_MULDIV
583 iptr[0].opc = ICMD_LMULCONST;
584 goto icmd_lconst_tail;
586 if (iptr[0].val.l == 0x00000002)
588 else if (iptr[0].val.l == 0x00000004)
590 else if (iptr[0].val.l == 0x00000008)
592 else if (iptr[0].val.l == 0x00000010)
594 else if (iptr[0].val.l == 0x00000020)
596 else if (iptr[0].val.l == 0x00000040)
598 else if (iptr[0].val.l == 0x00000080)
600 else if (iptr[0].val.l == 0x00000100)
602 else if (iptr[0].val.l == 0x00000200)
604 else if (iptr[0].val.l == 0x00000400)
606 else if (iptr[0].val.l == 0x00000800)
608 else if (iptr[0].val.l == 0x00001000)
610 else if (iptr[0].val.l == 0x00002000)
612 else if (iptr[0].val.l == 0x00004000)
614 else if (iptr[0].val.l == 0x00008000)
616 else if (iptr[0].val.l == 0x00010000)
618 else if (iptr[0].val.l == 0x00020000)
620 else if (iptr[0].val.l == 0x00040000)
622 else if (iptr[0].val.l == 0x00080000)
624 else if (iptr[0].val.l == 0x00100000)
626 else if (iptr[0].val.l == 0x00200000)
628 else if (iptr[0].val.l == 0x00400000)
630 else if (iptr[0].val.l == 0x00800000)
632 else if (iptr[0].val.l == 0x01000000)
634 else if (iptr[0].val.l == 0x02000000)
636 else if (iptr[0].val.l == 0x04000000)
638 else if (iptr[0].val.l == 0x08000000)
640 else if (iptr[0].val.l == 0x10000000)
642 else if (iptr[0].val.l == 0x20000000)
644 else if (iptr[0].val.l == 0x40000000)
646 else if (iptr[0].val.l == 0x80000000)
652 iptr[0].opc = ICMD_LDIVPOW2;
653 goto icmd_lconst_tail;
655 #if !defined(__I386__) && !defined(NO_DIV_OPT)
656 if (iptr[0].val.l == 0x10001) {
657 iptr[0].opc = ICMD_LREM0X10001;
658 goto icmd_lconst_tail;
661 if ((iptr[0].val.l == 0x00000002) ||
662 (iptr[0].val.l == 0x00000004) ||
663 (iptr[0].val.l == 0x00000008) ||
664 (iptr[0].val.l == 0x00000010) ||
665 (iptr[0].val.l == 0x00000020) ||
666 (iptr[0].val.l == 0x00000040) ||
667 (iptr[0].val.l == 0x00000080) ||
668 (iptr[0].val.l == 0x00000100) ||
669 (iptr[0].val.l == 0x00000200) ||
670 (iptr[0].val.l == 0x00000400) ||
671 (iptr[0].val.l == 0x00000800) ||
672 (iptr[0].val.l == 0x00001000) ||
673 (iptr[0].val.l == 0x00002000) ||
674 (iptr[0].val.l == 0x00004000) ||
675 (iptr[0].val.l == 0x00008000) ||
676 (iptr[0].val.l == 0x00010000) ||
677 (iptr[0].val.l == 0x00020000) ||
678 (iptr[0].val.l == 0x00040000) ||
679 (iptr[0].val.l == 0x00080000) ||
680 (iptr[0].val.l == 0x00100000) ||
681 (iptr[0].val.l == 0x00200000) ||
682 (iptr[0].val.l == 0x00400000) ||
683 (iptr[0].val.l == 0x00800000) ||
684 (iptr[0].val.l == 0x01000000) ||
685 (iptr[0].val.l == 0x02000000) ||
686 (iptr[0].val.l == 0x04000000) ||
687 (iptr[0].val.l == 0x08000000) ||
688 (iptr[0].val.l == 0x10000000) ||
689 (iptr[0].val.l == 0x20000000) ||
690 (iptr[0].val.l == 0x40000000) ||
691 (iptr[0].val.l == 0x80000000)) {
692 iptr[0].opc = ICMD_LREMPOW2;
694 goto icmd_lconst_tail;
701 iptr[0].opc = ICMD_LANDCONST;
702 goto icmd_lconst_tail;
704 iptr[0].opc = ICMD_LORCONST;
705 goto icmd_lconst_tail;
707 iptr[0].opc = ICMD_LXORCONST;
708 goto icmd_lconst_tail;
710 #ifndef NOLONG_CONDITIONAL
712 if ((len > 1) && (iptr[2].val.i == 0)) {
713 switch (iptr[2].opc) {
715 iptr[0].opc = ICMD_IF_LEQ;
716 icmd_lconst_lcmp_tail:
717 iptr[0].op1 = iptr[2].op1;
720 /* iptr[1].opc = ICMD_NOP;
721 iptr[2].opc = ICMD_NOP; */
723 tbptr = block + block_index[iptr->op1];
725 iptr[0].target = (void *) tbptr;
727 MARKREACHED(tbptr, copy);
728 COUNT(count_pcmd_bra);
729 COUNT(count_pcmd_op);
732 iptr[0].opc = ICMD_IF_LNE;
733 goto icmd_lconst_lcmp_tail;
735 iptr[0].opc = ICMD_IF_LLT;
736 goto icmd_lconst_lcmp_tail;
738 iptr[0].opc = ICMD_IF_LGT;
739 goto icmd_lconst_lcmp_tail;
741 iptr[0].opc = ICMD_IF_LLE;
742 goto icmd_lconst_lcmp_tail;
744 iptr[0].opc = ICMD_IF_LGE;
745 goto icmd_lconst_lcmp_tail;
748 } /* switch (iptr[2].opc) */
749 } /* if (iptr[2].val.i == 0) */
762 COUNT(count_pcmd_load);
766 COUNT(count_pcmd_load);
770 COUNT(count_pcmd_load);
774 /* pop 0 push 1 load */
781 COUNT(count_load_instruction);
782 i = opcode-ICMD_ILOAD;
783 iptr->op1 = argren[iptr->op1];
784 locals[ iptr->op1 ][i].type = i;
785 LOAD(i, LOCALVAR, iptr->op1);
795 COUNT(count_check_null);
796 COUNT(count_check_bound);
797 COUNT(count_pcmd_mem);
798 OP2IAT_1(opcode-ICMD_IALOAD);
804 COUNT(count_check_null);
805 COUNT(count_check_bound);
806 COUNT(count_pcmd_mem);
810 /* pop 0 push 0 iinc */
816 count_store_depth[10]++;
818 count_store_depth[i]++;
823 if ((copy->varkind == LOCALVAR) &&
824 (copy->varnum == iptr->op1)) {
825 copy->varkind = TEMPVAR;
834 /* pop 1 push 0 store */
843 i = opcode-ICMD_ISTORE;
844 locals[iptr->op1][i].type = i;
849 count_store_length[20]++;
851 count_store_length[i]++;
854 count_store_depth[10]++;
856 count_store_depth[i]++;
858 copy = curstack->prev;
861 if ((copy->varkind == LOCALVAR) &&
862 (copy->varnum == iptr->op1)) {
863 copy->varkind = TEMPVAR;
869 if ((new - curstack) == 1) {
870 curstack->varkind = LOCALVAR;
871 curstack->varnum = iptr->op1;
873 STORE(opcode-ICMD_ISTORE);
883 COUNT(count_check_null);
884 COUNT(count_check_bound);
885 COUNT(count_pcmd_mem);
886 OP3TIA_0(opcode-ICMD_IASTORE);
891 COUNT(count_check_null);
892 COUNT(count_check_bound);
893 COUNT(count_pcmd_mem);
908 COUNT(count_pcmd_return);
909 OP1_0(opcode-ICMD_IRETURN);
910 superblockend = true;
914 COUNT(count_check_null);
918 superblockend = true;
922 COUNT(count_pcmd_mem);
926 /* pop 1 push 0 branch */
930 COUNT(count_pcmd_bra);
932 tbptr = block + block_index[iptr->op1];
934 iptr[0].target = (void *) tbptr;
936 MARKREACHED(tbptr, copy);
945 COUNT(count_pcmd_bra);
946 #ifdef CONDITIONAL_LOADCONST
948 tbptr = block + b_index;
949 if ((b_count >= 3) &&
950 ((b_index + 2) == block_index[iptr[0].op1]) &&
951 (tbptr[1].pre_count == 1) &&
952 (iptr[1].opc == ICMD_ICONST) &&
953 (iptr[2].opc == ICMD_GOTO) &&
954 ((b_index + 3) == block_index[iptr[2].op1]) &&
955 (tbptr[2].pre_count == 1) &&
956 (iptr[3].opc == ICMD_ICONST)) {
957 OP1_1(TYPE_INT, TYPE_INT);
958 switch (iptr[0].opc) {
960 iptr[0].opc = ICMD_IFNE_ICONST;
963 iptr[0].opc = ICMD_IFEQ_ICONST;
966 iptr[0].opc = ICMD_IFGE_ICONST;
969 iptr[0].opc = ICMD_IFLT_ICONST;
972 iptr[0].opc = ICMD_IFLE_ICONST;
975 iptr[0].opc = ICMD_IFGT_ICONST;
978 iptr[0].val.i = iptr[1].val.i;
979 iptr[1].opc = ICMD_ELSE_ICONST;
980 iptr[1].val.i = iptr[3].val.i;
981 iptr[2].opc = ICMD_NOP;
982 iptr[3].opc = ICMD_NOP;
983 tbptr[1].flags = BBDELETED;
984 tbptr[2].flags = BBDELETED;
987 if (tbptr[3].pre_count == 2) {
988 len += tbptr[3].icount + 3;
989 bptr->icount += tbptr[3].icount + 3;
990 tbptr[3].flags = BBDELETED;
1004 tbptr = block + block_index[iptr->op1];
1006 iptr[0].target = (void *) tbptr;
1008 MARKREACHED(tbptr, copy);
1011 /* pop 0 push 0 branch */
1014 COUNT(count_pcmd_bra);
1015 tbptr = block + block_index[iptr->op1];
1017 iptr[0].target = (void *) tbptr;
1019 MARKREACHED(tbptr, copy);
1021 superblockend = true;
1024 /* pop 1 push 0 table branch */
1026 case ICMD_TABLESWITCH:
1027 COUNT(count_pcmd_table);
1029 s4ptr = iptr->val.a;
1030 tbptr = block + block_index[*s4ptr++]; /* default */
1031 MARKREACHED(tbptr, copy);
1032 i = *s4ptr++; /* low */
1033 i = *s4ptr++ - i + 1; /* high */
1035 tptr = DMNEW(void*, i+1);
1036 iptr->target = (void *) tptr;
1038 tptr[0] = (void *) tbptr;
1042 tbptr = block + block_index[*s4ptr++];
1044 tptr[0] = (void *) tbptr;
1047 MARKREACHED(tbptr, copy);
1050 superblockend = true;
1053 /* pop 1 push 0 table branch */
1055 case ICMD_LOOKUPSWITCH:
1056 COUNT(count_pcmd_table);
1058 s4ptr = iptr->val.a;
1059 tbptr = block + block_index[*s4ptr++]; /* default */
1060 MARKREACHED(tbptr, copy);
1061 i = *s4ptr++; /* count */
1063 tptr = DMNEW(void*, i+1);
1064 iptr->target = (void *) tptr;
1066 tptr[0] = (void *) tbptr;
1070 tbptr = block + block_index[s4ptr[1]];
1072 tptr[0] = (void *) tbptr;
1075 MARKREACHED(tbptr, copy);
1079 superblockend = true;
1082 case ICMD_NULLCHECKPOP:
1083 case ICMD_MONITORENTER:
1084 COUNT(count_check_null);
1085 case ICMD_MONITOREXIT:
1089 /* pop 2 push 0 branch */
1091 case ICMD_IF_ICMPEQ:
1092 case ICMD_IF_ICMPNE:
1093 case ICMD_IF_ICMPLT:
1094 case ICMD_IF_ICMPGE:
1095 case ICMD_IF_ICMPGT:
1096 case ICMD_IF_ICMPLE:
1097 COUNT(count_pcmd_bra);
1099 tbptr = block + block_index[iptr->op1];
1101 iptr[0].target = (void *) tbptr;
1103 MARKREACHED(tbptr, copy);
1106 case ICMD_IF_ACMPEQ:
1107 case ICMD_IF_ACMPNE:
1108 COUNT(count_pcmd_bra);
1110 tbptr = block + block_index[iptr->op1];
1112 iptr[0].target = (void *) tbptr;
1114 MARKREACHED(tbptr, copy);
1120 COUNT(count_check_null);
1121 COUNT(count_pcmd_mem);
1122 OPTT2_0(iptr->op1,TYPE_ADR);
1126 if (! IS_2_WORD_TYPE(curstack->type)) {
1127 OP1_0ANY; /* second pop */
1130 iptr->opc = ICMD_POP;
1134 /* pop 0 push 1 dup */
1137 COUNT(count_dup_instruction);
1142 if (IS_2_WORD_TYPE(curstack->type)) {
1143 iptr->opc = ICMD_DUP;
1148 NEWSTACK(copy->prev->type, copy->prev->varkind,
1149 copy->prev->varnum);
1150 NEWSTACK(copy->type, copy->varkind,
1157 /* pop 2 push 3 dup */
1164 if (IS_2_WORD_TYPE(curstack->type)) {
1165 iptr->opc = ICMD_DUP_X1;
1173 /* pop 3 push 4 dup */
1176 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1177 iptr->opc = ICMD_DUP_X1;
1186 if (IS_2_WORD_TYPE(curstack->type)) {
1187 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1188 iptr->opc = ICMD_DUP_X1;
1192 iptr->opc = ICMD_DUP_X2;
1197 if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1198 iptr->opc = ICMD_DUP2_X1;
1206 /* pop 2 push 2 swap */
1215 if (!(SUPPORT_DIVISION)) {
1216 iptr[0].opc = ICMD_BUILTIN2;
1217 iptr[0].op1 = TYPE_INT;
1218 iptr[0].val.a = (functionptr) asm_builtin_idiv;
1219 isleafmethod = false;
1224 if (!(SUPPORT_DIVISION)) {
1225 iptr[0].opc = ICMD_BUILTIN2;
1226 iptr[0].op1 = TYPE_INT;
1227 iptr[0].val.a = (functionptr) asm_builtin_irem;
1228 isleafmethod = false;
1242 COUNT(count_pcmd_op);
1247 if (!(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_MULDIV)) {
1248 iptr[0].opc = ICMD_BUILTIN2;
1249 iptr[0].op1 = TYPE_LNG;
1250 iptr[0].val.a = (functionptr) asm_builtin_ldiv;
1251 isleafmethod = false;
1256 if (!(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_MULDIV)) {
1257 iptr[0].opc = ICMD_BUILTIN2;
1258 iptr[0].op1 = TYPE_LNG;
1259 iptr[0].val.a = (functionptr) asm_builtin_lrem;
1260 isleafmethod = false;
1271 COUNT(count_pcmd_op);
1278 COUNT(count_pcmd_op);
1287 COUNT(count_pcmd_op);
1296 COUNT(count_pcmd_op);
1301 COUNT(count_pcmd_op);
1302 #ifndef NOLONG_CONDITIONAL
1303 if ((len > 0) && (iptr[1].val.i == 0)) {
1304 switch (iptr[1].opc) {
1306 iptr[0].opc = ICMD_IF_LCMPEQ;
1308 iptr[0].op1 = iptr[1].op1;
1311 /* iptr[1].opc = ICMD_NOP; */
1313 tbptr = block + block_index[iptr->op1];
1315 iptr[0].target = (void *) tbptr;
1317 MARKREACHED(tbptr, copy);
1318 COUNT(count_pcmd_bra);
1321 iptr[0].opc = ICMD_IF_LCMPNE;
1322 goto icmd_lcmp_if_tail;
1324 iptr[0].opc = ICMD_IF_LCMPLT;
1325 goto icmd_lcmp_if_tail;
1327 iptr[0].opc = ICMD_IF_LCMPGT;
1328 goto icmd_lcmp_if_tail;
1330 iptr[0].opc = ICMD_IF_LCMPLE;
1331 goto icmd_lcmp_if_tail;
1333 iptr[0].opc = ICMD_IF_LCMPGE;
1334 goto icmd_lcmp_if_tail;
1336 OPTT2_1(TYPE_LNG, TYPE_INT);
1341 OPTT2_1(TYPE_LNG, TYPE_INT);
1345 COUNT(count_pcmd_op);
1346 OPTT2_1(TYPE_FLT, TYPE_INT);
1350 COUNT(count_pcmd_op);
1351 OPTT2_1(TYPE_DBL, TYPE_INT);
1359 case ICMD_INT2SHORT:
1360 COUNT(count_pcmd_op);
1361 OP1_1(TYPE_INT, TYPE_INT);
1364 COUNT(count_pcmd_op);
1365 OP1_1(TYPE_LNG, TYPE_LNG);
1368 COUNT(count_pcmd_op);
1369 OP1_1(TYPE_FLT, TYPE_FLT);
1372 COUNT(count_pcmd_op);
1373 OP1_1(TYPE_DBL, TYPE_DBL);
1377 COUNT(count_pcmd_op);
1378 OP1_1(TYPE_INT, TYPE_LNG);
1381 COUNT(count_pcmd_op);
1382 OP1_1(TYPE_INT, TYPE_FLT);
1385 COUNT(count_pcmd_op);
1386 OP1_1(TYPE_INT, TYPE_DBL);
1389 COUNT(count_pcmd_op);
1390 OP1_1(TYPE_LNG, TYPE_INT);
1393 COUNT(count_pcmd_op);
1394 OP1_1(TYPE_LNG, TYPE_FLT);
1397 COUNT(count_pcmd_op);
1398 OP1_1(TYPE_LNG, TYPE_DBL);
1401 COUNT(count_pcmd_op);
1402 OP1_1(TYPE_FLT, TYPE_INT);
1405 COUNT(count_pcmd_op);
1406 OP1_1(TYPE_FLT, TYPE_LNG);
1409 COUNT(count_pcmd_op);
1410 OP1_1(TYPE_FLT, TYPE_DBL);
1413 COUNT(count_pcmd_op);
1414 OP1_1(TYPE_DBL, TYPE_INT);
1417 COUNT(count_pcmd_op);
1418 OP1_1(TYPE_DBL, TYPE_LNG);
1421 COUNT(count_pcmd_op);
1422 OP1_1(TYPE_DBL, TYPE_FLT);
1425 case ICMD_CHECKCAST:
1426 OP1_1(TYPE_ADR, TYPE_ADR);
1429 case ICMD_ARRAYLENGTH:
1430 case ICMD_INSTANCEOF:
1431 OP1_1(TYPE_ADR, TYPE_INT);
1435 case ICMD_ANEWARRAY:
1436 OP1_1(TYPE_INT, TYPE_ADR);
1440 COUNT(count_check_null);
1441 COUNT(count_pcmd_mem);
1442 OP1_1(TYPE_ADR, iptr->op1);
1447 case ICMD_GETSTATIC:
1448 COUNT(count_pcmd_mem);
1458 tbptr = block + block_index[iptr->op1];
1460 iptr[0].target = (void *) tbptr;
1462 tbptr->type=BBTYPE_SBR;
1463 MARKREACHED(tbptr, copy);
1467 /* pop many push any */
1469 case ICMD_INVOKEVIRTUAL:
1470 case ICMD_INVOKESPECIAL:
1471 case ICMD_INVOKEINTERFACE:
1472 case ICMD_INVOKESTATIC:
1473 COUNT(count_pcmd_met);
1475 methodinfo *m = iptr->val.a;
1476 if (m->flags & ACC_STATIC)
1477 {COUNT(count_check_null);}
1479 if (i > arguments_num)
1483 if (! (copy->flags & SAVEDVAR)) {
1484 copy->varkind = ARGVAR;
1490 copy->flags |= SAVEDVAR;
1495 if (m->returntype != TYPE_VOID) {
1496 OP0_1(m->returntype);
1502 if (! (curstack->flags & SAVEDVAR)) {
1503 curstack->varkind = ARGVAR;
1504 curstack->varnum = 2;
1506 if (3 > arguments_num) {
1513 if (! (curstack->flags & SAVEDVAR)) {
1514 curstack->varkind = ARGVAR;
1515 curstack->varnum = 1;
1517 if (2 > arguments_num) {
1524 if (! (curstack->flags & SAVEDVAR)) {
1525 curstack->varkind = ARGVAR;
1526 curstack->varnum = 0;
1528 if (1 > arguments_num) {
1534 copy->flags |= SAVEDVAR;
1537 if (iptr->op1 != TYPE_VOID)
1541 case ICMD_MULTIANEWARRAY:
1543 if ((i + intreg_argnum) > arguments_num)
1544 arguments_num = i + intreg_argnum;
1547 if (! (copy->flags & SAVEDVAR)) {
1548 copy->varkind = ARGVAR;
1549 copy->varnum = i + intreg_argnum;
1554 copy->flags |= SAVEDVAR;
1562 case ICMD_CLEAR_ARGREN:
1563 for (i = iptr->op1; i<maxlocals; i++)
1565 iptr->opc = opcode = ICMD_NOP;
1569 case ICMD_READONLY_ARG:
1570 case ICMD_READONLY_ARG+1:
1571 case ICMD_READONLY_ARG+2:
1572 case ICMD_READONLY_ARG+3:
1573 case ICMD_READONLY_ARG+4:
1575 if (curstack->varkind == LOCALVAR) {
1576 i = curstack->varnum;
1577 argren[iptr->op1] = i;
1580 opcode = iptr->opc = opcode - ICMD_READONLY_ARG + ICMD_ISTORE;
1586 printf("ICMD %d at %d\n", iptr->opc, (int)(iptr-instr));
1587 panic("Missing ICMD code during stack analysis");
1590 } /* while instructions */
1591 bptr->outstack = curstack;
1592 bptr->outdepth = stackdepth;
1596 superblockend = true;
1598 } /* while blocks */
1599 } while (repeat && ! deadcode);
1602 if (block_count > count_max_basic_blocks)
1603 count_max_basic_blocks = block_count;
1604 count_basic_blocks += block_count;
1605 if (instr_count > count_max_javainstr)
1606 count_max_javainstr = instr_count;
1607 count_javainstr += instr_count;
1608 if (stack_count > count_upper_bound_new_stack)
1609 count_upper_bound_new_stack = stack_count;
1610 if ((new - stack) > count_max_new_stack)
1611 count_max_new_stack = (new - stack);
1613 b_count = block_count;
1615 while (--b_count >= 0) {
1616 if (bptr->flags > BBREACHED) {
1617 if (bptr->indepth >= 10)
1618 count_block_stack[10]++;
1620 count_block_stack[bptr->indepth]++;
1623 count_block_size_distribution[len]++;
1625 count_block_size_distribution[10]++;
1627 count_block_size_distribution[11]++;
1629 count_block_size_distribution[12]++;
1631 count_block_size_distribution[13]++;
1633 count_block_size_distribution[14]++;
1635 count_block_size_distribution[15]++;
1637 count_block_size_distribution[16]++;
1639 count_block_size_distribution[17]++;
1645 count_analyse_iterations[0]++;
1646 else if (loops == 2)
1647 count_analyse_iterations[1]++;
1648 else if (loops == 3)
1649 count_analyse_iterations[2]++;
1650 else if (loops == 4)
1651 count_analyse_iterations[3]++;
1653 count_analyse_iterations[4]++;
1655 if (block_count <= 5)
1656 count_method_bb_distribution[0]++;
1657 else if (block_count <= 10)
1658 count_method_bb_distribution[1]++;
1659 else if (block_count <= 15)
1660 count_method_bb_distribution[2]++;
1661 else if (block_count <= 20)
1662 count_method_bb_distribution[3]++;
1663 else if (block_count <= 30)
1664 count_method_bb_distribution[4]++;
1665 else if (block_count <= 40)
1666 count_method_bb_distribution[5]++;
1667 else if (block_count <= 50)
1668 count_method_bb_distribution[6]++;
1669 else if (block_count <= 75)
1670 count_method_bb_distribution[7]++;
1672 count_method_bb_distribution[8]++;
1677 static void print_stack(stackptr s) {
1693 if (s->flags & SAVEDVAR)
1694 switch (s->varkind) {
1696 if (s->flags & INMEMORY)
1697 printf(" M%02d", s->regoff);
1698 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1699 printf(" F%02d", s->regoff);
1701 printf(" %3s", regs[s->regoff]);
1704 printf(" I%02d", s->varnum);
1707 printf(" L%02d", s->varnum);
1710 printf(" A%02d", s->varnum);
1713 printf(" !%02d", j);
1716 switch (s->varkind) {
1718 if (s->flags & INMEMORY)
1719 printf(" m%02d", s->regoff);
1720 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1721 printf(" f%02d", s->regoff);
1723 printf(" %3s", regs[s->regoff]);
1726 printf(" i%02d", s->varnum);
1729 printf(" l%02d", s->varnum);
1732 printf(" a%02d", s->varnum);
1735 printf(" ?%02d", j);
1743 static void print_reg(stackptr s) {
1745 if (s->flags & SAVEDVAR)
1746 switch (s->varkind) {
1748 if (s->flags & INMEMORY)
1749 printf(" tm%02d", s->regoff);
1751 printf(" tr%02d", s->regoff);
1754 printf(" s %02d", s->varnum);
1757 printf(" l %02d", s->varnum);
1760 printf(" a %02d", s->varnum);
1763 printf(" ! %02d", s->varnum);
1766 switch (s->varkind) {
1768 if (s->flags & INMEMORY)
1769 printf(" Tm%02d", s->regoff);
1771 printf(" Tr%02d", s->regoff);
1774 printf(" S %02d", s->varnum);
1777 printf(" L %02d", s->varnum);
1780 printf(" A %02d", s->varnum);
1783 printf(" ? %02d", s->varnum);
1793 static char *builtin_name(functionptr bptr)
1795 builtin_descriptor *bdesc = builtin_desc;
1796 while ((bdesc->bptr != NULL) && (bdesc->bptr != bptr))
1802 static char *jit_type[] = {
1811 static void show_icmd_method()
1822 utf_fprint(stdout, class->name);
1824 utf_fprint(stdout, method->name);
1826 utf_fprint(stdout, method->descriptor);
1827 printf ("\n\nMax locals: %d\n", (int) maxlocals);
1828 printf ("Max stack: %d\n", (int) maxstack);
1830 printf ("Exceptions (Number: %d):\n", exceptiontablelength);
1831 for (ex = extable; ex != NULL; ex = ex->down) {
1832 printf(" L%03d ... ", ex->start->debug_nr );
1833 printf("L%03d = ", ex->end->debug_nr);
1834 printf("L%03d\n", ex->handler->debug_nr);
1837 printf ("Local Table:\n");
1838 for (i = 0; i < maxlocals; i++) {
1839 printf(" %3d: ", i);
1840 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1841 if (locals[i][j].type >= 0) {
1842 printf(" (%s) ", jit_type[j]);
1843 if (locals[i][j].flags & INMEMORY)
1844 printf("m%2d", locals[i][j].regoff);
1845 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1846 printf("f%02d", locals[i][j].regoff);
1848 printf("%3s", regs[locals[i][j].regoff]);
1854 printf ("Interface Table:\n");
1855 for (i = 0; i < maxstack; i++) {
1856 if ((interfaces[i][0].type >= 0) || (interfaces[i][1].type >= 0) ||
1857 (interfaces[i][2].type >= 0) || (interfaces[i][3].type >= 0) ||
1858 (interfaces[i][4].type >= 0)) {
1859 printf(" %3d: ", i);
1860 for (j = TYPE_INT; j <= TYPE_ADR; j++)
1861 if (interfaces[i][j].type >= 0) {
1862 printf(" (%s) ", jit_type[j]);
1863 if (interfaces[i][j].flags & SAVEDVAR) {
1864 if (interfaces[i][j].flags & INMEMORY)
1865 printf("M%2d", interfaces[i][j].regoff);
1866 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1867 printf("F%02d", interfaces[i][j].regoff);
1869 printf("%3s", regs[interfaces[i][j].regoff]);
1872 if (interfaces[i][j].flags & INMEMORY)
1873 printf("m%2d", interfaces[i][j].regoff);
1874 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
1875 printf("f%02d", interfaces[i][j].regoff);
1877 printf("%3s", regs[interfaces[i][j].regoff]);
1885 if (showdisassemble) {
1886 #if defined(__I386__) || defined(__X86_64__)
1887 /* extern u1 *codestatic; */
1888 /* extern int pstatic; */
1891 u1ptr = method->mcode + dseglen;
1892 for (i = 0; i < block[0].mpc; i++, u1ptr++) {
1893 disassinstr(u1ptr, i);
1899 s4ptr = (s4 *) (method->mcode + dseglen);
1900 for (i = 0; i < block[0].mpc; i += 4, s4ptr++) {
1901 disassinstr(*s4ptr, i);
1908 for (bptr = block; bptr != NULL; bptr = bptr->next)
1909 if (bptr->flags != BBDELETED) {
1910 deadcode = bptr->flags <= BBREACHED;
1913 for (j = maxstack; j > 0; j--)
1916 print_stack(bptr->instack);
1917 printf("] L%03d(%d - %d):\n", bptr->debug_nr, bptr->icount, bptr->pre_count);
1918 iptr = bptr->iinstr;
1920 for (i=0; i < bptr->icount; i++, iptr++) {
1923 for (j = maxstack; j > 0; j--)
1927 print_stack(iptr->dst);
1928 printf("] %4d %s", i, icmd_names[iptr->opc]);
1929 switch ((int) iptr->opc) {
1930 case ICMD_IADDCONST:
1931 case ICMD_ISUBCONST:
1932 case ICMD_IMULCONST:
1935 case ICMD_IREM0X10001:
1936 case ICMD_IANDCONST:
1938 case ICMD_IXORCONST:
1939 case ICMD_ISHLCONST:
1940 case ICMD_ISHRCONST:
1941 case ICMD_IUSHRCONST:
1942 case ICMD_LSHLCONST:
1943 case ICMD_LSHRCONST:
1944 case ICMD_LUSHRCONST:
1946 case ICMD_ELSE_ICONST:
1947 case ICMD_IFEQ_ICONST:
1948 case ICMD_IFNE_ICONST:
1949 case ICMD_IFLT_ICONST:
1950 case ICMD_IFGE_ICONST:
1951 case ICMD_IFGT_ICONST:
1952 case ICMD_IFLE_ICONST:
1953 printf(" %d", iptr->val.i);
1955 case ICMD_LADDCONST:
1956 case ICMD_LSUBCONST:
1957 case ICMD_LMULCONST:
1960 case ICMD_LANDCONST:
1962 case ICMD_LXORCONST:
1964 #if defined(__I386__)
1965 printf(" %lld", iptr->val.l);
1967 printf(" %ld", iptr->val.l);
1971 printf(" %f", iptr->val.f);
1974 printf(" %f", iptr->val.d);
1977 printf(" %p", iptr->val.a);
1981 printf(" %d,", ((fieldinfo *) iptr->val.a)->offset);
1982 case ICMD_PUTSTATIC:
1983 case ICMD_GETSTATIC:
1986 ((fieldinfo *) iptr->val.a)->name);
1989 printf(" %d + %d", iptr->op1, iptr->val.i);
2024 printf(" %d", iptr->op1);
2029 ((classinfo *) iptr->val.a)->name);
2032 switch (iptr->op1) {
2059 case ICMD_ANEWARRAY:
2063 ((classinfo *) iptr->val.a)->name);
2066 case ICMD_CHECKCAST:
2067 case ICMD_INSTANCEOF:
2069 classinfo *c = iptr->val.a;
2070 if (c->flags & ACC_INTERFACE)
2071 printf(" (INTERFACE) ");
2073 printf(" (CLASS,%3d) ", c->vftbl->diffval);
2074 utf_fprint(stdout, c->name);
2080 printf(" %s", builtin_name((functionptr) iptr->val.a));
2082 case ICMD_INVOKEVIRTUAL:
2083 case ICMD_INVOKESPECIAL:
2084 case ICMD_INVOKESTATIC:
2085 case ICMD_INVOKEINTERFACE:
2088 ((methodinfo *) iptr->val.a)->class->name);
2091 ((methodinfo *) iptr->val.a)->name);
2099 printf("(%d) L%03d", iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
2107 printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
2112 case ICMD_IFNONNULL:
2113 case ICMD_IF_ICMPEQ:
2114 case ICMD_IF_ICMPNE:
2115 case ICMD_IF_ICMPLT:
2116 case ICMD_IF_ICMPGE:
2117 case ICMD_IF_ICMPGT:
2118 case ICMD_IF_ICMPLE:
2119 case ICMD_IF_LCMPEQ:
2120 case ICMD_IF_LCMPNE:
2121 case ICMD_IF_LCMPLT:
2122 case ICMD_IF_LCMPGE:
2123 case ICMD_IF_LCMPGT:
2124 case ICMD_IF_LCMPLE:
2125 case ICMD_IF_ACMPEQ:
2126 case ICMD_IF_ACMPNE:
2127 printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
2129 case ICMD_TABLESWITCH:
2131 s4ptr = iptr->val.a;
2132 tptr = (void **) iptr->target;
2134 printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
2140 j = *s4ptr++; /* low */
2141 j = *s4ptr++ - j; /* high */
2143 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2148 case ICMD_LOOKUPSWITCH:
2149 s4ptr = iptr->val.a;
2150 tptr = (void **) iptr->target;
2152 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2153 s4ptr++; /* default */
2154 j = *s4ptr; /* count */
2158 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2166 if (showdisassemble && (!deadcode)) {
2167 #if defined(__I386__) || defined(__X86_64__)
2168 /* extern u1 *codestatic; */
2169 /* extern int pstatic; */
2174 u1ptr = method->mcode + dseglen + i;
2176 if (bptr->next != NULL) {
2177 for (; i < bptr->next->mpc; i++, u1ptr++) {
2178 disassinstr(u1ptr, i);
2185 for (; u1ptr < (u1 *) (method->mcode + method->mcodelength); i++, u1ptr++) {
2186 disassinstr(u1ptr, i);
2195 s4ptr = (s4 *) (method->mcode + dseglen + i);
2197 if (bptr->next != NULL) {
2198 for (; i < bptr->next->mpc; i += 4, s4ptr++) {
2199 disassinstr(*s4ptr, i);
2204 for (; s4ptr < (s4 *) (method->mcode + method->mcodelength); i += 4, s4ptr++) {
2205 disassinstr(*s4ptr, i);
2215 s4ptr = (s4 *) (method->mcode + dseglen + i);
2216 if (showdisassemble && (s4ptr < (s4 *) (method->mcode + method->mcodelength))) {
2218 for (; s4ptr < (s4 *) (method->mcode + method->mcodelength); i += 4, s4ptr++) {
2219 disassinstr(*s4ptr, i);
2228 * These are local overrides for various environment variables in Emacs.
2229 * Please do not remove this and leave it at the end of the file, where
2230 * Emacs will automagically detect them.
2231 * ---------------------------------------------------------------------
2234 * indent-tabs-mode: t