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