comments and better error messages
[cacao.git] / src / vm / jit / stack.c
1 /* jit/stack.c - stack analysis
2
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
7
8    This file is part of CACAO.
9
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.
14
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.
19
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
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Andreas Krall
28
29    Changes: Edwin Steiner
30
31    $Id: stack.c 803 2003-12-17 14:11:00Z edwin $
32
33 */
34
35
36 #include <stdio.h>
37 #include <string.h>
38 #include "stack.h"
39 #include "global.h"
40 #include "jit.h"
41 #include "builtin.h"
42 #include "disass.h"
43 #include "reg.h"
44 #include "tables.h"
45 #include "types.h"
46 #include "toolbox/loging.h"
47 #include "toolbox/memory.h"
48
49
50 /* from codegen.inc */
51 extern int dseglen;
52
53 /**********************************************************************/
54 /* Macros used internally by analyse_stack                            */
55 /**********************************************************************/
56
57 #ifdef STATISTICS
58 #define COUNT(cnt) cnt++
59 #else
60 #define COUNT(cnt)
61 #endif
62  
63 /* convenient abbreviations */
64 #define CURKIND    curstack->varkind
65 #define CURTYPE    curstack->type
66
67 /*--------------------------------------------------*/
68 /* SIGNALING ERRORS                                 */
69 /*--------------------------------------------------*/
70
71 #define TYPEPANIC  {show_icmd_method();panic("Stack type mismatch");}
72 #define UNDERFLOW  {show_icmd_method();panic("Operand stack underflow");}
73 #define OVERFLOW   {show_icmd_method();panic("Operand stack overflow");}
74
75 /*--------------------------------------------------*/
76 /* STACK UNDERFLOW/OVERFLOW CHECKS                  */
77 /*--------------------------------------------------*/
78
79 /* underflow checks */
80 #define REQUIRE(num)  do { if (stackdepth<(num)) {UNDERFLOW;} } while(0)
81 #define REQUIRE_1     REQUIRE(1)
82 #define REQUIRE_2     REQUIRE(2)
83 #define REQUIRE_3     REQUIRE(3)
84 #define REQUIRE_4     REQUIRE(4)
85
86 /* overflow check */
87 /* XXX we allow ACONST to exceed the maximum stack depth because it is
88  * generated for builtin calls. Maybe we should check against maximum
89  * stack depth only at block boundaries?
90  */
91 #define CHECKOVERFLOW                                                   \
92         do {                                                                            \
93                 if (stackdepth > maxstack) {                    \
94                         if (iptr[0].opc != ICMD_ACONST)         \
95                         {OVERFLOW;}                                                     \
96                 }                                                                               \
97         } while(0)
98
99 /*--------------------------------------------------*/
100 /* ALLOCATING STACK SLOTS                           */
101 /*--------------------------------------------------*/
102
103 #define NEWSTACK(s,v,n) {new->prev=curstack;new->type=s;new->flags=0;   \
104                         new->varkind=v;new->varnum=n;curstack=new;new++;}
105 #define NEWSTACKn(s,n)  NEWSTACK(s,UNDEFVAR,n)
106 #define NEWSTACK0(s)    NEWSTACK(s,UNDEFVAR,0)
107
108 /* allocate the input stack for an exception handler */
109 #define NEWXSTACK   {NEWSTACK(TYPE_ADR,STACKVAR,0);curstack=0;}
110
111 /*--------------------------------------------------*/
112 /* STACK MANIPULATION                               */
113 /*--------------------------------------------------*/
114
115 /* resetting to an empty operand stack */
116 #define STACKRESET {curstack=0;stackdepth=0;}
117
118 /* set the output stack of the current instruction */
119 #define SETDST      {iptr->dst=curstack;}
120
121 /* The following macros do NOT check stackdepth, set stackdepth or iptr->dst */
122 #define POP(s)      {if(s!=curstack->type){TYPEPANIC;}                                                                          \
123                      if(curstack->varkind==UNDEFVAR)curstack->varkind=TEMPVAR;\
124                      curstack=curstack->prev;}
125 #define POPANY      {if(curstack->varkind==UNDEFVAR)curstack->varkind=TEMPVAR;  \
126                      curstack=curstack->prev;}
127 #define COPY(s,d)   {(d)->flags=0;(d)->type=(s)->type;\
128                      (d)->varkind=(s)->varkind;(d)->varnum=(s)->varnum;}
129
130 /*--------------------------------------------------*/
131 /* STACK OPERATIONS MODELING                        */
132 /*--------------------------------------------------*/
133
134 /* The following macros are used to model the stack manipulations of
135  * different kinds of instructions.
136  *
137  * These macros check the input stackdepth and they set the output
138  * stackdepth and the output stack of the instruction (iptr->dst).
139  */
140    
141 #define PUSHCONST(s){NEWSTACKn(s,stackdepth);SETDST;stackdepth++;}
142 #define LOAD(s,v,n) {NEWSTACK(s,v,n);SETDST;stackdepth++;}
143 #define STORE(s)    {REQUIRE_1;POP(s);SETDST;stackdepth--;}
144 #define OP1_0(s)    {REQUIRE_1;POP(s);SETDST;stackdepth--;}
145 #define OP1_0ANY    {REQUIRE_1;POPANY;SETDST;stackdepth--;}
146 #define OP0_1(s)    {NEWSTACKn(s,stackdepth);SETDST;stackdepth++;}
147 #define OP1_1(s,d)  {REQUIRE_1;POP(s);NEWSTACKn(d,stackdepth-1);SETDST;}
148 #define OP2_0(s)    {REQUIRE_2;POP(s);POP(s);SETDST;stackdepth-=2;}
149 #define OPTT2_0(t,b){REQUIRE_2;POP(t);POP(b);SETDST;stackdepth-=2;}
150 #define OP2_1(s)    {REQUIRE_2;POP(s);POP(s);NEWSTACKn(s,stackdepth-2);SETDST;stackdepth--;}
151 #define OP2IAT_1(s) {REQUIRE_2;POP(TYPE_INT);POP(TYPE_ADR);NEWSTACKn(s,stackdepth-2);\
152                      SETDST;stackdepth--;}
153 #define OP2IT_1(s)  {REQUIRE_2;POP(TYPE_INT);POP(s);NEWSTACKn(s,stackdepth-2);\
154                      SETDST;stackdepth--;}
155 #define OPTT2_1(s,d){REQUIRE_2;POP(s);POP(s);NEWSTACKn(d,stackdepth-2);SETDST;stackdepth--;}
156 #define OP2_2(s)    {REQUIRE_2;POP(s);POP(s);NEWSTACKn(s,stackdepth-2);\
157                      NEWSTACKn(s,stackdepth-1);SETDST;}
158 #define OP3TIA_0(s) {REQUIRE_3;POP(s);POP(TYPE_INT);POP(TYPE_ADR);SETDST;stackdepth-=3;}
159 #define OP3_0(s)    {REQUIRE_3;POP(s);POP(s);POP(s);SETDST;stackdepth-=3;}
160 #define POPMANY(i)  {REQUIRE(i);stackdepth-=i;while(--i>=0){POPANY;}SETDST;}
161 #define DUP         {REQUIRE_1;NEWSTACK(CURTYPE,CURKIND,curstack->varnum);SETDST; \
162                     stackdepth++;}
163 #define SWAP        {REQUIRE_2;COPY(curstack,new);POPANY;COPY(curstack,new+1);POPANY;\
164                     new[0].prev=curstack;new[1].prev=new;\
165                     curstack=new+1;new+=2;SETDST;}
166 #define DUP_X1      {REQUIRE_2;COPY(curstack,new);COPY(curstack,new+2);POPANY;\
167                     COPY(curstack,new+1);POPANY;new[0].prev=curstack;\
168                     new[1].prev=new;new[2].prev=new+1;\
169                     curstack=new+2;new+=3;SETDST;stackdepth++;}
170 #define DUP2_X1     {REQUIRE_3;COPY(curstack,new+1);COPY(curstack,new+4);POPANY;\
171                     COPY(curstack,new);COPY(curstack,new+3);POPANY;\
172                     COPY(curstack,new+2);POPANY;new[0].prev=curstack;\
173                     new[1].prev=new;new[2].prev=new+1;\
174                     new[3].prev=new+2;new[4].prev=new+3;\
175                     curstack=new+4;new+=5;SETDST;stackdepth+=2;}
176 #define DUP_X2      {REQUIRE_3;COPY(curstack,new);COPY(curstack,new+3);POPANY;\
177                     COPY(curstack,new+2);POPANY;COPY(curstack,new+1);POPANY;\
178                     new[0].prev=curstack;new[1].prev=new;\
179                     new[2].prev=new+1;new[3].prev=new+2;\
180                     curstack=new+3;new+=4;SETDST;stackdepth++;}
181 #define DUP2_X2     {REQUIRE_4;COPY(curstack,new+1);COPY(curstack,new+5);POPANY;\
182                     COPY(curstack,new);COPY(curstack,new+4);POPANY;\
183                     COPY(curstack,new+3);POPANY;COPY(curstack,new+2);POPANY;\
184                     new[0].prev=curstack;new[1].prev=new;\
185                     new[2].prev=new+1;new[3].prev=new+2;\
186                     new[4].prev=new+3;new[5].prev=new+4;\
187                     curstack=new+5;new+=6;SETDST;stackdepth+=2;}
188 /******************************/
189
190 /* COPYCURSTACK makes a copy of the current operand stack (curstack)
191  * and returns it in the variable copy.
192  *
193  * This macro is used to propagate the operand stack from one basic
194  * block to another. The destination block receives the copy as its
195  * input stack.
196  */
197 #define COPYCURSTACK(copy) {\
198         int d;\
199         stackptr s;\
200         if(curstack){\
201                 s=curstack;\
202                 new+=stackdepth;\
203                 d=stackdepth;\
204                 copy=new;\
205                 while(s){\
206                         copy--;d--;\
207                         copy->prev=copy-1;\
208                         copy->type=s->type;\
209                         copy->flags=0;\
210                         copy->varkind=STACKVAR;\
211                         copy->varnum=d;\
212                         s=s->prev;\
213                         }\
214                 copy->prev=NULL;\
215                 copy=new-1;\
216                 }\
217         else\
218                 copy=NULL;\
219 }
220
221
222 #define BBEND(s,i){\
223         i=stackdepth-1;\
224         copy=s;\
225         while(copy){\
226                 if((copy->varkind==STACKVAR)&&(copy->varnum>i))\
227                         copy->varkind=TEMPVAR;\
228                 else {\
229                         copy->varkind=STACKVAR;\
230                         copy->varnum=i;\
231                         }\
232                 interfaces[i][copy->type].type = copy->type;\
233                 interfaces[i][copy->type].flags |= copy->flags;\
234                 i--;copy=copy->prev;\
235                 }\
236         i=bptr->indepth-1;\
237         copy=bptr->instack;\
238         while(copy){\
239                 interfaces[i][copy->type].type = copy->type;\
240                 if(copy->varkind==STACKVAR){\
241                         if (copy->flags & SAVEDVAR)\
242                                 interfaces[i][copy->type].flags |= SAVEDVAR;\
243                         }\
244                 i--;copy=copy->prev;\
245                 }\
246 }
247
248
249 /* MARKREACHED marks the destination block <b> as reached. If this
250  * block has been reached before we check if stack depth and types
251  * match. Otherwise the destination block receives a copy of the
252  * current stack as its input stack.
253  *
254  * b...destination block
255  * c...current stack
256  */
257 #define MARKREACHED(b,c) {                                                                                              \
258         if(b->flags<0)                                                                                                          \
259                 {COPYCURSTACK(c);b->flags=0;b->instack=c;b->indepth=stackdepth;} \
260         else {stackptr s=curstack;stackptr t=b->instack;                                        \
261                 if(b->indepth!=stackdepth)                                                                              \
262                         {show_icmd_method();panic("Stack depth mismatch");}                     \
263                 while(s){if (s->type!=t->type)                                                                  \
264                                 TYPEPANIC                                                                                               \
265                         s=s->prev;t=t->prev;                                                                            \
266                         }                                                                                                                       \
267                 }                                                                                                                               \
268 }
269
270
271 void analyse_stack()
272 {
273         int b_count;
274         int b_index;
275         int stackdepth;
276         stackptr curstack;
277         stackptr new;
278         stackptr copy;
279         int opcode, i, len, loops;
280         int superblockend, repeat, deadcode;
281         instruction *iptr;
282         basicblock *bptr;
283         basicblock *tbptr;
284         s4 *s4ptr;
285         void* *tptr;
286         int *argren;
287
288         if (compileverbose) {
289                 char logtext[MAXLOGTEXT];
290                 sprintf(logtext, "Analysing: ");
291                 utf_sprint(logtext+strlen(logtext), method->class->name);
292                 strcpy(logtext+strlen(logtext), ".");
293                 utf_sprint(logtext+strlen(logtext), method->name);
294                 utf_sprint(logtext+strlen(logtext), method->descriptor);
295                 log_text(logtext);
296         }
297
298         argren = DMNEW(int, maxlocals);
299         /*int *argren = (int *)alloca(maxlocals * sizeof(int));*/ /* table for argument renaming */
300         for (i = 0; i < maxlocals; i++)
301                 argren[i] = i;
302         
303         arguments_num = 0;
304         new = stack;
305         loops = 0;
306         block[0].flags = BBREACHED;
307         block[0].instack = 0;
308         block[0].indepth = 0;
309
310         for (i = 0; i < exceptiontablelength; i++) {
311                 bptr = &block[block_index[extable[i].handlerpc]];
312                 bptr->flags = BBREACHED;
313                 bptr->type = BBTYPE_EXH;
314                 bptr->instack = new;
315                 bptr->indepth = 1;
316                 bptr->pre_count = 10000;
317                 STACKRESET;
318                 NEWXSTACK;
319         }
320
321 #ifdef CONDITIONAL_LOADCONST
322         b_count = block_count;
323         bptr = block;
324         while (--b_count >= 0) {
325                 if (bptr->icount != 0) {
326                         iptr = bptr->iinstr + bptr->icount - 1;
327                         switch (iptr->opc) {
328                         case ICMD_RET:
329                         case ICMD_RETURN:
330                         case ICMD_IRETURN:
331                         case ICMD_LRETURN:
332                         case ICMD_FRETURN:
333                         case ICMD_DRETURN:
334                         case ICMD_ARETURN:
335                         case ICMD_ATHROW:
336                                 break;
337
338                         case ICMD_IFEQ:
339                         case ICMD_IFNE:
340                         case ICMD_IFLT:
341                         case ICMD_IFGE:
342                         case ICMD_IFGT:
343                         case ICMD_IFLE:
344
345                         case ICMD_IFNULL:
346                         case ICMD_IFNONNULL:
347
348                         case ICMD_IF_ICMPEQ:
349                         case ICMD_IF_ICMPNE:
350                         case ICMD_IF_ICMPLT:
351                         case ICMD_IF_ICMPGE:
352                         case ICMD_IF_ICMPGT:
353                         case ICMD_IF_ICMPLE:
354
355                         case ICMD_IF_ACMPEQ:
356                         case ICMD_IF_ACMPNE:
357                                 bptr[1].pre_count++;
358                         case ICMD_GOTO:
359                                 block[block_index[iptr->op1]].pre_count++;
360                                 break;
361
362                         case ICMD_TABLESWITCH:
363                                 s4ptr = iptr->val.a;
364                                 block[block_index[*s4ptr++]].pre_count++;   /* default */
365                                 i = *s4ptr++;                               /* low     */
366                                 i = *s4ptr++ - i + 1;                       /* high    */
367                                 while (--i >= 0) {
368                                         block[block_index[*s4ptr++]].pre_count++;
369                                 }
370                                 break;
371                                         
372                         case ICMD_LOOKUPSWITCH:
373                                 s4ptr = iptr->val.a;
374                                 block[block_index[*s4ptr++]].pre_count++;   /* default */
375                                 i = *s4ptr++;                               /* count   */
376                                 while (--i >= 0) {
377                                         block[block_index[s4ptr[1]]].pre_count++;
378                                         s4ptr += 2;
379                                 }
380                                 break;
381                         default:
382                                 bptr[1].pre_count++;
383                                 break;
384                         }
385                 }
386                 bptr++;
387         }
388 #endif
389
390
391         do {
392                 loops++;
393                 b_count = block_count;
394                 bptr = block;
395                 superblockend = true;
396                 repeat = false;
397                 STACKRESET;
398                 deadcode = true;
399                 while (--b_count >= 0) {
400                         if (bptr->flags == BBDELETED) {
401                                 /* do nothing */
402                         }
403                         else if (superblockend && (bptr->flags < BBREACHED))
404                                 repeat = true;
405                         else if (bptr->flags <= BBREACHED) {
406                                 if (superblockend)
407                                         stackdepth = bptr->indepth;
408                                 else if (bptr->flags < BBREACHED) {
409                                         COPYCURSTACK(copy);
410                                         bptr->instack = copy;
411                                         bptr->indepth = stackdepth;
412                                 }
413                                 else if (bptr->indepth != stackdepth) {
414                                         show_icmd_method();
415                                         panic("Stack depth mismatch");
416                                         
417                                 }
418                                 curstack = bptr->instack;
419                                 deadcode = false;
420                                 superblockend = false;
421                                 bptr->flags = BBFINISHED;
422                                 len = bptr->icount;
423                                 iptr = bptr->iinstr;
424                                 b_index = bptr - block;
425                                 while (--len >= 0)  {
426                                         opcode = iptr->opc;
427                                         iptr->target = NULL;
428
429                                         /* DEBUG XXX */ /*  dolog("p:%04d op: %s",iptr-instr,icmd_names[opcode]); */
430
431 #ifdef USEBUILTINTABLE
432                                         {
433 #if 0
434                                                 stdopdescriptor *breplace;
435                                                 breplace = find_builtin(opcode);
436
437                                                 if (breplace && opcode == breplace->opcode) {
438                                                         iptr[0].opc = breplace->icmd;
439                                                         iptr[0].op1 = breplace->type_d;
440                                                         iptr[0].val.a = breplace->builtin;
441                                                         isleafmethod = false;
442                                                         switch (breplace->icmd) {
443                                                         case ICMD_BUILTIN1:
444                                                                 goto builtin1;
445                                                         case ICMD_BUILTIN2:
446                                                                 goto builtin2;
447                                                         }
448                                                 }
449 #endif
450                                                 builtin_descriptor *breplace;
451                                                 breplace = find_builtin(opcode);
452
453                                                 if (breplace && opcode == breplace->opcode) {
454                                                         iptr[0].opc = breplace->icmd;
455                                                         iptr[0].op1 = breplace->type_d;
456                                                         iptr[0].val.a = breplace->builtin;
457                                                         isleafmethod = false;
458                                                         switch (breplace->icmd) {
459                                                         case ICMD_BUILTIN1:
460                                                                 goto builtin1;
461                                                         case ICMD_BUILTIN2:
462                                                                 goto builtin2;
463                                                         }
464                                                 }
465                                         }
466 #endif
467                                         
468                                         switch (opcode) {
469
470                                                 /* pop 0 push 0 */
471
472                                         case ICMD_NOP:
473                                         case ICMD_CHECKASIZE:
474
475                                         case ICMD_IFEQ_ICONST:
476                                         case ICMD_IFNE_ICONST:
477                                         case ICMD_IFLT_ICONST:
478                                         case ICMD_IFGE_ICONST:
479                                         case ICMD_IFGT_ICONST:
480                                         case ICMD_IFLE_ICONST:
481                                         case ICMD_ELSE_ICONST:
482                                                 SETDST;
483                                                 break;
484
485                                         case ICMD_RET:
486                                                 locals[iptr->op1][TYPE_ADR].type = TYPE_ADR;
487                                         case ICMD_RETURN:
488                                                 COUNT(count_pcmd_return);
489                                                 SETDST;
490                                                 superblockend = true;
491                                                 break;
492
493                                                 /* pop 0 push 1 const */
494                                                 
495                                         case ICMD_ICONST:
496                                                 COUNT(count_pcmd_load);
497                                                 if (len > 0) {
498                                                         switch (iptr[1].opc) {
499                                                         case ICMD_IADD:
500                                                                 iptr[0].opc = ICMD_IADDCONST;
501                                                         icmd_iconst_tail:
502                                                                 iptr[1].opc = ICMD_NOP;
503                                                                 OP1_1(TYPE_INT,TYPE_INT);
504                                                                 COUNT(count_pcmd_op);
505                                                                 break;
506                                                         case ICMD_ISUB:
507                                                                 iptr[0].opc = ICMD_ISUBCONST;
508                                                                 goto icmd_iconst_tail;
509                                                         case ICMD_IMUL:
510                                                                 iptr[0].opc = ICMD_IMULCONST;
511                                                                 goto icmd_iconst_tail;
512                                                         case ICMD_IDIV:
513                                                                 if (iptr[0].val.i == 0x00000002)
514                                                                         iptr[0].val.i = 1;
515                                                                 else if (iptr[0].val.i == 0x00000004)
516                                                                         iptr[0].val.i = 2;
517                                                                 else if (iptr[0].val.i == 0x00000008)
518                                                                         iptr[0].val.i = 3;
519                                                                 else if (iptr[0].val.i == 0x00000010)
520                                                                         iptr[0].val.i = 4;
521                                                                 else if (iptr[0].val.i == 0x00000020)
522                                                                         iptr[0].val.i = 5;
523                                                                 else if (iptr[0].val.i == 0x00000040)
524                                                                         iptr[0].val.i = 6;
525                                                                 else if (iptr[0].val.i == 0x00000080)
526                                                                         iptr[0].val.i = 7;
527                                                                 else if (iptr[0].val.i == 0x00000100)
528                                                                         iptr[0].val.i = 8;
529                                                                 else if (iptr[0].val.i == 0x00000200)
530                                                                         iptr[0].val.i = 9;
531                                                                 else if (iptr[0].val.i == 0x00000400)
532                                                                         iptr[0].val.i = 10;
533                                                                 else if (iptr[0].val.i == 0x00000800)
534                                                                         iptr[0].val.i = 11;
535                                                                 else if (iptr[0].val.i == 0x00001000)
536                                                                         iptr[0].val.i = 12;
537                                                                 else if (iptr[0].val.i == 0x00002000)
538                                                                         iptr[0].val.i = 13;
539                                                                 else if (iptr[0].val.i == 0x00004000)
540                                                                         iptr[0].val.i = 14;
541                                                                 else if (iptr[0].val.i == 0x00008000)
542                                                                         iptr[0].val.i = 15;
543                                                                 else if (iptr[0].val.i == 0x00010000)
544                                                                         iptr[0].val.i = 16;
545                                                                 else if (iptr[0].val.i == 0x00020000)
546                                                                         iptr[0].val.i = 17;
547                                                                 else if (iptr[0].val.i == 0x00040000)
548                                                                         iptr[0].val.i = 18;
549                                                                 else if (iptr[0].val.i == 0x00080000)
550                                                                         iptr[0].val.i = 19;
551                                                                 else if (iptr[0].val.i == 0x00100000)
552                                                                         iptr[0].val.i = 20;
553                                                                 else if (iptr[0].val.i == 0x00200000)
554                                                                         iptr[0].val.i = 21;
555                                                                 else if (iptr[0].val.i == 0x00400000)
556                                                                         iptr[0].val.i = 22;
557                                                                 else if (iptr[0].val.i == 0x00800000)
558                                                                         iptr[0].val.i = 23;
559                                                                 else if (iptr[0].val.i == 0x01000000)
560                                                                         iptr[0].val.i = 24;
561                                                                 else if (iptr[0].val.i == 0x02000000)
562                                                                         iptr[0].val.i = 25;
563                                                                 else if (iptr[0].val.i == 0x04000000)
564                                                                         iptr[0].val.i = 26;
565                                                                 else if (iptr[0].val.i == 0x08000000)
566                                                                         iptr[0].val.i = 27;
567                                                                 else if (iptr[0].val.i == 0x10000000)
568                                                                         iptr[0].val.i = 28;
569                                                                 else if (iptr[0].val.i == 0x20000000)
570                                                                         iptr[0].val.i = 29;
571                                                                 else if (iptr[0].val.i == 0x40000000)
572                                                                         iptr[0].val.i = 30;
573                                                                 else if (iptr[0].val.i == 0x80000000)
574                                                                         iptr[0].val.i = 31;
575                                                                 else {
576                                                                         PUSHCONST(TYPE_INT);
577                                                                         break;
578                                                                 }
579                                                                 iptr[0].opc = ICMD_IDIVPOW2;
580                                                                 goto icmd_iconst_tail;
581                                                         case ICMD_IREM:
582 #if !defined(NO_DIV_OPT)
583                                                                 if (iptr[0].val.i == 0x10001) {
584                                                                         iptr[0].opc = ICMD_IREM0X10001;
585                                                                         goto icmd_iconst_tail;
586                                                                 }
587 #endif
588                                                                 if ((iptr[0].val.i == 0x00000002) ||
589                                                                         (iptr[0].val.i == 0x00000004) ||
590                                                                         (iptr[0].val.i == 0x00000008) ||
591                                                                         (iptr[0].val.i == 0x00000010) ||
592                                                                         (iptr[0].val.i == 0x00000020) ||
593                                                                         (iptr[0].val.i == 0x00000040) ||
594                                                                         (iptr[0].val.i == 0x00000080) ||
595                                                                         (iptr[0].val.i == 0x00000100) ||
596                                                                         (iptr[0].val.i == 0x00000200) ||
597                                                                         (iptr[0].val.i == 0x00000400) ||
598                                                                         (iptr[0].val.i == 0x00000800) ||
599                                                                         (iptr[0].val.i == 0x00001000) ||
600                                                                         (iptr[0].val.i == 0x00002000) ||
601                                                                         (iptr[0].val.i == 0x00004000) ||
602                                                                         (iptr[0].val.i == 0x00008000) ||
603                                                                         (iptr[0].val.i == 0x00010000) ||
604                                                                         (iptr[0].val.i == 0x00020000) ||
605                                                                         (iptr[0].val.i == 0x00040000) ||
606                                                                         (iptr[0].val.i == 0x00080000) ||
607                                                                         (iptr[0].val.i == 0x00100000) ||
608                                                                         (iptr[0].val.i == 0x00200000) ||
609                                                                         (iptr[0].val.i == 0x00400000) ||
610                                                                         (iptr[0].val.i == 0x00800000) ||
611                                                                         (iptr[0].val.i == 0x01000000) ||
612                                                                         (iptr[0].val.i == 0x02000000) ||
613                                                                         (iptr[0].val.i == 0x04000000) ||
614                                                                         (iptr[0].val.i == 0x08000000) ||
615                                                                         (iptr[0].val.i == 0x10000000) ||
616                                                                         (iptr[0].val.i == 0x20000000) ||
617                                                                         (iptr[0].val.i == 0x40000000) ||
618                                                                         (iptr[0].val.i == 0x80000000)) {
619                                                                         iptr[0].opc = ICMD_IREMPOW2;
620                                                                         iptr[0].val.i -= 1;
621                                                                         goto icmd_iconst_tail;
622                                                                 }
623                                                                 PUSHCONST(TYPE_INT);
624                                                                 break;
625                                                         case ICMD_IAND:
626                                                                 iptr[0].opc = ICMD_IANDCONST;
627                                                                 goto icmd_iconst_tail;
628                                                         case ICMD_IOR:
629                                                                 iptr[0].opc = ICMD_IORCONST;
630                                                                 goto icmd_iconst_tail;
631                                                         case ICMD_IXOR:
632                                                                 iptr[0].opc = ICMD_IXORCONST;
633                                                                 goto icmd_iconst_tail;
634                                                         case ICMD_ISHL:
635                                                                 iptr[0].opc = ICMD_ISHLCONST;
636                                                                 goto icmd_iconst_tail;
637                                                         case ICMD_ISHR:
638                                                                 iptr[0].opc = ICMD_ISHRCONST;
639                                                                 goto icmd_iconst_tail;
640                                                         case ICMD_IUSHR:
641                                                                 iptr[0].opc = ICMD_IUSHRCONST;
642                                                                 goto icmd_iconst_tail;
643 #if SUPPORT_LONG_SHIFT
644                                                         case ICMD_LSHL:
645                                                                 iptr[0].opc = ICMD_LSHLCONST;
646                                                                 goto icmd_lconst_tail;
647                                                         case ICMD_LSHR:
648                                                                 iptr[0].opc = ICMD_LSHRCONST;
649                                                                 goto icmd_lconst_tail;
650                                                         case ICMD_LUSHR:
651                                                                 iptr[0].opc = ICMD_LUSHRCONST;
652                                                                 goto icmd_lconst_tail;
653 #endif
654                                                         case ICMD_IF_ICMPEQ:
655                                                                 iptr[0].opc = ICMD_IFEQ;
656                                                         icmd_if_icmp_tail:
657                                                                 iptr[0].op1 = iptr[1].op1;
658                                                                 bptr->icount--;
659                                                                 len--;
660                                                                 /* iptr[1].opc = ICMD_NOP; */
661                                                                 OP1_0(TYPE_INT);
662                                                                 tbptr = block + block_index[iptr->op1];
663
664                                                                 iptr[0].target = (void *) tbptr;
665
666                                                                 MARKREACHED(tbptr, copy);
667                                                                 COUNT(count_pcmd_bra);
668                                                                 break;
669                                                         case ICMD_IF_ICMPLT:
670                                                                 iptr[0].opc = ICMD_IFLT;
671                                                                 goto icmd_if_icmp_tail;
672                                                         case ICMD_IF_ICMPLE:
673                                                                 iptr[0].opc = ICMD_IFLE;
674                                                                 goto icmd_if_icmp_tail;
675                                                         case ICMD_IF_ICMPNE:
676                                                                 iptr[0].opc = ICMD_IFNE;
677                                                                 goto icmd_if_icmp_tail;
678                                                         case ICMD_IF_ICMPGT:
679                                                                 iptr[0].opc = ICMD_IFGT;
680                                                                 goto icmd_if_icmp_tail;
681                                                         case ICMD_IF_ICMPGE:
682                                                                 iptr[0].opc = ICMD_IFGE;
683                                                                 goto icmd_if_icmp_tail;
684                                                         default:
685                                                                 PUSHCONST(TYPE_INT);
686                                                         }
687                                                 }
688                                                 else
689                                                         PUSHCONST(TYPE_INT);
690                                                 break;
691                                         case ICMD_LCONST:
692                                                 COUNT(count_pcmd_load);
693                                                 if (len > 0) {
694                                                         switch (iptr[1].opc) {
695 #if SUPPORT_LONG_ADD
696                                                         case ICMD_LADD:
697                                                                 iptr[0].opc = ICMD_LADDCONST;
698                                                         icmd_lconst_tail:
699                                                                 iptr[1].opc = ICMD_NOP;
700                                                                 OP1_1(TYPE_LNG,TYPE_LNG);
701                                                                 COUNT(count_pcmd_op);
702                                                                 break;
703                                                         case ICMD_LSUB:
704                                                                 iptr[0].opc = ICMD_LSUBCONST;
705                                                                 goto icmd_lconst_tail;
706 #endif
707 #if SUPPORT_LONG_MUL
708                                                         case ICMD_LMUL:
709                                                                 iptr[0].opc = ICMD_LMULCONST;
710 #if defined(__I386__)
711                                                                 method_uses_edx = true;
712 #endif
713                                                                 goto icmd_lconst_tail;
714 #endif
715 #if SUPPORT_LONG_DIV
716                                                         case ICMD_LDIV:
717                                                                 if (iptr[0].val.l == 0x00000002)
718                                                                         iptr[0].val.i = 1;
719                                                                 else if (iptr[0].val.l == 0x00000004)
720                                                                         iptr[0].val.i = 2;
721                                                                 else if (iptr[0].val.l == 0x00000008)
722                                                                         iptr[0].val.i = 3;
723                                                                 else if (iptr[0].val.l == 0x00000010)
724                                                                         iptr[0].val.i = 4;
725                                                                 else if (iptr[0].val.l == 0x00000020)
726                                                                         iptr[0].val.i = 5;
727                                                                 else if (iptr[0].val.l == 0x00000040)
728                                                                         iptr[0].val.i = 6;
729                                                                 else if (iptr[0].val.l == 0x00000080)
730                                                                         iptr[0].val.i = 7;
731                                                                 else if (iptr[0].val.l == 0x00000100)
732                                                                         iptr[0].val.i = 8;
733                                                                 else if (iptr[0].val.l == 0x00000200)
734                                                                         iptr[0].val.i = 9;
735                                                                 else if (iptr[0].val.l == 0x00000400)
736                                                                         iptr[0].val.i = 10;
737                                                                 else if (iptr[0].val.l == 0x00000800)
738                                                                         iptr[0].val.i = 11;
739                                                                 else if (iptr[0].val.l == 0x00001000)
740                                                                         iptr[0].val.i = 12;
741                                                                 else if (iptr[0].val.l == 0x00002000)
742                                                                         iptr[0].val.i = 13;
743                                                                 else if (iptr[0].val.l == 0x00004000)
744                                                                         iptr[0].val.i = 14;
745                                                                 else if (iptr[0].val.l == 0x00008000)
746                                                                         iptr[0].val.i = 15;
747                                                                 else if (iptr[0].val.l == 0x00010000)
748                                                                         iptr[0].val.i = 16;
749                                                                 else if (iptr[0].val.l == 0x00020000)
750                                                                         iptr[0].val.i = 17;
751                                                                 else if (iptr[0].val.l == 0x00040000)
752                                                                         iptr[0].val.i = 18;
753                                                                 else if (iptr[0].val.l == 0x00080000)
754                                                                         iptr[0].val.i = 19;
755                                                                 else if (iptr[0].val.l == 0x00100000)
756                                                                         iptr[0].val.i = 20;
757                                                                 else if (iptr[0].val.l == 0x00200000)
758                                                                         iptr[0].val.i = 21;
759                                                                 else if (iptr[0].val.l == 0x00400000)
760                                                                         iptr[0].val.i = 22;
761                                                                 else if (iptr[0].val.l == 0x00800000)
762                                                                         iptr[0].val.i = 23;
763                                                                 else if (iptr[0].val.l == 0x01000000)
764                                                                         iptr[0].val.i = 24;
765                                                                 else if (iptr[0].val.l == 0x02000000)
766                                                                         iptr[0].val.i = 25;
767                                                                 else if (iptr[0].val.l == 0x04000000)
768                                                                         iptr[0].val.i = 26;
769                                                                 else if (iptr[0].val.l == 0x08000000)
770                                                                         iptr[0].val.i = 27;
771                                                                 else if (iptr[0].val.l == 0x10000000)
772                                                                         iptr[0].val.i = 28;
773                                                                 else if (iptr[0].val.l == 0x20000000)
774                                                                         iptr[0].val.i = 29;
775                                                                 else if (iptr[0].val.l == 0x40000000)
776                                                                         iptr[0].val.i = 30;
777                                                                 else if (iptr[0].val.l == 0x80000000)
778                                                                         iptr[0].val.i = 31;
779                                                                 else {
780                                                                         PUSHCONST(TYPE_LNG);
781                                                                         break;
782                                                                 }
783                                                                 iptr[0].opc = ICMD_LDIVPOW2;
784                                                                 goto icmd_lconst_tail;
785                                                         case ICMD_LREM:
786 #if !defined(NO_DIV_OPT)
787                                                                 if (iptr[0].val.l == 0x10001) {
788                                                                         iptr[0].opc = ICMD_LREM0X10001;
789                                                                         goto icmd_lconst_tail;
790                                                                 }
791 #endif
792                                                                 if ((iptr[0].val.l == 0x00000002) ||
793                                                                         (iptr[0].val.l == 0x00000004) ||
794                                                                         (iptr[0].val.l == 0x00000008) ||
795                                                                         (iptr[0].val.l == 0x00000010) ||
796                                                                         (iptr[0].val.l == 0x00000020) ||
797                                                                         (iptr[0].val.l == 0x00000040) ||
798                                                                         (iptr[0].val.l == 0x00000080) ||
799                                                                         (iptr[0].val.l == 0x00000100) ||
800                                                                         (iptr[0].val.l == 0x00000200) ||
801                                                                         (iptr[0].val.l == 0x00000400) ||
802                                                                         (iptr[0].val.l == 0x00000800) ||
803                                                                         (iptr[0].val.l == 0x00001000) ||
804                                                                         (iptr[0].val.l == 0x00002000) ||
805                                                                         (iptr[0].val.l == 0x00004000) ||
806                                                                         (iptr[0].val.l == 0x00008000) ||
807                                                                         (iptr[0].val.l == 0x00010000) ||
808                                                                         (iptr[0].val.l == 0x00020000) ||
809                                                                         (iptr[0].val.l == 0x00040000) ||
810                                                                         (iptr[0].val.l == 0x00080000) ||
811                                                                         (iptr[0].val.l == 0x00100000) ||
812                                                                         (iptr[0].val.l == 0x00200000) ||
813                                                                         (iptr[0].val.l == 0x00400000) ||
814                                                                         (iptr[0].val.l == 0x00800000) ||
815                                                                         (iptr[0].val.l == 0x01000000) ||
816                                                                         (iptr[0].val.l == 0x02000000) ||
817                                                                         (iptr[0].val.l == 0x04000000) ||
818                                                                         (iptr[0].val.l == 0x08000000) ||
819                                                                         (iptr[0].val.l == 0x10000000) ||
820                                                                         (iptr[0].val.l == 0x20000000) ||
821                                                                         (iptr[0].val.l == 0x40000000) ||
822                                                                         (iptr[0].val.l == 0x80000000)) {
823                                                                         iptr[0].opc = ICMD_LREMPOW2;
824                                                                         iptr[0].val.l -= 1;
825                                                                         goto icmd_lconst_tail;
826                                                                 }
827                                                                 PUSHCONST(TYPE_LNG);
828                                                                 break;
829 #endif
830 #if SUPPORT_LONG_LOG
831                                                         case ICMD_LAND:
832                                                                 iptr[0].opc = ICMD_LANDCONST;
833                                                                 goto icmd_lconst_tail;
834                                                         case ICMD_LOR:
835                                                                 iptr[0].opc = ICMD_LORCONST;
836                                                                 goto icmd_lconst_tail;
837                                                         case ICMD_LXOR:
838                                                                 iptr[0].opc = ICMD_LXORCONST;
839                                                                 goto icmd_lconst_tail;
840 #endif
841 #if !defined(NOLONG_CONDITIONAL)
842                                                         case ICMD_LCMP:
843                                                                 if ((len > 1) && (iptr[2].val.i == 0)) {
844                                                                         switch (iptr[2].opc) {
845                                                                         case ICMD_IFEQ:
846                                                                                 iptr[0].opc = ICMD_IF_LEQ;
847                                                                         icmd_lconst_lcmp_tail:
848                                                                                 iptr[0].op1 = iptr[2].op1;
849                                                                                 bptr->icount -= 2;
850                                                                                 len -= 2;
851                                                                                 /* iptr[1].opc = ICMD_NOP;
852                                                                                    iptr[2].opc = ICMD_NOP; */
853                                                                                 OP1_0(TYPE_LNG);
854                                                                                 tbptr = block + block_index[iptr->op1];
855
856                                                                                 iptr[0].target = (void *) tbptr;
857
858                                                                                 MARKREACHED(tbptr, copy);
859                                                                                 COUNT(count_pcmd_bra);
860                                                                                 COUNT(count_pcmd_op);
861                                                                                 break;
862                                                                         case ICMD_IFNE:
863                                                                                 iptr[0].opc = ICMD_IF_LNE;
864                                                                                 goto icmd_lconst_lcmp_tail;
865                                                                         case ICMD_IFLT:
866                                                                                 iptr[0].opc = ICMD_IF_LLT;
867                                                                                 goto icmd_lconst_lcmp_tail;
868                                                                         case ICMD_IFGT:
869                                                                                 iptr[0].opc = ICMD_IF_LGT;
870                                                                                 goto icmd_lconst_lcmp_tail;
871                                                                         case ICMD_IFLE:
872                                                                                 iptr[0].opc = ICMD_IF_LLE;
873                                                                                 goto icmd_lconst_lcmp_tail;
874                                                                         case ICMD_IFGE:
875                                                                                 iptr[0].opc = ICMD_IF_LGE;
876                                                                                 goto icmd_lconst_lcmp_tail;
877                                                                         default:
878                                                                                 PUSHCONST(TYPE_LNG);
879                                                                         } /* switch (iptr[2].opc) */
880                                                                 } /* if (iptr[2].val.i == 0) */
881                                                                 else
882                                                                         PUSHCONST(TYPE_LNG);
883                                                                 break;
884 #endif
885                                                         default:
886                                                                 PUSHCONST(TYPE_LNG);
887                                                         }
888                                                 }
889                                                 else
890                                                         PUSHCONST(TYPE_LNG);
891                                                 break;
892                                         case ICMD_FCONST:
893                                                 COUNT(count_pcmd_load);
894                                                 PUSHCONST(TYPE_FLT);
895                                                 break;
896                                         case ICMD_DCONST:
897                                                 COUNT(count_pcmd_load);
898                                                 PUSHCONST(TYPE_DBL);
899                                                 break;
900                                         case ICMD_ACONST:
901                                                 COUNT(count_pcmd_load);
902                                                 PUSHCONST(TYPE_ADR);
903                                                 break;
904
905                                                 /* pop 0 push 1 load */
906                                                 
907                                         case ICMD_ILOAD:
908                                         case ICMD_LLOAD:
909                                         case ICMD_FLOAD:
910                                         case ICMD_DLOAD:
911                                         case ICMD_ALOAD:
912                                                 COUNT(count_load_instruction);
913                                                 i = opcode-ICMD_ILOAD;
914                                                 iptr->op1 = argren[iptr->op1];
915                                                 locals[iptr->op1][i].type = i;
916                                                 LOAD(i, LOCALVAR, iptr->op1);
917                                                 break;
918
919                                                 /* pop 2 push 1 */
920
921                                         case ICMD_LALOAD:
922 #if defined(__I386__)
923                                                 method_uses_edx = true;
924 #endif
925                                         case ICMD_IALOAD:
926                                         case ICMD_FALOAD:
927                                         case ICMD_DALOAD:
928                                         case ICMD_AALOAD:
929                                                 COUNT(count_check_null);
930                                                 COUNT(count_check_bound);
931                                                 COUNT(count_pcmd_mem);
932                                                 OP2IAT_1(opcode-ICMD_IALOAD);
933                                                 break;
934
935                                         case ICMD_BALOAD:
936                                         case ICMD_CALOAD:
937                                         case ICMD_SALOAD:
938                                                 COUNT(count_check_null);
939                                                 COUNT(count_check_bound);
940                                                 COUNT(count_pcmd_mem);
941                                                 OP2IAT_1(TYPE_INT);
942                                                 break;
943
944                                                 /* pop 0 push 0 iinc */
945
946                                         case ICMD_IINC:
947 #ifdef STATISTICS
948                                                 i = stackdepth;
949                                                 if (i >= 10)
950                                                         count_store_depth[10]++;
951                                                 else
952                                                         count_store_depth[i]++;
953 #endif
954                                                 copy = curstack;
955                                                 i = stackdepth - 1;
956                                                 while (copy) {
957                                                         if ((copy->varkind == LOCALVAR) &&
958                                                                 (copy->varnum == iptr->op1)) {
959                                                                 copy->varkind = TEMPVAR;
960                                                                 copy->varnum = i;
961                                                         }
962                                                         i--;
963                                                         copy = copy->prev;
964                                                 }
965                                                 SETDST;
966                                                 break;
967
968                                                 /* pop 1 push 0 store */
969
970                                         case ICMD_ISTORE:
971                                         case ICMD_LSTORE:
972                                         case ICMD_FSTORE:
973                                         case ICMD_DSTORE:
974                                         case ICMD_ASTORE:
975                                         icmd_store:
976                                                 REQUIRE_1;
977
978                                         i = opcode - ICMD_ISTORE;
979                                         locals[iptr->op1][i].type = i;
980 #ifdef STATISTICS
981                                         count_pcmd_store++;
982                                         i = new - curstack;
983                                         if (i >= 20)
984                                                 count_store_length[20]++;
985                                         else
986                                                 count_store_length[i]++;
987                                         i = stackdepth - 1;
988                                         if (i >= 10)
989                                                 count_store_depth[10]++;
990                                         else
991                                                 count_store_depth[i]++;
992 #endif
993                                         copy = curstack->prev;
994                                         i = stackdepth - 2;
995                                         while (copy) {
996                                                 if ((copy->varkind == LOCALVAR) &&
997                                                         (copy->varnum == iptr->op1)) {
998                                                         copy->varkind = TEMPVAR;
999                                                         copy->varnum = i;
1000                                                 }
1001                                                 i--;
1002                                                 copy = copy->prev;
1003                                         }
1004                                         if ((new - curstack) == 1) {
1005                                                 curstack->varkind = LOCALVAR;
1006                                                 curstack->varnum = iptr->op1;
1007                                         };
1008                                         STORE(opcode-ICMD_ISTORE);
1009                                         break;
1010
1011                                         /* pop 3 push 0 */
1012
1013                                         case ICMD_IASTORE:
1014                                         case ICMD_AASTORE:
1015                                         case ICMD_LASTORE:
1016 #if defined(__I386__)
1017                                                 method_uses_edx = true;
1018 #endif
1019                                         case ICMD_FASTORE:
1020                                         case ICMD_DASTORE:
1021                                                 COUNT(count_check_null);
1022                                                 COUNT(count_check_bound);
1023                                                 COUNT(count_pcmd_mem);
1024                                                 OP3TIA_0(opcode-ICMD_IASTORE);
1025                                                 break;
1026
1027                                         case ICMD_BASTORE:
1028                                         case ICMD_CASTORE:
1029                                         case ICMD_SASTORE:
1030                                                 COUNT(count_check_null);
1031                                                 COUNT(count_check_bound);
1032                                                 COUNT(count_pcmd_mem);
1033                                                 OP3TIA_0(TYPE_INT);
1034 #if defined(__I386__)
1035                                                 method_uses_edx = true;
1036 #endif
1037                                                 break;
1038
1039                                                 /* pop 1 push 0 */
1040
1041                                         case ICMD_POP:
1042                                                 OP1_0ANY;
1043                                                 break;
1044
1045                                         case ICMD_IRETURN:
1046                                         case ICMD_LRETURN:
1047                                         case ICMD_FRETURN:
1048                                         case ICMD_DRETURN:
1049                                         case ICMD_ARETURN:
1050                                                 COUNT(count_pcmd_return);
1051                                                 OP1_0(opcode-ICMD_IRETURN);
1052                                                 superblockend = true;
1053                                                 break;
1054
1055                                         case ICMD_ATHROW:
1056                                                 COUNT(count_check_null);
1057                                                 OP1_0(TYPE_ADR);
1058                                                 STACKRESET;
1059                                                 SETDST;
1060                                                 superblockend = true;
1061                                                 break;
1062
1063                                         case ICMD_PUTSTATIC:
1064                                                 COUNT(count_pcmd_mem);
1065                                                 OP1_0(iptr->op1);
1066                                                 break;
1067
1068                                                 /* pop 1 push 0 branch */
1069
1070                                         case ICMD_IFNULL:
1071                                         case ICMD_IFNONNULL:
1072                                                 COUNT(count_pcmd_bra);
1073                                                 OP1_0(TYPE_ADR);
1074                                                 tbptr = block + block_index[iptr->op1];
1075
1076                                                 iptr[0].target = (void *) tbptr;
1077
1078                                                 MARKREACHED(tbptr, copy);
1079                                                 break;
1080
1081                                         case ICMD_IFEQ:
1082                                         case ICMD_IFNE:
1083                                         case ICMD_IFLT:
1084                                         case ICMD_IFGE:
1085                                         case ICMD_IFGT:
1086                                         case ICMD_IFLE:
1087                                                 COUNT(count_pcmd_bra);
1088 #ifdef CONDITIONAL_LOADCONST
1089                                                 {
1090                                                         tbptr = block + b_index;
1091                                                         if ((b_count >= 3) &&
1092                                                             ((b_index + 2) == block_index[iptr[0].op1]) &&
1093                                                             (tbptr[1].pre_count == 1) &&
1094                                                             (iptr[1].opc == ICMD_ICONST) &&
1095                                                             (iptr[2].opc == ICMD_GOTO)   &&
1096                                                             ((b_index + 3) == block_index[iptr[2].op1]) &&
1097                                                             (tbptr[2].pre_count == 1) &&
1098                                                             (iptr[3].opc == ICMD_ICONST)) {
1099                                                                 OP1_1(TYPE_INT, TYPE_INT);
1100                                                                 switch (iptr[0].opc) {
1101                                                                 case ICMD_IFEQ:
1102                                                                         iptr[0].opc = ICMD_IFNE_ICONST;
1103                                                                         break;
1104                                                                 case ICMD_IFNE:
1105                                                                         iptr[0].opc = ICMD_IFEQ_ICONST;
1106                                                                         break;
1107                                                                 case ICMD_IFLT:
1108                                                                         iptr[0].opc = ICMD_IFGE_ICONST;
1109                                                                         break;
1110                                                                 case ICMD_IFGE:
1111                                                                         iptr[0].opc = ICMD_IFLT_ICONST;
1112                                                                         break;
1113                                                                 case ICMD_IFGT:
1114                                                                         iptr[0].opc = ICMD_IFLE_ICONST;
1115                                                                         break;
1116                                                                 case ICMD_IFLE:
1117                                                                         iptr[0].opc = ICMD_IFGT_ICONST;
1118                                                                         break;
1119                                                                 }
1120                                                                 iptr[0].val.i = iptr[1].val.i;
1121                                                                 iptr[1].opc = ICMD_ELSE_ICONST;
1122                                                                 iptr[1].val.i = iptr[3].val.i;
1123                                                                 iptr[2].opc = ICMD_NOP;
1124                                                                 iptr[3].opc = ICMD_NOP;
1125                                                                 tbptr[1].flags = BBDELETED;
1126                                                                 tbptr[2].flags = BBDELETED;
1127                                                                 tbptr[1].icount = 0;
1128                                                                 tbptr[2].icount = 0;
1129                                                                 if (tbptr[3].pre_count == 2) {
1130                                                                         len += tbptr[3].icount + 3;
1131                                                                         bptr->icount += tbptr[3].icount + 3;
1132                                                                         tbptr[3].flags = BBDELETED;
1133                                                                         tbptr[3].icount = 0;
1134                                                                         b_index++;
1135                                                                 }
1136                                                                 else {
1137                                                                         bptr->icount++;
1138                                                                         len ++;
1139                                                                 }
1140                                                                 b_index += 2;
1141                                                                 break;
1142                                                         }
1143                                                 }
1144 #endif
1145                                                 OP1_0(TYPE_INT);
1146                                                 tbptr = block + block_index[iptr->op1];
1147
1148                                                 iptr[0].target = (void *) tbptr;
1149
1150                                                 MARKREACHED(tbptr, copy);
1151                                                 break;
1152
1153                                                 /* pop 0 push 0 branch */
1154
1155                                         case ICMD_GOTO:
1156                                                 COUNT(count_pcmd_bra);
1157                                                 tbptr = block + block_index[iptr->op1];
1158
1159                                                 iptr[0].target = (void *) tbptr;
1160
1161                                                 MARKREACHED(tbptr, copy);
1162                                                 SETDST;
1163                                                 superblockend = true;
1164                                                 break;
1165
1166                                                 /* pop 1 push 0 table branch */
1167
1168                                         case ICMD_TABLESWITCH:
1169                                                 COUNT(count_pcmd_table);
1170                                                 OP1_0(TYPE_INT);
1171                                                 s4ptr = iptr->val.a;
1172                                                 tbptr = block + block_index[*s4ptr++]; /* default */
1173                                                 MARKREACHED(tbptr, copy);
1174                                                 i = *s4ptr++;                          /* low     */
1175                                                 i = *s4ptr++ - i + 1;                  /* high    */
1176
1177                                                 tptr = DMNEW(void*, i+1);
1178                                                 iptr->target = (void *) tptr;
1179
1180                                                 tptr[0] = (void *) tbptr;
1181                                                 tptr++;
1182
1183                                                 while (--i >= 0) {
1184                                                         tbptr = block + block_index[*s4ptr++];
1185
1186                                                         tptr[0] = (void *) tbptr;
1187                                                         tptr++;
1188
1189                                                         MARKREACHED(tbptr, copy);
1190                                                 }
1191                                                 SETDST;
1192                                                 superblockend = true;
1193                                                 break;
1194                                                         
1195                                                 /* pop 1 push 0 table branch */
1196
1197                                         case ICMD_LOOKUPSWITCH:
1198                                                 COUNT(count_pcmd_table);
1199                                                 OP1_0(TYPE_INT);
1200                                                 s4ptr = iptr->val.a;
1201                                                 tbptr = block + block_index[*s4ptr++]; /* default */
1202                                                 MARKREACHED(tbptr, copy);
1203                                                 i = *s4ptr++;                          /* count   */
1204
1205                                                 tptr = DMNEW(void*, i+1);
1206                                                 iptr->target = (void *) tptr;
1207
1208                                                 tptr[0] = (void *) tbptr;
1209                                                 tptr++;
1210
1211                                                 while (--i >= 0) {
1212                                                         tbptr = block + block_index[s4ptr[1]];
1213
1214                                                         tptr[0] = (void *) tbptr;
1215                                                         tptr++;
1216                                                                 
1217                                                         MARKREACHED(tbptr, copy);
1218                                                         s4ptr += 2;
1219                                                 }
1220                                                 SETDST;
1221                                                 superblockend = true;
1222                                                 break;
1223
1224                                         case ICMD_NULLCHECKPOP:
1225                                         case ICMD_MONITORENTER:
1226                                                 COUNT(count_check_null);
1227                                         case ICMD_MONITOREXIT:
1228                                                 OP1_0(TYPE_ADR);
1229                                                 break;
1230
1231                                                 /* pop 2 push 0 branch */
1232
1233                                         case ICMD_IF_ICMPEQ:
1234                                         case ICMD_IF_ICMPNE:
1235                                         case ICMD_IF_ICMPLT:
1236                                         case ICMD_IF_ICMPGE:
1237                                         case ICMD_IF_ICMPGT:
1238                                         case ICMD_IF_ICMPLE:
1239                                                 COUNT(count_pcmd_bra);
1240                                                 OP2_0(TYPE_INT);
1241                                                 tbptr = block + block_index[iptr->op1];
1242                                                         
1243                                                 iptr[0].target = (void *) tbptr;
1244
1245                                                 MARKREACHED(tbptr, copy);
1246                                                 break;
1247
1248                                         case ICMD_IF_ACMPEQ:
1249                                         case ICMD_IF_ACMPNE:
1250                                                 COUNT(count_pcmd_bra);
1251                                                 OP2_0(TYPE_ADR);
1252                                                 tbptr = block + block_index[iptr->op1];
1253
1254                                                 iptr[0].target = (void *) tbptr;
1255
1256                                                 MARKREACHED(tbptr, copy);
1257                                                 break;
1258
1259                                                 /* pop 2 push 0 */
1260
1261                                         case ICMD_PUTFIELD:
1262                                                 COUNT(count_check_null);
1263                                                 COUNT(count_pcmd_mem);
1264                                                 OPTT2_0(iptr->op1,TYPE_ADR);
1265                                                 break;
1266
1267                                         case ICMD_POP2:
1268                                                 REQUIRE_1;
1269                                                 if (! IS_2_WORD_TYPE(curstack->type)) {
1270                                                         OP1_0ANY;                /* second pop */
1271                                                 }
1272                                                 else
1273                                                         iptr->opc = ICMD_POP;
1274                                                 OP1_0ANY;
1275                                                 break;
1276
1277                                                 /* pop 0 push 1 dup */
1278                                                 
1279                                         case ICMD_DUP:
1280                                                 COUNT(count_dup_instruction);
1281                                                 DUP;
1282                                                 break;
1283
1284                                         case ICMD_DUP2:
1285                                                 REQUIRE_1;
1286                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1287                                                         iptr->opc = ICMD_DUP;
1288                                                         DUP;
1289                                                 }
1290                                                 else {
1291                                                         REQUIRE_2;
1292                                                         copy = curstack;
1293                                                         NEWSTACK(copy->prev->type, copy->prev->varkind,
1294                                                                          copy->prev->varnum);
1295                                                         NEWSTACK(copy->type, copy->varkind,
1296                                                                          copy->varnum);
1297                                                         SETDST;
1298                                                         stackdepth+=2;
1299                                                 }
1300                                                 break;
1301
1302                                                 /* pop 2 push 3 dup */
1303                                                 
1304                                         case ICMD_DUP_X1:
1305                                                 DUP_X1;
1306                                                 break;
1307
1308                                         case ICMD_DUP2_X1:
1309                                                 REQUIRE_2;
1310                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1311                                                         iptr->opc = ICMD_DUP_X1;
1312                                                         DUP_X1;
1313                                                 }
1314                                                 else {
1315                                                         DUP2_X1;
1316                                                 }
1317                                                 break;
1318
1319                                                 /* pop 3 push 4 dup */
1320                                                 
1321                                         case ICMD_DUP_X2:
1322                                                 REQUIRE_2;
1323                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1324                                                         iptr->opc = ICMD_DUP_X1;
1325                                                         DUP_X1;
1326                                                 }
1327                                                 else {
1328                                                         DUP_X2;
1329                                                 }
1330                                                 break;
1331
1332                                         case ICMD_DUP2_X2:
1333                                                 REQUIRE_2;
1334                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1335                                                         if (IS_2_WORD_TYPE(curstack->prev->type)) {
1336                                                                 iptr->opc = ICMD_DUP_X1;
1337                                                                 DUP_X1;
1338                                                         }
1339                                                         else {
1340                                                                 iptr->opc = ICMD_DUP_X2;
1341                                                                 DUP_X2;
1342                                                         }
1343                                                 }
1344                                                 else {
1345                                                         REQUIRE_3;
1346                                                         if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1347                                                                 iptr->opc = ICMD_DUP2_X1;
1348                                                                 DUP2_X1;
1349                                                         }
1350                                                         else {
1351                                                                 DUP2_X2;
1352                                                         }
1353                                                 }
1354                                                 break;
1355
1356                                                 /* pop 2 push 2 swap */
1357                                                 
1358                                         case ICMD_SWAP:
1359                                                 SWAP;
1360                                                 break;
1361
1362                                                 /* pop 2 push 1 */
1363                                                 
1364                                         case ICMD_IDIV:
1365 #if !SUPPORT_DIVISION
1366                                                 iptr[0].opc = ICMD_BUILTIN2;
1367                                                 iptr[0].op1 = TYPE_INT;
1368                                                 iptr[0].val.a = BUILTIN_idiv;
1369                                                 isleafmethod = false;
1370                                                 goto builtin2;
1371 #endif
1372
1373                                         case ICMD_IREM:
1374 #if !SUPPORT_DIVISION
1375                                                 iptr[0].opc = ICMD_BUILTIN2;
1376                                                 iptr[0].op1 = TYPE_INT;
1377                                                 iptr[0].val.a = BUILTIN_irem;
1378                                                 isleafmethod = false;
1379                                                 goto builtin2;
1380 #endif
1381 #if defined(__I386__)
1382                                                 method_uses_edx = true;
1383 #endif
1384
1385                                         case ICMD_ISHL:
1386                                         case ICMD_ISHR:
1387                                         case ICMD_IUSHR:
1388 #if defined(__I386__)
1389                                                 method_uses_ecx = true;
1390 #endif
1391                                         case ICMD_IADD:
1392                                         case ICMD_ISUB:
1393                                         case ICMD_IMUL:
1394                                         case ICMD_IAND:
1395                                         case ICMD_IOR:
1396                                         case ICMD_IXOR:
1397                                                 COUNT(count_pcmd_op);
1398                                                 OP2_1(TYPE_INT);
1399                                                 break;
1400
1401                                         case ICMD_LDIV:
1402 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1403                                                 iptr[0].opc = ICMD_BUILTIN2;
1404                                                 iptr[0].op1 = TYPE_LNG;
1405                                                 iptr[0].val.a = BUILTIN_ldiv;
1406                                                 isleafmethod = false;
1407                                                 goto builtin2;
1408 #endif
1409
1410                                         case ICMD_LREM:
1411 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1412                                                 iptr[0].opc = ICMD_BUILTIN2;
1413                                                 iptr[0].op1 = TYPE_LNG;
1414                                                 iptr[0].val.a = BUILTIN_lrem;
1415                                                 isleafmethod = false;
1416                                                 goto builtin2;
1417 #endif
1418
1419                                         case ICMD_LMUL:
1420 #if defined(__I386__)
1421                                                 method_uses_edx = true;
1422 #endif
1423                                         case ICMD_LADD:
1424                                         case ICMD_LSUB:
1425                                         case ICMD_LOR:
1426                                         case ICMD_LAND:
1427                                         case ICMD_LXOR:
1428                                                 /* XXX DEBUG */ /*dolog("OP2_1(TYPE_LNG)"); */
1429                                                 COUNT(count_pcmd_op);
1430                                                 OP2_1(TYPE_LNG);
1431                                                 break;
1432
1433                                         case ICMD_LSHL:
1434                                         case ICMD_LSHR:
1435                                         case ICMD_LUSHR:
1436                                                 COUNT(count_pcmd_op);
1437                                                 OP2IT_1(TYPE_LNG);
1438 #if defined(__I386__)
1439                                                 method_uses_ecx = true;
1440                                                 method_uses_edx = true;
1441 #endif
1442                                                 break;
1443
1444                                         case ICMD_FADD:
1445                                         case ICMD_FSUB:
1446                                         case ICMD_FMUL:
1447                                         case ICMD_FDIV:
1448                                         case ICMD_FREM:
1449                                                 COUNT(count_pcmd_op);
1450                                                 OP2_1(TYPE_FLT);
1451                                                 break;
1452
1453                                         case ICMD_DADD:
1454                                         case ICMD_DSUB:
1455                                         case ICMD_DMUL:
1456                                         case ICMD_DDIV:
1457                                         case ICMD_DREM:
1458                                                 COUNT(count_pcmd_op);
1459                                                 OP2_1(TYPE_DBL);
1460                                                 break;
1461
1462                                         case ICMD_LCMP:
1463                                                 COUNT(count_pcmd_op);
1464 #if !defined(NOLONG_CONDITIONAL)
1465                                                 if ((len > 0) && (iptr[1].val.i == 0)) {
1466                                                         switch (iptr[1].opc) {
1467                                                         case ICMD_IFEQ:
1468                                                                 iptr[0].opc = ICMD_IF_LCMPEQ;
1469                                                         icmd_lcmp_if_tail:
1470                                                                 iptr[0].op1 = iptr[1].op1;
1471                                                                 len--;
1472                                                                 bptr->icount--;
1473                                                                 /* iptr[1].opc = ICMD_NOP; */
1474                                                                 OP2_0(TYPE_LNG);
1475                                                                 tbptr = block + block_index[iptr->op1];
1476                         
1477                                                                 iptr[0].target = (void *) tbptr;
1478
1479                                                                 MARKREACHED(tbptr, copy);
1480                                                                 COUNT(count_pcmd_bra);
1481                                                                 break;
1482                                                         case ICMD_IFNE:
1483                                                                 iptr[0].opc = ICMD_IF_LCMPNE;
1484                                                                 goto icmd_lcmp_if_tail;
1485                                                         case ICMD_IFLT:
1486                                                                 iptr[0].opc = ICMD_IF_LCMPLT;
1487                                                                 goto icmd_lcmp_if_tail;
1488                                                         case ICMD_IFGT:
1489                                                                 iptr[0].opc = ICMD_IF_LCMPGT;
1490                                                                 goto icmd_lcmp_if_tail;
1491                                                         case ICMD_IFLE:
1492                                                                 iptr[0].opc = ICMD_IF_LCMPLE;
1493                                                                 goto icmd_lcmp_if_tail;
1494                                                         case ICMD_IFGE:
1495                                                                 iptr[0].opc = ICMD_IF_LCMPGE;
1496                                                                 goto icmd_lcmp_if_tail;
1497                                                         default:
1498                                                                 OPTT2_1(TYPE_LNG, TYPE_INT);
1499                                                         }
1500                                                 }
1501                                                 else
1502 #endif
1503                                                         OPTT2_1(TYPE_LNG, TYPE_INT);
1504                                                 break;
1505                                         case ICMD_FCMPL:
1506                                         case ICMD_FCMPG:
1507                                                 COUNT(count_pcmd_op);
1508                                                 OPTT2_1(TYPE_FLT, TYPE_INT);
1509                                                 break;
1510                                         case ICMD_DCMPL:
1511                                         case ICMD_DCMPG:
1512                                                 COUNT(count_pcmd_op);
1513                                                 OPTT2_1(TYPE_DBL, TYPE_INT);
1514                                                 break;
1515
1516                                                 /* pop 1 push 1 */
1517                                                 
1518                                         case ICMD_INEG:
1519                                         case ICMD_INT2BYTE:
1520                                         case ICMD_INT2CHAR:
1521                                         case ICMD_INT2SHORT:
1522                                                 COUNT(count_pcmd_op);
1523                                                 OP1_1(TYPE_INT, TYPE_INT);
1524                                                 break;
1525                                         case ICMD_LNEG:
1526                                                 COUNT(count_pcmd_op);
1527                                                 OP1_1(TYPE_LNG, TYPE_LNG);
1528                                                 break;
1529                                         case ICMD_FNEG:
1530                                                 COUNT(count_pcmd_op);
1531                                                 OP1_1(TYPE_FLT, TYPE_FLT);
1532                                                 break;
1533                                         case ICMD_DNEG:
1534                                                 COUNT(count_pcmd_op);
1535                                                 OP1_1(TYPE_DBL, TYPE_DBL);
1536                                                 break;
1537
1538                                         case ICMD_I2L:
1539                                                 COUNT(count_pcmd_op);
1540                                                 OP1_1(TYPE_INT, TYPE_LNG);
1541 #if defined(__I386__)
1542                                                 method_uses_edx = true;
1543 #endif
1544                                                 break;
1545                                         case ICMD_I2F:
1546                                                 COUNT(count_pcmd_op);
1547                                                 OP1_1(TYPE_INT, TYPE_FLT);
1548                                                 break;
1549                                         case ICMD_I2D:
1550                                                 COUNT(count_pcmd_op);
1551                                                 OP1_1(TYPE_INT, TYPE_DBL);
1552                                                 break;
1553                                         case ICMD_L2I:
1554                                                 COUNT(count_pcmd_op);
1555                                                 OP1_1(TYPE_LNG, TYPE_INT);
1556                                                 break;
1557                                         case ICMD_L2F:
1558                                                 COUNT(count_pcmd_op);
1559                                                 OP1_1(TYPE_LNG, TYPE_FLT);
1560                                                 break;
1561                                         case ICMD_L2D:
1562                                                 COUNT(count_pcmd_op);
1563                                                 OP1_1(TYPE_LNG, TYPE_DBL);
1564                                                 break;
1565                                         case ICMD_F2I:
1566                                                 COUNT(count_pcmd_op);
1567                                                 OP1_1(TYPE_FLT, TYPE_INT);
1568                                                 break;
1569                                         case ICMD_F2L:
1570                                                 COUNT(count_pcmd_op);
1571                                                 OP1_1(TYPE_FLT, TYPE_LNG);
1572 #if defined(__I386__)
1573                                                 method_uses_edx = true;
1574 #endif
1575                                                 break;
1576                                         case ICMD_F2D:
1577                                                 COUNT(count_pcmd_op);
1578                                                 OP1_1(TYPE_FLT, TYPE_DBL);
1579                                                 break;
1580                                         case ICMD_D2I:
1581                                                 COUNT(count_pcmd_op);
1582                                                 OP1_1(TYPE_DBL, TYPE_INT);
1583                                                 break;
1584                                         case ICMD_D2L:
1585                                                 COUNT(count_pcmd_op);
1586                                                 OP1_1(TYPE_DBL, TYPE_LNG);
1587 #if defined(__I386__)
1588                                                 method_uses_edx = true;
1589 #endif
1590                                                 break;
1591                                         case ICMD_D2F:
1592                                                 COUNT(count_pcmd_op);
1593                                                 OP1_1(TYPE_DBL, TYPE_FLT);
1594                                                 break;
1595
1596                                         case ICMD_CHECKCAST:
1597                                                 OP1_1(TYPE_ADR, TYPE_ADR);
1598 #if defined(__I386__)
1599                                                 method_uses_edx = true;
1600 #endif
1601                                                 break;
1602
1603                                         case ICMD_INSTANCEOF:
1604 #if defined(__I386__)
1605                                                 method_uses_edx = true;
1606 #endif
1607                                         case ICMD_ARRAYLENGTH:
1608                                                 OP1_1(TYPE_ADR, TYPE_INT);
1609                                                 break;
1610
1611                                         case ICMD_NEWARRAY:
1612                                         case ICMD_ANEWARRAY:
1613                                                 OP1_1(TYPE_INT, TYPE_ADR);
1614                                                 break;
1615
1616                                         case ICMD_GETFIELD:
1617                                                 COUNT(count_check_null);
1618                                                 COUNT(count_pcmd_mem);
1619                                                 OP1_1(TYPE_ADR, iptr->op1);
1620                                                 break;
1621
1622                                                 /* pop 0 push 1 */
1623                                                 
1624                                         case ICMD_GETSTATIC:
1625                                                 COUNT(count_pcmd_mem);
1626                                                 OP0_1(iptr->op1);
1627                                                 break;
1628
1629                                         case ICMD_NEW:
1630                                                 OP0_1(TYPE_ADR);
1631                                                 break;
1632
1633                                         case ICMD_JSR:
1634                                                 OP0_1(TYPE_ADR);
1635                                                 tbptr = block + block_index[iptr->op1];
1636
1637                                                 iptr[0].target = (void *) tbptr;
1638
1639                                                 /* XXX This is a dirty hack. The typechecker
1640                                                  * needs it because the OP1_0ANY below
1641                                                  * overwrites iptr->dst.
1642                                                  */
1643                                                 iptr->val.a = (void*) iptr->dst;
1644
1645                                                 tbptr->type=BBTYPE_SBR;
1646                                                 CHECKOVERFLOW;
1647                                                 MARKREACHED(tbptr, copy);
1648                                                 OP1_0ANY;
1649                                                 break;
1650
1651                                                 /* pop many push any */
1652                                                 
1653                                         case ICMD_INVOKEVIRTUAL:
1654                                         case ICMD_INVOKESPECIAL:
1655                                         case ICMD_INVOKEINTERFACE:
1656                                         case ICMD_INVOKESTATIC:
1657                                                 COUNT(count_pcmd_met);
1658                                                 {
1659                                                         methodinfo *m = iptr->val.a;
1660                                                         if (m->flags & ACC_STATIC)
1661                                                                 {COUNT(count_check_null);}
1662                                                         i = iptr->op1;
1663                                                         if (i > arguments_num)
1664                                                                 arguments_num = i;
1665                                                         REQUIRE(i);
1666 #if defined(__X86_64__)
1667                                                         {
1668                                                                 int iarg = 0;
1669                                                                 int farg = 0;
1670                                                                 int stackargs = 0;
1671
1672                                                                 copy = curstack;
1673                                                                 while (--i >= 0) {
1674                                                                         (IS_FLT_DBL_TYPE(copy->type)) ? farg++ : iarg++;
1675                                                                         copy = copy->prev;
1676                                                                 }
1677
1678                                                                 stackargs += (iarg < intreg_argnum) ? 0 : (iarg - intreg_argnum);
1679                                                                 stackargs += (farg < fltreg_argnum) ? 0 : (farg - fltreg_argnum);
1680
1681                                                                 i = iptr->op1;
1682                                                                 copy = curstack;
1683                                                                 while (--i >= 0) {
1684                                                                         if (!(copy->flags & SAVEDVAR)) {
1685                                                                                 copy->varkind = ARGVAR;
1686                                                                                 if (IS_FLT_DBL_TYPE(copy->type)) {
1687                                                                                         if (--farg < fltreg_argnum) {
1688                                                                                                 copy->varnum = farg;
1689                                                                                         } else {
1690                                                                                                 copy->varnum = --stackargs + intreg_argnum;
1691                                                                                         }
1692                                                                                 } else {
1693                                                                                         if (--iarg < intreg_argnum) {
1694                                                                                                 copy->varnum = iarg;
1695                                                                                         } else {
1696                                                                                                 copy->varnum = --stackargs + intreg_argnum;
1697                                                                                         }
1698                                                                                 }
1699                                                                         } else {
1700                                                                                 (IS_FLT_DBL_TYPE(copy->type)) ? --farg : --iarg;
1701                                                                         }
1702                                                                         copy = copy->prev;
1703                                                                 }
1704                                                         }
1705 #else
1706                                                         copy = curstack;
1707                                                         while (--i >= 0) {
1708                                                                 if (! (copy->flags & SAVEDVAR)) {
1709                                                                         copy->varkind = ARGVAR;
1710                                                                         copy->varnum = i;
1711                                                                 }
1712                                                                 copy = copy->prev;
1713                                                         }
1714 #endif
1715                                                         while (copy) {
1716                                                                 copy->flags |= SAVEDVAR;
1717                                                                 copy = copy->prev;
1718                                                         }
1719                                                         i = iptr->op1;
1720                                                         POPMANY(i);
1721                                                         if (m->returntype != TYPE_VOID) {
1722                                                                 OP0_1(m->returntype);
1723                                                         }
1724                                                         break;
1725                                                 }
1726
1727                                         case ICMD_BUILTIN3:
1728                                                 /* XXX DEBUG */ /*dolog("builtin3");*/
1729                                                 REQUIRE_3;
1730                                                 if (! (curstack->flags & SAVEDVAR)) {
1731                                                         curstack->varkind = ARGVAR;
1732                                                         curstack->varnum = 2;
1733                                                 }
1734                                                 if (3 > arguments_num) {
1735                                                         arguments_num = 3;
1736                                                 }
1737                                                 OP1_0ANY;
1738
1739                                         case ICMD_BUILTIN2:
1740                                         builtin2:
1741                                                 REQUIRE_2;
1742                                                 /* XXX DEBUG */ /*dolog("builtin2");*/
1743                                         if (!(curstack->flags & SAVEDVAR)) {
1744                                                 curstack->varkind = ARGVAR;
1745                                                 curstack->varnum = 1;
1746                                         }
1747                                         if (2 > arguments_num) {
1748                                                 arguments_num = 2;
1749                                         }
1750                                         OP1_0ANY;
1751
1752                                         case ICMD_BUILTIN1:
1753                                         builtin1:
1754                                                 REQUIRE_1;
1755                                                 /* XXX DEBUG */ /*dolog("builtin1");*/
1756                                         if (!(curstack->flags & SAVEDVAR)) {
1757                                                 curstack->varkind = ARGVAR;
1758                                                 curstack->varnum = 0;
1759                                         }
1760                                         if (1 > arguments_num) {
1761                                                 arguments_num = 1;
1762                                         }
1763                                         OP1_0ANY;
1764                                         copy = curstack;
1765                                         while (copy) {
1766                                                 copy->flags |= SAVEDVAR;
1767                                                 copy = copy->prev;
1768                                         }
1769                                         if (iptr->op1 != TYPE_VOID)
1770                                                 OP0_1(iptr->op1);
1771                                         break;
1772
1773                                         case ICMD_MULTIANEWARRAY:
1774                                                 i = iptr->op1;
1775                                                 REQUIRE(i);
1776                                                 if ((i + intreg_argnum) > arguments_num)
1777                                                         arguments_num = i + intreg_argnum;
1778                                                 copy = curstack;
1779                                                 while (--i >= 0) {
1780                                                         if (! (copy->flags & SAVEDVAR)) {
1781                                                                 copy->varkind = ARGVAR;
1782                                                                 copy->varnum = i + intreg_argnum;
1783                                                         }
1784                                                         copy = copy->prev;
1785                                                 }
1786                                                 while (copy) {
1787                                                         copy->flags |= SAVEDVAR;
1788                                                         copy = copy->prev;
1789                                                 }
1790                                                 i = iptr->op1;
1791                                                 POPMANY(i);
1792                                                 OP0_1(TYPE_ADR);
1793                                                 break;
1794
1795                                         case ICMD_CLEAR_ARGREN:
1796                                                 for (i = iptr->op1; i<maxlocals; i++) 
1797                                                         argren[i] = i;
1798                                                 iptr->opc = opcode = ICMD_NOP;
1799                                                 SETDST;
1800                                                 break;
1801                                                 
1802                                         case ICMD_READONLY_ARG:
1803                                         case ICMD_READONLY_ARG+1:
1804                                         case ICMD_READONLY_ARG+2:
1805                                         case ICMD_READONLY_ARG+3:
1806                                         case ICMD_READONLY_ARG+4:
1807
1808                                                 REQUIRE_1;
1809                                                 if (curstack->varkind == LOCALVAR) {
1810                                                         i = curstack->varnum;
1811                                                         argren[iptr->op1] = i;
1812                                                         iptr->op1 = i;
1813                                                 }
1814                                                 opcode = iptr->opc = opcode - ICMD_READONLY_ARG + ICMD_ISTORE;
1815                                                 goto icmd_store;
1816
1817                                                 break;
1818
1819                                         default:
1820                                                 printf("ICMD %d at %d\n", iptr->opc, (int)(iptr-instr));
1821                                                 panic("Missing ICMD code during stack analysis");
1822                                         } /* switch */
1823
1824                                         CHECKOVERFLOW;
1825                                         
1826                                         /* XXX DEBUG */ /*dolog("iptr++");*/
1827                                         iptr++;
1828                                 } /* while instructions */
1829                                 bptr->outstack = curstack;
1830                                 bptr->outdepth = stackdepth;
1831                                 BBEND(curstack, i);
1832                         } /* if */
1833                         else
1834                                 superblockend = true;
1835                         bptr++;
1836                 } /* while blocks */
1837         } while (repeat && !deadcode);
1838
1839 #ifdef STATISTICS
1840         if (block_count > count_max_basic_blocks)
1841                 count_max_basic_blocks = block_count;
1842         count_basic_blocks += block_count;
1843         if (instr_count > count_max_javainstr)
1844                 count_max_javainstr = instr_count;
1845         count_javainstr += instr_count;
1846         if (stack_count > count_upper_bound_new_stack)
1847                 count_upper_bound_new_stack = stack_count;
1848         if ((new - stack) > count_max_new_stack)
1849                 count_max_new_stack = (new - stack);
1850
1851         b_count = block_count;
1852         bptr = block;
1853         while (--b_count >= 0) {
1854                 if (bptr->flags > BBREACHED) {
1855                         if (bptr->indepth >= 10)
1856                                 count_block_stack[10]++;
1857                         else
1858                                 count_block_stack[bptr->indepth]++;
1859                         len = bptr->icount;
1860                         if (len < 10) 
1861                                 count_block_size_distribution[len]++;
1862                         else if (len <= 12)
1863                                 count_block_size_distribution[10]++;
1864                         else if (len <= 14)
1865                                 count_block_size_distribution[11]++;
1866                         else if (len <= 16)
1867                                 count_block_size_distribution[12]++;
1868                         else if (len <= 18)
1869                                 count_block_size_distribution[13]++;
1870                         else if (len <= 20)
1871                                 count_block_size_distribution[14]++;
1872                         else if (len <= 25)
1873                                 count_block_size_distribution[15]++;
1874                         else if (len <= 30)
1875                                 count_block_size_distribution[16]++;
1876                         else
1877                                 count_block_size_distribution[17]++;
1878                 }
1879                 bptr++;
1880         }
1881
1882         if (loops == 1)
1883                 count_analyse_iterations[0]++;
1884         else if (loops == 2)
1885                 count_analyse_iterations[1]++;
1886         else if (loops == 3)
1887                 count_analyse_iterations[2]++;
1888         else if (loops == 4)
1889                 count_analyse_iterations[3]++;
1890         else
1891                 count_analyse_iterations[4]++;
1892
1893         if (block_count <= 5)
1894                 count_method_bb_distribution[0]++;
1895         else if (block_count <= 10)
1896                 count_method_bb_distribution[1]++;
1897         else if (block_count <= 15)
1898                 count_method_bb_distribution[2]++;
1899         else if (block_count <= 20)
1900                 count_method_bb_distribution[3]++;
1901         else if (block_count <= 30)
1902                 count_method_bb_distribution[4]++;
1903         else if (block_count <= 40)
1904                 count_method_bb_distribution[5]++;
1905         else if (block_count <= 50)
1906                 count_method_bb_distribution[6]++;
1907         else if (block_count <= 75)
1908                 count_method_bb_distribution[7]++;
1909         else
1910                 count_method_bb_distribution[8]++;
1911 #endif
1912 }
1913
1914
1915 void icmd_print_stack(stackptr s)
1916 {
1917         int i, j;
1918         stackptr t;
1919
1920         i = maxstack;
1921         t = s;
1922         
1923         while (t) {
1924                 i--;
1925                 t = t->prev;
1926         }
1927         j = maxstack - i;
1928         while (--i >= 0)
1929                 printf("    ");
1930         while (s) {
1931                 j--;
1932                 /* XXX remove */ /* printf("(%d)",s->flags); fflush(stdout); */
1933                 if (s->flags & SAVEDVAR)
1934                         switch (s->varkind) {
1935                         case TEMPVAR:
1936                                 if (s->flags & INMEMORY)
1937                                         printf((regs_ok) ? " M%02d" : " M??", s->regoff);
1938                                 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1939                                         printf((regs_ok) ? " F%02d" : " F??", s->regoff);
1940                                 else {
1941                                         if (regs_ok) printf(" %3s",regs[s->regoff]); else printf(" ???");
1942                                 }
1943                                 break;
1944                         case STACKVAR:
1945                                 printf(" I%02d", s->varnum);
1946                                 break;
1947                         case LOCALVAR:
1948                                 printf(" L%02d", s->varnum);
1949                                 break;
1950                         case ARGVAR:
1951                                 printf(" A%02d", s->varnum);
1952                                 break;
1953                         default:
1954                                 printf(" !%02d", j);
1955                         }
1956                 else
1957                         switch (s->varkind) {
1958                         case TEMPVAR:
1959                                 if (s->flags & INMEMORY)
1960                                         printf((regs_ok) ? " m%02d" : " m??", s->regoff);
1961                                 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1962                                         printf((regs_ok) ? " f%02d" : " f??", s->regoff);
1963                                 else {
1964                                         if (regs_ok) printf(" %3s",regs[s->regoff]); else printf(" ???");
1965                                 }
1966                                 break;
1967                         case STACKVAR:
1968                                 printf(" i%02d", s->varnum);
1969                                 break;
1970                         case LOCALVAR:
1971                                 printf(" l%02d", s->varnum);
1972                                 break;
1973                         case ARGVAR:
1974                                 printf(" a%02d", s->varnum);
1975                                 break;
1976                         default:
1977                                 printf(" ?%02d", j);
1978                         }
1979                 s = s->prev;
1980         }
1981 }
1982
1983
1984 #if 0
1985 static void print_reg(stackptr s) {
1986         if (s) {
1987                 if (s->flags & SAVEDVAR)
1988                         switch (s->varkind) {
1989                         case TEMPVAR:
1990                                 if (s->flags & INMEMORY)
1991                                         printf(" tm%02d", s->regoff);
1992                                 else
1993                                         printf(" tr%02d", s->regoff);
1994                                 break;
1995                         case STACKVAR:
1996                                 printf(" s %02d", s->varnum);
1997                                 break;
1998                         case LOCALVAR:
1999                                 printf(" l %02d", s->varnum);
2000                                 break;
2001                         case ARGVAR:
2002                                 printf(" a %02d", s->varnum);
2003                                 break;
2004                         default:
2005                                 printf(" ! %02d", s->varnum);
2006                         }
2007                 else
2008                         switch (s->varkind) {
2009                         case TEMPVAR:
2010                                 if (s->flags & INMEMORY)
2011                                         printf(" Tm%02d", s->regoff);
2012                                 else
2013                                         printf(" Tr%02d", s->regoff);
2014                                 break;
2015                         case STACKVAR:
2016                                 printf(" S %02d", s->varnum);
2017                                 break;
2018                         case LOCALVAR:
2019                                 printf(" L %02d", s->varnum);
2020                                 break;
2021                         case ARGVAR:
2022                                 printf(" A %02d", s->varnum);
2023                                 break;
2024                         default:
2025                                 printf(" ? %02d", s->varnum);
2026                         }
2027         }
2028         else
2029                 printf("     ");
2030                 
2031 }
2032 #endif
2033
2034
2035 char *icmd_builtin_name(functionptr bptr)
2036 {
2037         builtin_descriptor *bdesc = builtin_desc;
2038         while ((bdesc->opcode != 0) && (bdesc->builtin != bptr))
2039                 bdesc++;
2040         return (bdesc->opcode) ? bdesc->name : "<NOT IN TABLE>";
2041 }
2042
2043
2044 static char *jit_type[] = {
2045         "int",
2046         "lng",
2047         "flt",
2048         "dbl",
2049         "adr"
2050 };
2051
2052
2053 void show_icmd_method()
2054 {
2055         int i, j;
2056         s4  *s4ptr; /* used */
2057         basicblock *bptr;
2058         xtable *ex;
2059
2060         printf("\n");
2061         utf_fprint(stdout, class->name);
2062         printf(".");
2063         utf_fprint(stdout, method->name);
2064         printf(" ");
2065         utf_fprint(stdout, method->descriptor);
2066         printf ("\n\nMax locals: %d\n", (int) maxlocals);
2067         printf ("Max stack:  %d\n", (int) maxstack);
2068
2069         printf ("Exceptions (Number: %d):\n", exceptiontablelength);
2070         for (ex = extable; ex != NULL; ex = ex->down) {
2071                 printf("    L%03d ... ", ex->start->debug_nr );
2072                 printf("L%03d  = ", ex->end->debug_nr);
2073                 printf("L%03d\n", ex->handler->debug_nr);
2074         }
2075         
2076         printf ("Local Table:\n");
2077         for (i = 0; i < maxlocals; i++) {
2078                 printf("   %3d: ", i);
2079                 for (j = TYPE_INT; j <= TYPE_ADR; j++)
2080                         if (locals[i][j].type >= 0) {
2081                                 printf("   (%s) ", jit_type[j]);
2082                                 if (locals[i][j].flags & INMEMORY)
2083                                         printf((regs_ok) ? "m%2d" : "m??", locals[i][j].regoff);
2084                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2085                                         printf((regs_ok) ? "f%02d" : "f??", locals[i][j].regoff);
2086                                 else {
2087                                         if (regs_ok) printf("%3s",regs[locals[i][j].regoff]); else printf("???");
2088                                 }
2089                         }
2090                 printf("\n");
2091         }
2092         printf("\n");
2093
2094         printf ("Interface Table:\n");
2095         for (i = 0; i < maxstack; i++) {
2096                 if ((interfaces[i][0].type >= 0) || (interfaces[i][1].type >= 0) ||
2097                     (interfaces[i][2].type >= 0) || (interfaces[i][3].type >= 0) ||
2098                     (interfaces[i][4].type >= 0)) {
2099                         printf("   %3d: ", i);
2100                         for (j = TYPE_INT; j <= TYPE_ADR; j++)
2101                                 if (interfaces[i][j].type >= 0) {
2102                                         printf("   (%s) ", jit_type[j]);
2103                                         if (interfaces[i][j].flags & SAVEDVAR) {
2104                                                 if (interfaces[i][j].flags & INMEMORY)
2105                                                         printf((regs_ok) ? "M%2d" : "M??", interfaces[i][j].regoff);
2106                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2107                                                         printf((regs_ok) ? "F%02d" : "F??", interfaces[i][j].regoff);
2108                                                 else {
2109                                                         if (regs_ok) printf("%3s",regs[interfaces[i][j].regoff]); else printf("???");
2110                                                 }
2111                                         }
2112                                         else {
2113                                                 if (interfaces[i][j].flags & INMEMORY)
2114                                                         printf((regs_ok) ? "m%2d" : "m??", interfaces[i][j].regoff);
2115                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2116                                                         printf((regs_ok) ? "f%02d" : "f??", interfaces[i][j].regoff);
2117                                                 else {
2118                                                         if (regs_ok) printf("%3s",regs[interfaces[i][j].regoff]); else printf("???");
2119                                                 }
2120                                         }
2121                                 }
2122                         printf("\n");
2123                 }
2124         }
2125         printf("\n");
2126
2127         if (showdisassemble) {
2128 #if defined(__I386__) || defined(__X86_64__)
2129                 u1 *u1ptr;
2130                 int a;
2131
2132                 u1ptr = method->mcode + dseglen;
2133                 for (i = 0; i < block[0].mpc; i++, u1ptr++) {
2134                         a = disassinstr(u1ptr, i);
2135                         i += a;
2136                         u1ptr += a;
2137                 }
2138                 printf("\n");
2139 #else
2140                 s4ptr = (s4 *) (method->mcode + dseglen);
2141                 for (i = 0; i < block[0].mpc; i += 4, s4ptr++) {
2142                         disassinstr(*s4ptr, i); 
2143                 }
2144                 printf("\n");
2145 #endif
2146         }
2147
2148         
2149         for (bptr = block; bptr != NULL; bptr = bptr->next) {
2150                 show_icmd_block(bptr);
2151         }
2152 }
2153
2154
2155 void show_icmd_block(basicblock *bptr)
2156 {
2157         int i, j;
2158         int deadcode;
2159         s4  *s4ptr; /* used */
2160         instruction *iptr;
2161
2162         if (bptr->flags != BBDELETED) {
2163                 deadcode = bptr->flags <= BBREACHED;
2164                 printf("[");
2165                 if (deadcode)
2166                         for (j = method->maxstack; j > 0; j--)
2167                                 printf(" ?  ");
2168                 else
2169                         icmd_print_stack(bptr->instack);
2170                 printf("] L%03d(%d - %d) flags=%d:\n", bptr->debug_nr, bptr->icount, bptr->pre_count,bptr->flags);
2171                 iptr = bptr->iinstr;
2172
2173                 for (i=0; i < bptr->icount; i++, iptr++) {
2174                         printf("[");
2175                         if (deadcode) {
2176                                 for (j = method->maxstack; j > 0; j--)
2177                                         printf(" ?  ");
2178                         }
2179                         else
2180                                 icmd_print_stack(iptr->dst);
2181                         printf("]     %4d  ", i);
2182                         /* XXX remove */ /*fflush(stdout);*/
2183                         show_icmd(iptr,deadcode);
2184                         printf("\n");
2185                 }
2186
2187                 if (showdisassemble && (!deadcode)) {
2188 #if defined(__I386__) || defined(__X86_64__)
2189                         u1 *u1ptr;
2190                         int a;
2191
2192                         printf("\n");
2193                         i = bptr->mpc;
2194                         u1ptr = method->mcode + dseglen + i;
2195
2196                         if (bptr->next != NULL) {
2197                                 for (; i < bptr->next->mpc; i++, u1ptr++) {
2198                                         a = disassinstr(u1ptr, i);
2199                                         i += a;
2200                                         u1ptr += a;
2201                                 }
2202                                 printf("\n");
2203
2204                         } else {
2205                                 for (; u1ptr < (u1 *) (method->mcode + method->mcodelength); i++, u1ptr++) {
2206                                         a = disassinstr(u1ptr, i); 
2207                                         i += a;
2208                                         u1ptr += a;
2209                                 }
2210                                 printf("\n");
2211                         }
2212 #else
2213                         printf("\n");
2214                         i = bptr->mpc;
2215                         s4ptr = (s4 *) (method->mcode + dseglen + i);
2216
2217                         if (bptr->next != NULL) {
2218                                 for (; i < bptr->next->mpc; i += 4, s4ptr++) {
2219                                         disassinstr(*s4ptr, i); 
2220                                 }
2221                                 printf("\n");
2222
2223                         } else {
2224                                 for (; s4ptr < (s4 *) (method->mcode + method->mcodelength); i += 4, s4ptr++) {
2225                                         disassinstr(*s4ptr, i); 
2226                                 }
2227                                 printf("\n");
2228                         }
2229 #endif
2230                 }
2231         }
2232 }
2233
2234
2235 void show_icmd(instruction *iptr,bool deadcode)
2236 {
2237         int j;
2238         s4  *s4ptr;
2239         void **tptr;
2240         
2241         printf("%s", icmd_names[iptr->opc]);
2242
2243         switch ((int) iptr->opc) {
2244         case ICMD_IADDCONST:
2245         case ICMD_ISUBCONST:
2246         case ICMD_IMULCONST:
2247         case ICMD_IDIVPOW2:
2248         case ICMD_IREMPOW2:
2249         case ICMD_IREM0X10001:
2250         case ICMD_IANDCONST:
2251         case ICMD_IORCONST:
2252         case ICMD_IXORCONST:
2253         case ICMD_ISHLCONST:
2254         case ICMD_ISHRCONST:
2255         case ICMD_IUSHRCONST:
2256         case ICMD_LSHLCONST:
2257         case ICMD_LSHRCONST:
2258         case ICMD_LUSHRCONST:
2259         case ICMD_ICONST:
2260         case ICMD_ELSE_ICONST:
2261         case ICMD_IFEQ_ICONST:
2262         case ICMD_IFNE_ICONST:
2263         case ICMD_IFLT_ICONST:
2264         case ICMD_IFGE_ICONST:
2265         case ICMD_IFGT_ICONST:
2266         case ICMD_IFLE_ICONST:
2267                 printf(" %d", iptr->val.i);
2268                 break;
2269
2270         case ICMD_LADDCONST:
2271         case ICMD_LSUBCONST:
2272         case ICMD_LMULCONST:
2273         case ICMD_LDIVPOW2:
2274         case ICMD_LREMPOW2:
2275         case ICMD_LANDCONST:
2276         case ICMD_LORCONST:
2277         case ICMD_LXORCONST:
2278         case ICMD_LCONST:
2279 #if defined(__I386__)
2280                 printf(" %lld", iptr->val.l);
2281 #else
2282                 printf(" %ld", iptr->val.l);
2283 #endif
2284                 break;
2285
2286         case ICMD_FCONST:
2287                 printf(" %f", iptr->val.f);
2288                 break;
2289
2290         case ICMD_DCONST:
2291                 printf(" %f", iptr->val.d);
2292                 break;
2293
2294         case ICMD_ACONST:
2295                 printf(" %p", iptr->val.a);
2296                 break;
2297
2298         case ICMD_GETFIELD:
2299         case ICMD_PUTFIELD:
2300                 printf(" %d,", ((fieldinfo *) iptr->val.a)->offset);
2301         case ICMD_PUTSTATIC:
2302         case ICMD_GETSTATIC:
2303                 printf(" ");
2304                 utf_fprint(stdout,
2305                                    ((fieldinfo *) iptr->val.a)->class->name);
2306                 printf(".");
2307                 utf_fprint(stdout,
2308                                    ((fieldinfo *) iptr->val.a)->name);
2309                 printf(" (type ");
2310                 utf_fprint(stdout,
2311                                    ((fieldinfo *) iptr->val.a)->descriptor);
2312                 printf(")");
2313                 break;
2314
2315         case ICMD_IINC:
2316                 printf(" %d + %d", iptr->op1, iptr->val.i);
2317                 break;
2318
2319         case ICMD_IASTORE:
2320         case ICMD_SASTORE:
2321         case ICMD_BASTORE:
2322         case ICMD_CASTORE:
2323         case ICMD_LASTORE:
2324         case ICMD_DASTORE:
2325         case ICMD_FASTORE:
2326         case ICMD_AASTORE:
2327
2328         case ICMD_IALOAD:
2329         case ICMD_SALOAD:
2330         case ICMD_BALOAD:
2331         case ICMD_CALOAD:
2332         case ICMD_LALOAD:
2333         case ICMD_DALOAD:
2334         case ICMD_FALOAD:
2335         case ICMD_AALOAD:
2336                 if (iptr->op1 != 0)
2337                         printf("(opt.)");
2338                 break;
2339
2340         case ICMD_RET:
2341         case ICMD_ILOAD:
2342         case ICMD_LLOAD:
2343         case ICMD_FLOAD:
2344         case ICMD_DLOAD:
2345         case ICMD_ALOAD:
2346         case ICMD_ISTORE:
2347         case ICMD_LSTORE:
2348         case ICMD_FSTORE:
2349         case ICMD_DSTORE:
2350         case ICMD_ASTORE:
2351                 printf(" %d", iptr->op1);
2352                 break;
2353
2354         case ICMD_NEW:
2355                 printf(" ");
2356                 utf_fprint(stdout,
2357                                    ((classinfo *) iptr->val.a)->name);
2358                 break;
2359
2360         case ICMD_NEWARRAY:
2361                 switch (iptr->op1) {
2362                 case 4:
2363                         printf(" boolean");
2364                         break;
2365                 case 5:
2366                         printf(" char");
2367                         break;
2368                 case 6:
2369                         printf(" float");
2370                         break;
2371                 case 7:
2372                         printf(" double");
2373                         break;
2374                 case 8:
2375                         printf(" byte");
2376                         break;
2377                 case 9:
2378                         printf(" short");
2379                         break;
2380                 case 10:
2381                         printf(" int");
2382                         break;
2383                 case 11:
2384                         printf(" long");
2385                         break;
2386                 }
2387                 break;
2388
2389         case ICMD_ANEWARRAY:
2390                 if (iptr->op1) {
2391                         printf(" ");
2392                         utf_fprint(stdout,
2393                                            ((classinfo *) iptr->val.a)->name);
2394                 }
2395                 break;
2396
2397         case ICMD_MULTIANEWARRAY:
2398                 {
2399                         vftbl *vft;
2400                         printf(" %d ",iptr->op1);
2401                         vft = (vftbl *)iptr->val.a;
2402                         if (vft)
2403                                 utf_fprint(stdout,vft->class->name);
2404                         else
2405                                 printf("<null>");
2406                 }
2407                 break;
2408
2409         case ICMD_CHECKCAST:
2410         case ICMD_INSTANCEOF:
2411                 if (iptr->op1) {
2412                         classinfo *c = iptr->val.a;
2413                         if (c->flags & ACC_INTERFACE)
2414                                 printf(" (INTERFACE) ");
2415                         else
2416                                 printf(" (CLASS,%3d) ", c->vftbl->diffval);
2417                         utf_fprint(stdout, c->name);
2418                 }
2419                 break;
2420
2421         case ICMD_BUILTIN3:
2422         case ICMD_BUILTIN2:
2423         case ICMD_BUILTIN1:
2424                 printf(" %s", icmd_builtin_name((functionptr) iptr->val.a));
2425                 break;
2426
2427         case ICMD_INVOKEVIRTUAL:
2428         case ICMD_INVOKESPECIAL:
2429         case ICMD_INVOKESTATIC:
2430         case ICMD_INVOKEINTERFACE:
2431                 printf(" ");
2432                 utf_fprint(stdout,
2433                                    ((methodinfo *) iptr->val.a)->class->name);
2434                 printf(".");
2435                 utf_fprint(stdout,
2436                                    ((methodinfo *) iptr->val.a)->name);
2437                 break;
2438
2439         case ICMD_IFEQ:
2440         case ICMD_IFNE:
2441         case ICMD_IFLT:
2442         case ICMD_IFGE:
2443         case ICMD_IFGT:
2444         case ICMD_IFLE:
2445                 if (deadcode || !iptr->target)
2446                         printf("(%d) op1=%d", iptr->val.i, iptr->op1);
2447                 else
2448                         printf("(%d) L%03d", iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
2449                 break;
2450
2451         case ICMD_IF_LEQ:
2452         case ICMD_IF_LNE:
2453         case ICMD_IF_LLT:
2454         case ICMD_IF_LGE:
2455         case ICMD_IF_LGT:
2456         case ICMD_IF_LLE:
2457                 if (deadcode || !iptr->target)
2458                         printf("(%lld) op1=%d", iptr->val.l, iptr->op1);
2459                 else
2460                         printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
2461                 break;
2462
2463         case ICMD_JSR:
2464         case ICMD_GOTO:
2465         case ICMD_IFNULL:
2466         case ICMD_IFNONNULL:
2467         case ICMD_IF_ICMPEQ:
2468         case ICMD_IF_ICMPNE:
2469         case ICMD_IF_ICMPLT:
2470         case ICMD_IF_ICMPGE:
2471         case ICMD_IF_ICMPGT:
2472         case ICMD_IF_ICMPLE:
2473         case ICMD_IF_LCMPEQ:
2474         case ICMD_IF_LCMPNE:
2475         case ICMD_IF_LCMPLT:
2476         case ICMD_IF_LCMPGE:
2477         case ICMD_IF_LCMPGT:
2478         case ICMD_IF_LCMPLE:
2479         case ICMD_IF_ACMPEQ:
2480         case ICMD_IF_ACMPNE:
2481                 if (deadcode || !iptr->target)
2482                         printf(" op1=%d", iptr->op1);
2483                 else
2484                         printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
2485                 break;
2486
2487         case ICMD_TABLESWITCH:
2488                 s4ptr = (s4*)iptr->val.a;
2489
2490                 if (deadcode || !iptr->target) {
2491                         printf(" %d;", *s4ptr);
2492                 }
2493                 else {
2494                         tptr = (void **) iptr->target;
2495                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr); 
2496                         tptr++;
2497                 }
2498
2499                 s4ptr++;         /* skip default */
2500                 j = *s4ptr++;                               /* low     */
2501                 j = *s4ptr++ - j;                           /* high    */
2502                 while (j >= 0) {
2503                         if (deadcode || !*tptr)
2504                                 printf(" %d", *s4ptr++);
2505                         else {
2506                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2507                                 tptr++;
2508                         }
2509                         j--;
2510                 }
2511                 break;
2512
2513         case ICMD_LOOKUPSWITCH:
2514                 s4ptr = (s4*)iptr->val.a;
2515
2516                 if (deadcode || !iptr->target) {
2517                         printf(" %d;", *s4ptr);
2518                 }
2519                 else {
2520                         tptr = (void **) iptr->target;
2521                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
2522                         tptr++;
2523                 }
2524                 s4ptr++;                                         /* default */
2525                 j = *s4ptr++;                                    /* count   */
2526
2527                 while (--j >= 0) {
2528                         if (deadcode || !*tptr) {
2529                                 s4ptr++; /* skip value */
2530                                 printf(" %d",*s4ptr++);
2531                         }
2532                         else {
2533                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2534                                 tptr++;
2535                         }
2536                 }
2537                 break;
2538         }
2539 }
2540
2541
2542 /*
2543  * These are local overrides for various environment variables in Emacs.
2544  * Please do not remove this and leave it at the end of the file, where
2545  * Emacs will automagically detect them.
2546  * ---------------------------------------------------------------------
2547  * Local variables:
2548  * mode: c
2549  * indent-tabs-mode: t
2550  * c-basic-offset: 4
2551  * tab-width: 4
2552  * End:
2553  */