3de5b75c461e0402c9f3549ac47935daa4899c79
[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 768 2003-12-13 22:56:53Z twisti $
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 #if defined(__I386__)
647                                                                 method_uses_edx = true;
648 #endif
649                                                                 goto icmd_lconst_tail;
650 #endif
651 #if SUPPORT_LONG_DIV
652                                                         case ICMD_LDIV:
653                                                                 if (iptr[0].val.l == 0x00000002)
654                                                                         iptr[0].val.i = 1;
655                                                                 else if (iptr[0].val.l == 0x00000004)
656                                                                         iptr[0].val.i = 2;
657                                                                 else if (iptr[0].val.l == 0x00000008)
658                                                                         iptr[0].val.i = 3;
659                                                                 else if (iptr[0].val.l == 0x00000010)
660                                                                         iptr[0].val.i = 4;
661                                                                 else if (iptr[0].val.l == 0x00000020)
662                                                                         iptr[0].val.i = 5;
663                                                                 else if (iptr[0].val.l == 0x00000040)
664                                                                         iptr[0].val.i = 6;
665                                                                 else if (iptr[0].val.l == 0x00000080)
666                                                                         iptr[0].val.i = 7;
667                                                                 else if (iptr[0].val.l == 0x00000100)
668                                                                         iptr[0].val.i = 8;
669                                                                 else if (iptr[0].val.l == 0x00000200)
670                                                                         iptr[0].val.i = 9;
671                                                                 else if (iptr[0].val.l == 0x00000400)
672                                                                         iptr[0].val.i = 10;
673                                                                 else if (iptr[0].val.l == 0x00000800)
674                                                                         iptr[0].val.i = 11;
675                                                                 else if (iptr[0].val.l == 0x00001000)
676                                                                         iptr[0].val.i = 12;
677                                                                 else if (iptr[0].val.l == 0x00002000)
678                                                                         iptr[0].val.i = 13;
679                                                                 else if (iptr[0].val.l == 0x00004000)
680                                                                         iptr[0].val.i = 14;
681                                                                 else if (iptr[0].val.l == 0x00008000)
682                                                                         iptr[0].val.i = 15;
683                                                                 else if (iptr[0].val.l == 0x00010000)
684                                                                         iptr[0].val.i = 16;
685                                                                 else if (iptr[0].val.l == 0x00020000)
686                                                                         iptr[0].val.i = 17;
687                                                                 else if (iptr[0].val.l == 0x00040000)
688                                                                         iptr[0].val.i = 18;
689                                                                 else if (iptr[0].val.l == 0x00080000)
690                                                                         iptr[0].val.i = 19;
691                                                                 else if (iptr[0].val.l == 0x00100000)
692                                                                         iptr[0].val.i = 20;
693                                                                 else if (iptr[0].val.l == 0x00200000)
694                                                                         iptr[0].val.i = 21;
695                                                                 else if (iptr[0].val.l == 0x00400000)
696                                                                         iptr[0].val.i = 22;
697                                                                 else if (iptr[0].val.l == 0x00800000)
698                                                                         iptr[0].val.i = 23;
699                                                                 else if (iptr[0].val.l == 0x01000000)
700                                                                         iptr[0].val.i = 24;
701                                                                 else if (iptr[0].val.l == 0x02000000)
702                                                                         iptr[0].val.i = 25;
703                                                                 else if (iptr[0].val.l == 0x04000000)
704                                                                         iptr[0].val.i = 26;
705                                                                 else if (iptr[0].val.l == 0x08000000)
706                                                                         iptr[0].val.i = 27;
707                                                                 else if (iptr[0].val.l == 0x10000000)
708                                                                         iptr[0].val.i = 28;
709                                                                 else if (iptr[0].val.l == 0x20000000)
710                                                                         iptr[0].val.i = 29;
711                                                                 else if (iptr[0].val.l == 0x40000000)
712                                                                         iptr[0].val.i = 30;
713                                                                 else if (iptr[0].val.l == 0x80000000)
714                                                                         iptr[0].val.i = 31;
715                                                                 else {
716                                                                         PUSHCONST(TYPE_LNG);
717                                                                         break;
718                                                                 }
719                                                                 iptr[0].opc = ICMD_LDIVPOW2;
720                                                                 goto icmd_lconst_tail;
721                                                         case ICMD_LREM:
722 #if !defined(NO_DIV_OPT)
723                                                                 if (iptr[0].val.l == 0x10001) {
724                                                                         iptr[0].opc = ICMD_LREM0X10001;
725                                                                         goto icmd_lconst_tail;
726                                                                 }
727 #endif
728                                                                 if ((iptr[0].val.l == 0x00000002) ||
729                                                                         (iptr[0].val.l == 0x00000004) ||
730                                                                         (iptr[0].val.l == 0x00000008) ||
731                                                                         (iptr[0].val.l == 0x00000010) ||
732                                                                         (iptr[0].val.l == 0x00000020) ||
733                                                                         (iptr[0].val.l == 0x00000040) ||
734                                                                         (iptr[0].val.l == 0x00000080) ||
735                                                                         (iptr[0].val.l == 0x00000100) ||
736                                                                         (iptr[0].val.l == 0x00000200) ||
737                                                                         (iptr[0].val.l == 0x00000400) ||
738                                                                         (iptr[0].val.l == 0x00000800) ||
739                                                                         (iptr[0].val.l == 0x00001000) ||
740                                                                         (iptr[0].val.l == 0x00002000) ||
741                                                                         (iptr[0].val.l == 0x00004000) ||
742                                                                         (iptr[0].val.l == 0x00008000) ||
743                                                                         (iptr[0].val.l == 0x00010000) ||
744                                                                         (iptr[0].val.l == 0x00020000) ||
745                                                                         (iptr[0].val.l == 0x00040000) ||
746                                                                         (iptr[0].val.l == 0x00080000) ||
747                                                                         (iptr[0].val.l == 0x00100000) ||
748                                                                         (iptr[0].val.l == 0x00200000) ||
749                                                                         (iptr[0].val.l == 0x00400000) ||
750                                                                         (iptr[0].val.l == 0x00800000) ||
751                                                                         (iptr[0].val.l == 0x01000000) ||
752                                                                         (iptr[0].val.l == 0x02000000) ||
753                                                                         (iptr[0].val.l == 0x04000000) ||
754                                                                         (iptr[0].val.l == 0x08000000) ||
755                                                                         (iptr[0].val.l == 0x10000000) ||
756                                                                         (iptr[0].val.l == 0x20000000) ||
757                                                                         (iptr[0].val.l == 0x40000000) ||
758                                                                         (iptr[0].val.l == 0x80000000)) {
759                                                                         iptr[0].opc = ICMD_LREMPOW2;
760                                                                         iptr[0].val.l -= 1;
761                                                                         goto icmd_lconst_tail;
762                                                                 }
763                                                                 PUSHCONST(TYPE_LNG);
764                                                                 break;
765 #endif
766 #if SUPPORT_LONG_LOG
767                                                         case ICMD_LAND:
768                                                                 iptr[0].opc = ICMD_LANDCONST;
769                                                                 goto icmd_lconst_tail;
770                                                         case ICMD_LOR:
771                                                                 iptr[0].opc = ICMD_LORCONST;
772                                                                 goto icmd_lconst_tail;
773                                                         case ICMD_LXOR:
774                                                                 iptr[0].opc = ICMD_LXORCONST;
775                                                                 goto icmd_lconst_tail;
776 #endif
777 #if !defined(NOLONG_CONDITIONAL)
778                                                         case ICMD_LCMP:
779                                                                 if ((len > 1) && (iptr[2].val.i == 0)) {
780                                                                         switch (iptr[2].opc) {
781                                                                         case ICMD_IFEQ:
782                                                                                 iptr[0].opc = ICMD_IF_LEQ;
783                                                                         icmd_lconst_lcmp_tail:
784                                                                                 iptr[0].op1 = iptr[2].op1;
785                                                                                 bptr->icount -= 2;
786                                                                                 len -= 2;
787                                                                                 /* iptr[1].opc = ICMD_NOP;
788                                                                                    iptr[2].opc = ICMD_NOP; */
789                                                                                 OP1_0(TYPE_LNG);
790                                                                                 tbptr = block + block_index[iptr->op1];
791
792                                                                                 iptr[0].target = (void *) tbptr;
793
794                                                                                 MARKREACHED(tbptr, copy);
795                                                                                 COUNT(count_pcmd_bra);
796                                                                                 COUNT(count_pcmd_op);
797                                                                                 break;
798                                                                         case ICMD_IFNE:
799                                                                                 iptr[0].opc = ICMD_IF_LNE;
800                                                                                 goto icmd_lconst_lcmp_tail;
801                                                                         case ICMD_IFLT:
802                                                                                 iptr[0].opc = ICMD_IF_LLT;
803                                                                                 goto icmd_lconst_lcmp_tail;
804                                                                         case ICMD_IFGT:
805                                                                                 iptr[0].opc = ICMD_IF_LGT;
806                                                                                 goto icmd_lconst_lcmp_tail;
807                                                                         case ICMD_IFLE:
808                                                                                 iptr[0].opc = ICMD_IF_LLE;
809                                                                                 goto icmd_lconst_lcmp_tail;
810                                                                         case ICMD_IFGE:
811                                                                                 iptr[0].opc = ICMD_IF_LGE;
812                                                                                 goto icmd_lconst_lcmp_tail;
813                                                                         default:
814                                                                                 PUSHCONST(TYPE_LNG);
815                                                                         } /* switch (iptr[2].opc) */
816                                                                 } /* if (iptr[2].val.i == 0) */
817                                                                 else
818                                                                         PUSHCONST(TYPE_LNG);
819                                                                 break;
820 #endif
821                                                         default:
822                                                                 PUSHCONST(TYPE_LNG);
823                                                         }
824                                                 }
825                                                 else
826                                                         PUSHCONST(TYPE_LNG);
827                                                 break;
828                                         case ICMD_FCONST:
829                                                 COUNT(count_pcmd_load);
830                                                 PUSHCONST(TYPE_FLT);
831                                                 break;
832                                         case ICMD_DCONST:
833                                                 COUNT(count_pcmd_load);
834                                                 PUSHCONST(TYPE_DBL);
835                                                 break;
836                                         case ICMD_ACONST:
837                                                 COUNT(count_pcmd_load);
838                                                 PUSHCONST(TYPE_ADR);
839                                                 break;
840
841                                                 /* pop 0 push 1 load */
842                                                 
843                                         case ICMD_ILOAD:
844                                         case ICMD_LLOAD:
845                                         case ICMD_FLOAD:
846                                         case ICMD_DLOAD:
847                                         case ICMD_ALOAD:
848                                                 COUNT(count_load_instruction);
849                                                 i = opcode-ICMD_ILOAD;
850                                                 iptr->op1 = argren[iptr->op1];
851                                                 locals[iptr->op1][i].type = i;
852                                                 LOAD(i, LOCALVAR, iptr->op1);
853                                                 break;
854
855                                                 /* pop 2 push 1 */
856
857                                         case ICMD_LALOAD:
858 #if defined(__I386__)
859                                                 method_uses_edx = true;
860 #endif
861                                         case ICMD_IALOAD:
862                                         case ICMD_FALOAD:
863                                         case ICMD_DALOAD:
864                                         case ICMD_AALOAD:
865                                                 COUNT(count_check_null);
866                                                 COUNT(count_check_bound);
867                                                 COUNT(count_pcmd_mem);
868                                                 OP2IAT_1(opcode-ICMD_IALOAD);
869                                                 break;
870
871                                         case ICMD_BALOAD:
872                                         case ICMD_CALOAD:
873                                         case ICMD_SALOAD:
874                                                 COUNT(count_check_null);
875                                                 COUNT(count_check_bound);
876                                                 COUNT(count_pcmd_mem);
877                                                 OP2IAT_1(TYPE_INT);
878                                                 break;
879
880                                                 /* pop 0 push 0 iinc */
881
882                                         case ICMD_IINC:
883 #ifdef STATISTICS
884                                                 i = stackdepth;
885                                                 if (i >= 10)
886                                                         count_store_depth[10]++;
887                                                 else
888                                                         count_store_depth[i]++;
889 #endif
890                                                 copy = curstack;
891                                                 i = stackdepth - 1;
892                                                 while (copy) {
893                                                         if ((copy->varkind == LOCALVAR) &&
894                                                                 (copy->varnum == iptr->op1)) {
895                                                                 copy->varkind = TEMPVAR;
896                                                                 copy->varnum = i;
897                                                         }
898                                                         i--;
899                                                         copy = copy->prev;
900                                                 }
901                                                 SETDST;
902                                                 break;
903
904                                                 /* pop 1 push 0 store */
905
906                                         case ICMD_ISTORE:
907                                         case ICMD_LSTORE:
908                                         case ICMD_FSTORE:
909                                         case ICMD_DSTORE:
910                                         case ICMD_ASTORE:
911                                         icmd_store:
912                                                 REQUIRE_1;
913
914                                         i = opcode - ICMD_ISTORE;
915                                         locals[iptr->op1][i].type = i;
916 #ifdef STATISTICS
917                                         count_pcmd_store++;
918                                         i = new - curstack;
919                                         if (i >= 20)
920                                                 count_store_length[20]++;
921                                         else
922                                                 count_store_length[i]++;
923                                         i = stackdepth - 1;
924                                         if (i >= 10)
925                                                 count_store_depth[10]++;
926                                         else
927                                                 count_store_depth[i]++;
928 #endif
929                                         copy = curstack->prev;
930                                         i = stackdepth - 2;
931                                         while (copy) {
932                                                 if ((copy->varkind == LOCALVAR) &&
933                                                         (copy->varnum == iptr->op1)) {
934                                                         copy->varkind = TEMPVAR;
935                                                         copy->varnum = i;
936                                                 }
937                                                 i--;
938                                                 copy = copy->prev;
939                                         }
940                                         if ((new - curstack) == 1) {
941                                                 curstack->varkind = LOCALVAR;
942                                                 curstack->varnum = iptr->op1;
943                                         };
944                                         STORE(opcode-ICMD_ISTORE);
945                                         break;
946
947                                         /* pop 3 push 0 */
948
949                                         case ICMD_IASTORE:
950                                         case ICMD_AASTORE:
951                                         case ICMD_LASTORE:
952 #if defined(__I386__)
953                                                 method_uses_edx = true;
954 #endif
955                                         case ICMD_FASTORE:
956                                         case ICMD_DASTORE:
957                                                 COUNT(count_check_null);
958                                                 COUNT(count_check_bound);
959                                                 COUNT(count_pcmd_mem);
960                                                 OP3TIA_0(opcode-ICMD_IASTORE);
961                                                 break;
962
963                                         case ICMD_BASTORE:
964                                         case ICMD_CASTORE:
965                                         case ICMD_SASTORE:
966                                                 COUNT(count_check_null);
967                                                 COUNT(count_check_bound);
968                                                 COUNT(count_pcmd_mem);
969                                                 OP3TIA_0(TYPE_INT);
970 #if defined(__I386__)
971                                                 method_uses_edx = true;
972 #endif
973                                                 break;
974
975                                                 /* pop 1 push 0 */
976
977                                         case ICMD_POP:
978                                                 OP1_0ANY;
979                                                 break;
980
981                                         case ICMD_IRETURN:
982                                         case ICMD_LRETURN:
983                                         case ICMD_FRETURN:
984                                         case ICMD_DRETURN:
985                                         case ICMD_ARETURN:
986                                                 COUNT(count_pcmd_return);
987                                                 OP1_0(opcode-ICMD_IRETURN);
988                                                 superblockend = true;
989                                                 break;
990
991                                         case ICMD_ATHROW:
992                                                 COUNT(count_check_null);
993                                                 OP1_0(TYPE_ADR);
994                                                 STACKRESET;
995                                                 SETDST;
996                                                 superblockend = true;
997                                                 break;
998
999                                         case ICMD_PUTSTATIC:
1000                                                 COUNT(count_pcmd_mem);
1001                                                 OP1_0(iptr->op1);
1002                                                 break;
1003
1004                                                 /* pop 1 push 0 branch */
1005
1006                                         case ICMD_IFNULL:
1007                                         case ICMD_IFNONNULL:
1008                                                 COUNT(count_pcmd_bra);
1009                                                 OP1_0(TYPE_ADR);
1010                                                 tbptr = block + block_index[iptr->op1];
1011
1012                                                 iptr[0].target = (void *) tbptr;
1013
1014                                                 MARKREACHED(tbptr, copy);
1015                                                 break;
1016
1017                                         case ICMD_IFEQ:
1018                                         case ICMD_IFNE:
1019                                         case ICMD_IFLT:
1020                                         case ICMD_IFGE:
1021                                         case ICMD_IFGT:
1022                                         case ICMD_IFLE:
1023                                                 COUNT(count_pcmd_bra);
1024 #ifdef CONDITIONAL_LOADCONST
1025                                                 {
1026                                                         tbptr = block + b_index;
1027                                                         if ((b_count >= 3) &&
1028                                                             ((b_index + 2) == block_index[iptr[0].op1]) &&
1029                                                             (tbptr[1].pre_count == 1) &&
1030                                                             (iptr[1].opc == ICMD_ICONST) &&
1031                                                             (iptr[2].opc == ICMD_GOTO)   &&
1032                                                             ((b_index + 3) == block_index[iptr[2].op1]) &&
1033                                                             (tbptr[2].pre_count == 1) &&
1034                                                             (iptr[3].opc == ICMD_ICONST)) {
1035                                                                 OP1_1(TYPE_INT, TYPE_INT);
1036                                                                 switch (iptr[0].opc) {
1037                                                                 case ICMD_IFEQ:
1038                                                                         iptr[0].opc = ICMD_IFNE_ICONST;
1039                                                                         break;
1040                                                                 case ICMD_IFNE:
1041                                                                         iptr[0].opc = ICMD_IFEQ_ICONST;
1042                                                                         break;
1043                                                                 case ICMD_IFLT:
1044                                                                         iptr[0].opc = ICMD_IFGE_ICONST;
1045                                                                         break;
1046                                                                 case ICMD_IFGE:
1047                                                                         iptr[0].opc = ICMD_IFLT_ICONST;
1048                                                                         break;
1049                                                                 case ICMD_IFGT:
1050                                                                         iptr[0].opc = ICMD_IFLE_ICONST;
1051                                                                         break;
1052                                                                 case ICMD_IFLE:
1053                                                                         iptr[0].opc = ICMD_IFGT_ICONST;
1054                                                                         break;
1055                                                                 }
1056                                                                 iptr[0].val.i = iptr[1].val.i;
1057                                                                 iptr[1].opc = ICMD_ELSE_ICONST;
1058                                                                 iptr[1].val.i = iptr[3].val.i;
1059                                                                 iptr[2].opc = ICMD_NOP;
1060                                                                 iptr[3].opc = ICMD_NOP;
1061                                                                 tbptr[1].flags = BBDELETED;
1062                                                                 tbptr[2].flags = BBDELETED;
1063                                                                 tbptr[1].icount = 0;
1064                                                                 tbptr[2].icount = 0;
1065                                                                 if (tbptr[3].pre_count == 2) {
1066                                                                         len += tbptr[3].icount + 3;
1067                                                                         bptr->icount += tbptr[3].icount + 3;
1068                                                                         tbptr[3].flags = BBDELETED;
1069                                                                         tbptr[3].icount = 0;
1070                                                                         b_index++;
1071                                                                 }
1072                                                                 else {
1073                                                                         bptr->icount++;
1074                                                                         len ++;
1075                                                                 }
1076                                                                 b_index += 2;
1077                                                                 break;
1078                                                         }
1079                                                 }
1080 #endif
1081                                                 OP1_0(TYPE_INT);
1082                                                 tbptr = block + block_index[iptr->op1];
1083
1084                                                 iptr[0].target = (void *) tbptr;
1085
1086                                                 MARKREACHED(tbptr, copy);
1087                                                 break;
1088
1089                                                 /* pop 0 push 0 branch */
1090
1091                                         case ICMD_GOTO:
1092                                                 COUNT(count_pcmd_bra);
1093                                                 tbptr = block + block_index[iptr->op1];
1094
1095                                                 iptr[0].target = (void *) tbptr;
1096
1097                                                 MARKREACHED(tbptr, copy);
1098                                                 SETDST;
1099                                                 superblockend = true;
1100                                                 break;
1101
1102                                                 /* pop 1 push 0 table branch */
1103
1104                                         case ICMD_TABLESWITCH:
1105                                                 COUNT(count_pcmd_table);
1106                                                 OP1_0(TYPE_INT);
1107                                                 s4ptr = iptr->val.a;
1108                                                 tbptr = block + block_index[*s4ptr++]; /* default */
1109                                                 MARKREACHED(tbptr, copy);
1110                                                 i = *s4ptr++;                          /* low     */
1111                                                 i = *s4ptr++ - i + 1;                  /* high    */
1112
1113                                                 tptr = DMNEW(void*, i+1);
1114                                                 iptr->target = (void *) tptr;
1115
1116                                                 tptr[0] = (void *) tbptr;
1117                                                 tptr++;
1118
1119                                                 while (--i >= 0) {
1120                                                         tbptr = block + block_index[*s4ptr++];
1121
1122                                                         tptr[0] = (void *) tbptr;
1123                                                         tptr++;
1124
1125                                                         MARKREACHED(tbptr, copy);
1126                                                 }
1127                                                 SETDST;
1128                                                 superblockend = true;
1129                                                 break;
1130                                                         
1131                                                 /* pop 1 push 0 table branch */
1132
1133                                         case ICMD_LOOKUPSWITCH:
1134                                                 COUNT(count_pcmd_table);
1135                                                 OP1_0(TYPE_INT);
1136                                                 s4ptr = iptr->val.a;
1137                                                 tbptr = block + block_index[*s4ptr++]; /* default */
1138                                                 MARKREACHED(tbptr, copy);
1139                                                 i = *s4ptr++;                          /* count   */
1140
1141                                                 tptr = DMNEW(void*, i+1);
1142                                                 iptr->target = (void *) tptr;
1143
1144                                                 tptr[0] = (void *) tbptr;
1145                                                 tptr++;
1146
1147                                                 while (--i >= 0) {
1148                                                         tbptr = block + block_index[s4ptr[1]];
1149
1150                                                         tptr[0] = (void *) tbptr;
1151                                                         tptr++;
1152                                                                 
1153                                                         MARKREACHED(tbptr, copy);
1154                                                         s4ptr += 2;
1155                                                 }
1156                                                 SETDST;
1157                                                 superblockend = true;
1158                                                 break;
1159
1160                                         case ICMD_NULLCHECKPOP:
1161                                         case ICMD_MONITORENTER:
1162                                                 COUNT(count_check_null);
1163                                         case ICMD_MONITOREXIT:
1164                                                 OP1_0(TYPE_ADR);
1165                                                 break;
1166
1167                                                 /* pop 2 push 0 branch */
1168
1169                                         case ICMD_IF_ICMPEQ:
1170                                         case ICMD_IF_ICMPNE:
1171                                         case ICMD_IF_ICMPLT:
1172                                         case ICMD_IF_ICMPGE:
1173                                         case ICMD_IF_ICMPGT:
1174                                         case ICMD_IF_ICMPLE:
1175                                                 COUNT(count_pcmd_bra);
1176                                                 OP2_0(TYPE_INT);
1177                                                 tbptr = block + block_index[iptr->op1];
1178                                                         
1179                                                 iptr[0].target = (void *) tbptr;
1180
1181                                                 MARKREACHED(tbptr, copy);
1182                                                 break;
1183
1184                                         case ICMD_IF_ACMPEQ:
1185                                         case ICMD_IF_ACMPNE:
1186                                                 COUNT(count_pcmd_bra);
1187                                                 OP2_0(TYPE_ADR);
1188                                                 tbptr = block + block_index[iptr->op1];
1189
1190                                                 iptr[0].target = (void *) tbptr;
1191
1192                                                 MARKREACHED(tbptr, copy);
1193                                                 break;
1194
1195                                                 /* pop 2 push 0 */
1196
1197                                         case ICMD_PUTFIELD:
1198                                                 COUNT(count_check_null);
1199                                                 COUNT(count_pcmd_mem);
1200                                                 OPTT2_0(iptr->op1,TYPE_ADR);
1201                                                 break;
1202
1203                                         case ICMD_POP2:
1204                                                 REQUIRE_1;
1205                                                 if (! IS_2_WORD_TYPE(curstack->type)) {
1206                                                         OP1_0ANY;                /* second pop */
1207                                                 }
1208                                                 else
1209                                                         iptr->opc = ICMD_POP;
1210                                                 OP1_0ANY;
1211                                                 break;
1212
1213                                                 /* pop 0 push 1 dup */
1214                                                 
1215                                         case ICMD_DUP:
1216                                                 COUNT(count_dup_instruction);
1217                                                 DUP;
1218                                                 break;
1219
1220                                         case ICMD_DUP2:
1221                                                 REQUIRE_1;
1222                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1223                                                         iptr->opc = ICMD_DUP;
1224                                                         DUP;
1225                                                 }
1226                                                 else {
1227                                                         REQUIRE_2;
1228                                                         copy = curstack;
1229                                                         NEWSTACK(copy->prev->type, copy->prev->varkind,
1230                                                                          copy->prev->varnum);
1231                                                         NEWSTACK(copy->type, copy->varkind,
1232                                                                          copy->varnum);
1233                                                         SETDST;
1234                                                         stackdepth+=2;
1235                                                 }
1236                                                 break;
1237
1238                                                 /* pop 2 push 3 dup */
1239                                                 
1240                                         case ICMD_DUP_X1:
1241                                                 DUP_X1;
1242                                                 break;
1243
1244                                         case ICMD_DUP2_X1:
1245                                                 REQUIRE_2;
1246                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1247                                                         iptr->opc = ICMD_DUP_X1;
1248                                                         DUP_X1;
1249                                                 }
1250                                                 else {
1251                                                         DUP2_X1;
1252                                                 }
1253                                                 break;
1254
1255                                                 /* pop 3 push 4 dup */
1256                                                 
1257                                         case ICMD_DUP_X2:
1258                                                 REQUIRE_2;
1259                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1260                                                         iptr->opc = ICMD_DUP_X1;
1261                                                         DUP_X1;
1262                                                 }
1263                                                 else {
1264                                                         DUP_X2;
1265                                                 }
1266                                                 break;
1267
1268                                         case ICMD_DUP2_X2:
1269                                                 REQUIRE_2;
1270                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1271                                                         if (IS_2_WORD_TYPE(curstack->prev->type)) {
1272                                                                 iptr->opc = ICMD_DUP_X1;
1273                                                                 DUP_X1;
1274                                                         }
1275                                                         else {
1276                                                                 iptr->opc = ICMD_DUP_X2;
1277                                                                 DUP_X2;
1278                                                         }
1279                                                 }
1280                                                 else
1281                                                         REQUIRE_3;
1282                                                         if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1283                                                                 iptr->opc = ICMD_DUP2_X1;
1284                                                                 DUP2_X1;
1285                                                         }
1286                                                         else {
1287                                                                 DUP2_X2;
1288                                                         }
1289                                                 break;
1290
1291                                                 /* pop 2 push 2 swap */
1292                                                 
1293                                         case ICMD_SWAP:
1294                                                 SWAP;
1295                                                 break;
1296
1297                                                 /* pop 2 push 1 */
1298                                                 
1299                                         case ICMD_IDIV:
1300 #if !SUPPORT_DIVISION
1301                                                 iptr[0].opc = ICMD_BUILTIN2;
1302                                                 iptr[0].op1 = TYPE_INT;
1303                                                 iptr[0].val.a = BUILTIN_idiv;
1304                                                 isleafmethod = false;
1305                                                 goto builtin2;
1306 #endif
1307
1308                                         case ICMD_IREM:
1309 #if !SUPPORT_DIVISION
1310                                                 iptr[0].opc = ICMD_BUILTIN2;
1311                                                 iptr[0].op1 = TYPE_INT;
1312                                                 iptr[0].val.a = BUILTIN_irem;
1313                                                 isleafmethod = false;
1314                                                 goto builtin2;
1315 #endif
1316 #if defined(__I386__)
1317                                                 method_uses_edx = true;
1318 #endif
1319
1320                                         case ICMD_ISHL:
1321                                         case ICMD_ISHR:
1322                                         case ICMD_IUSHR:
1323 #if defined(__I386__)
1324                                                 method_uses_ecx = true;
1325 #endif
1326                                         case ICMD_IADD:
1327                                         case ICMD_ISUB:
1328                                         case ICMD_IMUL:
1329                                         case ICMD_IAND:
1330                                         case ICMD_IOR:
1331                                         case ICMD_IXOR:
1332                                                 COUNT(count_pcmd_op);
1333                                                 OP2_1(TYPE_INT);
1334                                                 break;
1335
1336                                         case ICMD_LDIV:
1337 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1338                                                 iptr[0].opc = ICMD_BUILTIN2;
1339                                                 iptr[0].op1 = TYPE_LNG;
1340                                                 iptr[0].val.a = BUILTIN_ldiv;
1341                                                 isleafmethod = false;
1342                                                 goto builtin2;
1343 #endif
1344
1345                                         case ICMD_LREM:
1346 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1347                                                 iptr[0].opc = ICMD_BUILTIN2;
1348                                                 iptr[0].op1 = TYPE_LNG;
1349                                                 iptr[0].val.a = BUILTIN_lrem;
1350                                                 isleafmethod = false;
1351                                                 goto builtin2;
1352 #endif
1353
1354                                         case ICMD_LMUL:
1355 #if defined(__I386__)
1356                                                 method_uses_edx = true;
1357 #endif
1358                                         case ICMD_LADD:
1359                                         case ICMD_LSUB:
1360                                         case ICMD_LOR:
1361                                         case ICMD_LAND:
1362                                         case ICMD_LXOR:
1363                                                 /* XXX DEBUG */ /*dolog("OP2_1(TYPE_LNG)"); */
1364                                                 COUNT(count_pcmd_op);
1365                                                 OP2_1(TYPE_LNG);
1366                                                 break;
1367
1368                                         case ICMD_LSHL:
1369                                         case ICMD_LSHR:
1370                                         case ICMD_LUSHR:
1371                                                 COUNT(count_pcmd_op);
1372                                                 OP2IT_1(TYPE_LNG);
1373 #if defined(__I386__)
1374                                                 method_uses_ecx = true;
1375                                                 method_uses_edx = true;
1376 #endif
1377                                                 break;
1378
1379                                         case ICMD_FADD:
1380                                         case ICMD_FSUB:
1381                                         case ICMD_FMUL:
1382                                         case ICMD_FDIV:
1383                                         case ICMD_FREM:
1384                                                 COUNT(count_pcmd_op);
1385                                                 OP2_1(TYPE_FLT);
1386                                                 break;
1387
1388                                         case ICMD_DADD:
1389                                         case ICMD_DSUB:
1390                                         case ICMD_DMUL:
1391                                         case ICMD_DDIV:
1392                                         case ICMD_DREM:
1393                                                 COUNT(count_pcmd_op);
1394                                                 OP2_1(TYPE_DBL);
1395                                                 break;
1396
1397                                         case ICMD_LCMP:
1398                                                 COUNT(count_pcmd_op);
1399 #if !defined(NOLONG_CONDITIONAL)
1400                                                 if ((len > 0) && (iptr[1].val.i == 0)) {
1401                                                         switch (iptr[1].opc) {
1402                                                         case ICMD_IFEQ:
1403                                                                 iptr[0].opc = ICMD_IF_LCMPEQ;
1404                                                         icmd_lcmp_if_tail:
1405                                                                 iptr[0].op1 = iptr[1].op1;
1406                                                                 len--;
1407                                                                 bptr->icount--;
1408                                                                 /* iptr[1].opc = ICMD_NOP; */
1409                                                                 OP2_0(TYPE_LNG);
1410                                                                 tbptr = block + block_index[iptr->op1];
1411                         
1412                                                                 iptr[0].target = (void *) tbptr;
1413
1414                                                                 MARKREACHED(tbptr, copy);
1415                                                                 COUNT(count_pcmd_bra);
1416                                                                 break;
1417                                                         case ICMD_IFNE:
1418                                                                 iptr[0].opc = ICMD_IF_LCMPNE;
1419                                                                 goto icmd_lcmp_if_tail;
1420                                                         case ICMD_IFLT:
1421                                                                 iptr[0].opc = ICMD_IF_LCMPLT;
1422                                                                 goto icmd_lcmp_if_tail;
1423                                                         case ICMD_IFGT:
1424                                                                 iptr[0].opc = ICMD_IF_LCMPGT;
1425                                                                 goto icmd_lcmp_if_tail;
1426                                                         case ICMD_IFLE:
1427                                                                 iptr[0].opc = ICMD_IF_LCMPLE;
1428                                                                 goto icmd_lcmp_if_tail;
1429                                                         case ICMD_IFGE:
1430                                                                 iptr[0].opc = ICMD_IF_LCMPGE;
1431                                                                 goto icmd_lcmp_if_tail;
1432                                                         default:
1433                                                                 OPTT2_1(TYPE_LNG, TYPE_INT);
1434                                                         }
1435                                                 }
1436                                                 else
1437 #endif
1438                                                         OPTT2_1(TYPE_LNG, TYPE_INT);
1439                                                 break;
1440                                         case ICMD_FCMPL:
1441                                         case ICMD_FCMPG:
1442                                                 COUNT(count_pcmd_op);
1443                                                 OPTT2_1(TYPE_FLT, TYPE_INT);
1444                                                 break;
1445                                         case ICMD_DCMPL:
1446                                         case ICMD_DCMPG:
1447                                                 COUNT(count_pcmd_op);
1448                                                 OPTT2_1(TYPE_DBL, TYPE_INT);
1449                                                 break;
1450
1451                                                 /* pop 1 push 1 */
1452                                                 
1453                                         case ICMD_INEG:
1454                                         case ICMD_INT2BYTE:
1455                                         case ICMD_INT2CHAR:
1456                                         case ICMD_INT2SHORT:
1457                                                 COUNT(count_pcmd_op);
1458                                                 OP1_1(TYPE_INT, TYPE_INT);
1459                                                 break;
1460                                         case ICMD_LNEG:
1461                                                 COUNT(count_pcmd_op);
1462                                                 OP1_1(TYPE_LNG, TYPE_LNG);
1463                                                 break;
1464                                         case ICMD_FNEG:
1465                                                 COUNT(count_pcmd_op);
1466                                                 OP1_1(TYPE_FLT, TYPE_FLT);
1467                                                 break;
1468                                         case ICMD_DNEG:
1469                                                 COUNT(count_pcmd_op);
1470                                                 OP1_1(TYPE_DBL, TYPE_DBL);
1471                                                 break;
1472
1473                                         case ICMD_I2L:
1474                                                 COUNT(count_pcmd_op);
1475                                                 OP1_1(TYPE_INT, TYPE_LNG);
1476 #if defined(__I386__)
1477                                                 method_uses_edx = true;
1478 #endif
1479                                                 break;
1480                                         case ICMD_I2F:
1481                                                 COUNT(count_pcmd_op);
1482                                                 OP1_1(TYPE_INT, TYPE_FLT);
1483                                                 break;
1484                                         case ICMD_I2D:
1485                                                 COUNT(count_pcmd_op);
1486                                                 OP1_1(TYPE_INT, TYPE_DBL);
1487                                                 break;
1488                                         case ICMD_L2I:
1489                                                 COUNT(count_pcmd_op);
1490                                                 OP1_1(TYPE_LNG, TYPE_INT);
1491                                                 break;
1492                                         case ICMD_L2F:
1493                                                 COUNT(count_pcmd_op);
1494                                                 OP1_1(TYPE_LNG, TYPE_FLT);
1495                                                 break;
1496                                         case ICMD_L2D:
1497                                                 COUNT(count_pcmd_op);
1498                                                 OP1_1(TYPE_LNG, TYPE_DBL);
1499                                                 break;
1500                                         case ICMD_F2I:
1501                                                 COUNT(count_pcmd_op);
1502                                                 OP1_1(TYPE_FLT, TYPE_INT);
1503                                                 break;
1504                                         case ICMD_F2L:
1505                                                 COUNT(count_pcmd_op);
1506                                                 OP1_1(TYPE_FLT, TYPE_LNG);
1507 #if defined(__I386__)
1508                                                 method_uses_edx = true;
1509 #endif
1510                                                 break;
1511                                         case ICMD_F2D:
1512                                                 COUNT(count_pcmd_op);
1513                                                 OP1_1(TYPE_FLT, TYPE_DBL);
1514                                                 break;
1515                                         case ICMD_D2I:
1516                                                 COUNT(count_pcmd_op);
1517                                                 OP1_1(TYPE_DBL, TYPE_INT);
1518                                                 break;
1519                                         case ICMD_D2L:
1520                                                 COUNT(count_pcmd_op);
1521                                                 OP1_1(TYPE_DBL, TYPE_LNG);
1522 #if defined(__I386__)
1523                                                 method_uses_edx = true;
1524 #endif
1525                                                 break;
1526                                         case ICMD_D2F:
1527                                                 COUNT(count_pcmd_op);
1528                                                 OP1_1(TYPE_DBL, TYPE_FLT);
1529                                                 break;
1530
1531                                         case ICMD_CHECKCAST:
1532                                                 OP1_1(TYPE_ADR, TYPE_ADR);
1533 #if defined(__I386__)
1534                                                 method_uses_edx = true;
1535 #endif
1536                                                 break;
1537
1538                                         case ICMD_INSTANCEOF:
1539 #if defined(__I386__)
1540                                                 method_uses_edx = true;
1541 #endif
1542                                         case ICMD_ARRAYLENGTH:
1543                                                 OP1_1(TYPE_ADR, TYPE_INT);
1544                                                 break;
1545
1546                                         case ICMD_NEWARRAY:
1547                                         case ICMD_ANEWARRAY:
1548                                                 OP1_1(TYPE_INT, TYPE_ADR);
1549                                                 break;
1550
1551                                         case ICMD_GETFIELD:
1552                                                 COUNT(count_check_null);
1553                                                 COUNT(count_pcmd_mem);
1554                                                 OP1_1(TYPE_ADR, iptr->op1);
1555                                                 break;
1556
1557                                                 /* pop 0 push 1 */
1558                                                 
1559                                         case ICMD_GETSTATIC:
1560                                                 COUNT(count_pcmd_mem);
1561                                                 OP0_1(iptr->op1);
1562                                                 break;
1563
1564                                         case ICMD_NEW:
1565                                                 OP0_1(TYPE_ADR);
1566                                                 break;
1567
1568                                         case ICMD_JSR:
1569                                                 OP0_1(TYPE_ADR);
1570                                                 tbptr = block + block_index[iptr->op1];
1571
1572                                                 iptr[0].target = (void *) tbptr;
1573
1574                                                 /* XXX This is a dirty hack. The typechecker
1575                                                  * needs it because the OP1_0ANY below
1576                                                  * overwrites iptr->dst.
1577                                                  */
1578                                                 iptr->val.a = (void*) iptr->dst;
1579
1580                                                 tbptr->type=BBTYPE_SBR;
1581                                                 MARKREACHED(tbptr, copy);
1582                                                 OP1_0ANY;
1583                                                 break;
1584
1585                                                 /* pop many push any */
1586                                                 
1587                                         case ICMD_INVOKEVIRTUAL:
1588                                         case ICMD_INVOKESPECIAL:
1589                                         case ICMD_INVOKEINTERFACE:
1590                                         case ICMD_INVOKESTATIC:
1591                                                 COUNT(count_pcmd_met);
1592                                                 {
1593                                                         methodinfo *m = iptr->val.a;
1594                                                         if (m->flags & ACC_STATIC)
1595                                                                 {COUNT(count_check_null);}
1596                                                         i = iptr->op1;
1597                                                         if (i > arguments_num)
1598                                                                 arguments_num = i;
1599                                                         REQUIRE(i);
1600 #if defined(__X86_64__)
1601                                                         {
1602                                                                 int iarg = 0;
1603                                                                 int farg = 0;
1604                                                                 int stackargs = 0;
1605
1606                                                                 copy = curstack;
1607                                                                 while (--i >= 0) {
1608                                                                         (IS_FLT_DBL_TYPE(copy->type)) ? farg++ : iarg++;
1609                                                                         copy = copy->prev;
1610                                                                 }
1611
1612                                                                 stackargs += (iarg < intreg_argnum) ? 0 : (iarg - intreg_argnum);
1613                                                                 stackargs += (farg < fltreg_argnum) ? 0 : (farg - fltreg_argnum);
1614
1615                                                                 i = iptr->op1;
1616                                                                 copy = curstack;
1617                                                                 while (--i >= 0) {
1618                                                                         if (!(copy->flags & SAVEDVAR)) {
1619                                                                                 copy->varkind = ARGVAR;
1620                                                                                 if (IS_FLT_DBL_TYPE(copy->type)) {
1621                                                                                         if (--farg < fltreg_argnum) {
1622                                                                                                 copy->varnum = farg;
1623                                                                                         } else {
1624                                                                                                 copy->varnum = --stackargs + intreg_argnum;
1625                                                                                         }
1626                                                                                 } else {
1627                                                                                         if (--iarg < intreg_argnum) {
1628                                                                                                 copy->varnum = iarg;
1629                                                                                         } else {
1630                                                                                                 copy->varnum = --stackargs + intreg_argnum;
1631                                                                                         }
1632                                                                                 }
1633                                                                         } else {
1634                                                                                 (IS_FLT_DBL_TYPE(copy->type)) ? --farg : --iarg;
1635                                                                         }
1636                                                                         copy = copy->prev;
1637                                                                 }
1638                                                         }
1639 #else
1640                                                         copy = curstack;
1641                                                         while (--i >= 0) {
1642                                                                 if (! (copy->flags & SAVEDVAR)) {
1643                                                                         copy->varkind = ARGVAR;
1644                                                                         copy->varnum = i;
1645                                                                 }
1646                                                                 copy = copy->prev;
1647                                                         }
1648 #endif
1649                                                         while (copy) {
1650                                                                 copy->flags |= SAVEDVAR;
1651                                                                 copy = copy->prev;
1652                                                         }
1653                                                         i = iptr->op1;
1654                                                         POPMANY(i);
1655                                                         if (m->returntype != TYPE_VOID) {
1656                                                                 OP0_1(m->returntype);
1657                                                         }
1658                                                         break;
1659                                                 }
1660
1661                                         case ICMD_BUILTIN3:
1662                                                 /* XXX DEBUG */ /*dolog("builtin3");*/
1663                                                 REQUIRE_3;
1664                                                 if (! (curstack->flags & SAVEDVAR)) {
1665                                                         curstack->varkind = ARGVAR;
1666                                                         curstack->varnum = 2;
1667                                                 }
1668                                                 if (3 > arguments_num) {
1669                                                         arguments_num = 3;
1670                                                 }
1671                                                 OP1_0ANY;
1672
1673                                         case ICMD_BUILTIN2:
1674                                         builtin2:
1675                                                 REQUIRE_2;
1676                                                 /* XXX DEBUG */ /*dolog("builtin2");*/
1677                                         if (!(curstack->flags & SAVEDVAR)) {
1678                                                 curstack->varkind = ARGVAR;
1679                                                 curstack->varnum = 1;
1680                                         }
1681                                         if (2 > arguments_num) {
1682                                                 arguments_num = 2;
1683                                         }
1684                                         OP1_0ANY;
1685
1686                                         case ICMD_BUILTIN1:
1687                                         builtin1:
1688                                                 REQUIRE_1;
1689                                                 /* XXX DEBUG */ /*dolog("builtin1");*/
1690                                         if (!(curstack->flags & SAVEDVAR)) {
1691                                                 curstack->varkind = ARGVAR;
1692                                                 curstack->varnum = 0;
1693                                         }
1694                                         if (1 > arguments_num) {
1695                                                 arguments_num = 1;
1696                                         }
1697                                         OP1_0ANY;
1698                                         copy = curstack;
1699                                         while (copy) {
1700                                                 copy->flags |= SAVEDVAR;
1701                                                 copy = copy->prev;
1702                                         }
1703                                         if (iptr->op1 != TYPE_VOID)
1704                                                 OP0_1(iptr->op1);
1705                                         break;
1706
1707                                         case ICMD_MULTIANEWARRAY:
1708                                                 i = iptr->op1;
1709                                                 REQUIRE(i);
1710                                                 if ((i + intreg_argnum) > arguments_num)
1711                                                         arguments_num = i + intreg_argnum;
1712                                                 copy = curstack;
1713                                                 while (--i >= 0) {
1714                                                         if (! (copy->flags & SAVEDVAR)) {
1715                                                                 copy->varkind = ARGVAR;
1716                                                                 copy->varnum = i + intreg_argnum;
1717                                                         }
1718                                                         copy = copy->prev;
1719                                                 }
1720                                                 while (copy) {
1721                                                         copy->flags |= SAVEDVAR;
1722                                                         copy = copy->prev;
1723                                                 }
1724                                                 i = iptr->op1;
1725                                                 POPMANY(i);
1726                                                 OP0_1(TYPE_ADR);
1727                                                 break;
1728
1729                                         case ICMD_CLEAR_ARGREN:
1730                                                 for (i = iptr->op1; i<maxlocals; i++) 
1731                                                         argren[i] = i;
1732                                                 iptr->opc = opcode = ICMD_NOP;
1733                                                 SETDST;
1734                                                 break;
1735                                                 
1736                                         case ICMD_READONLY_ARG:
1737                                         case ICMD_READONLY_ARG+1:
1738                                         case ICMD_READONLY_ARG+2:
1739                                         case ICMD_READONLY_ARG+3:
1740                                         case ICMD_READONLY_ARG+4:
1741
1742                                                 REQUIRE_1;
1743                                                 if (curstack->varkind == LOCALVAR) {
1744                                                         i = curstack->varnum;
1745                                                         argren[iptr->op1] = i;
1746                                                         iptr->op1 = i;
1747                                                 }
1748                                                 opcode = iptr->opc = opcode - ICMD_READONLY_ARG + ICMD_ISTORE;
1749                                                 goto icmd_store;
1750
1751                                                 break;
1752
1753                                         default:
1754                                                 printf("ICMD %d at %d\n", iptr->opc, (int)(iptr-instr));
1755                                                 panic("Missing ICMD code during stack analysis");
1756                                         } /* switch */
1757                                         /* XXX DEBUG */ /*dolog("iptr++");*/
1758                                         iptr++;
1759                                 } /* while instructions */
1760                                 bptr->outstack = curstack;
1761                                 bptr->outdepth = stackdepth;
1762                                 BBEND(curstack, i);
1763                         } /* if */
1764                         else
1765                                 superblockend = true;
1766                         bptr++;
1767                 } /* while blocks */
1768         } while (repeat && !deadcode);
1769
1770 #ifdef STATISTICS
1771         if (block_count > count_max_basic_blocks)
1772                 count_max_basic_blocks = block_count;
1773         count_basic_blocks += block_count;
1774         if (instr_count > count_max_javainstr)
1775                 count_max_javainstr = instr_count;
1776         count_javainstr += instr_count;
1777         if (stack_count > count_upper_bound_new_stack)
1778                 count_upper_bound_new_stack = stack_count;
1779         if ((new - stack) > count_max_new_stack)
1780                 count_max_new_stack = (new - stack);
1781
1782         b_count = block_count;
1783         bptr = block;
1784         while (--b_count >= 0) {
1785                 if (bptr->flags > BBREACHED) {
1786                         if (bptr->indepth >= 10)
1787                                 count_block_stack[10]++;
1788                         else
1789                                 count_block_stack[bptr->indepth]++;
1790                         len = bptr->icount;
1791                         if (len < 10) 
1792                                 count_block_size_distribution[len]++;
1793                         else if (len <= 12)
1794                                 count_block_size_distribution[10]++;
1795                         else if (len <= 14)
1796                                 count_block_size_distribution[11]++;
1797                         else if (len <= 16)
1798                                 count_block_size_distribution[12]++;
1799                         else if (len <= 18)
1800                                 count_block_size_distribution[13]++;
1801                         else if (len <= 20)
1802                                 count_block_size_distribution[14]++;
1803                         else if (len <= 25)
1804                                 count_block_size_distribution[15]++;
1805                         else if (len <= 30)
1806                                 count_block_size_distribution[16]++;
1807                         else
1808                                 count_block_size_distribution[17]++;
1809                 }
1810                 bptr++;
1811         }
1812
1813         if (loops == 1)
1814                 count_analyse_iterations[0]++;
1815         else if (loops == 2)
1816                 count_analyse_iterations[1]++;
1817         else if (loops == 3)
1818                 count_analyse_iterations[2]++;
1819         else if (loops == 4)
1820                 count_analyse_iterations[3]++;
1821         else
1822                 count_analyse_iterations[4]++;
1823
1824         if (block_count <= 5)
1825                 count_method_bb_distribution[0]++;
1826         else if (block_count <= 10)
1827                 count_method_bb_distribution[1]++;
1828         else if (block_count <= 15)
1829                 count_method_bb_distribution[2]++;
1830         else if (block_count <= 20)
1831                 count_method_bb_distribution[3]++;
1832         else if (block_count <= 30)
1833                 count_method_bb_distribution[4]++;
1834         else if (block_count <= 40)
1835                 count_method_bb_distribution[5]++;
1836         else if (block_count <= 50)
1837                 count_method_bb_distribution[6]++;
1838         else if (block_count <= 75)
1839                 count_method_bb_distribution[7]++;
1840         else
1841                 count_method_bb_distribution[8]++;
1842 #endif
1843 }
1844
1845
1846 void icmd_print_stack(stackptr s)
1847 {
1848         int i, j;
1849         stackptr t;
1850
1851         i = maxstack;
1852         t = s;
1853         
1854         while (t) {
1855                 i--;
1856                 t = t->prev;
1857         }
1858         j = maxstack - i;
1859         while (--i >= 0)
1860                 printf("    ");
1861         while (s) {
1862                 j--;
1863                 /* XXX remove */ /* printf("(%d)",s->flags); fflush(stdout); */
1864                 if (s->flags & SAVEDVAR)
1865                         switch (s->varkind) {
1866                         case TEMPVAR:
1867                                 if (s->flags & INMEMORY)
1868                                         printf((regs_ok) ? " M%02d" : " M??", s->regoff);
1869                                 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1870                                         printf((regs_ok) ? " F%02d" : " F??", s->regoff);
1871                                 else {
1872                                         if (regs_ok) printf(" %3s",regs[s->regoff]); else printf(" ???");
1873                                 }
1874                                 break;
1875                         case STACKVAR:
1876                                 printf(" I%02d", s->varnum);
1877                                 break;
1878                         case LOCALVAR:
1879                                 printf(" L%02d", s->varnum);
1880                                 break;
1881                         case ARGVAR:
1882                                 printf(" A%02d", s->varnum);
1883                                 break;
1884                         default:
1885                                 printf(" !%02d", j);
1886                         }
1887                 else
1888                         switch (s->varkind) {
1889                         case TEMPVAR:
1890                                 if (s->flags & INMEMORY)
1891                                         printf((regs_ok) ? " m%02d" : " m??", s->regoff);
1892                                 else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
1893                                         printf((regs_ok) ? " f%02d" : " f??", s->regoff);
1894                                 else {
1895                                         if (regs_ok) printf(" %3s",regs[s->regoff]); else printf(" ???");
1896                                 }
1897                                 break;
1898                         case STACKVAR:
1899                                 printf(" i%02d", s->varnum);
1900                                 break;
1901                         case LOCALVAR:
1902                                 printf(" l%02d", s->varnum);
1903                                 break;
1904                         case ARGVAR:
1905                                 printf(" a%02d", s->varnum);
1906                                 break;
1907                         default:
1908                                 printf(" ?%02d", j);
1909                         }
1910                 s = s->prev;
1911         }
1912 }
1913
1914
1915 #if 0
1916 static void print_reg(stackptr s) {
1917         if (s) {
1918                 if (s->flags & SAVEDVAR)
1919                         switch (s->varkind) {
1920                         case TEMPVAR:
1921                                 if (s->flags & INMEMORY)
1922                                         printf(" tm%02d", s->regoff);
1923                                 else
1924                                         printf(" tr%02d", s->regoff);
1925                                 break;
1926                         case STACKVAR:
1927                                 printf(" s %02d", s->varnum);
1928                                 break;
1929                         case LOCALVAR:
1930                                 printf(" l %02d", s->varnum);
1931                                 break;
1932                         case ARGVAR:
1933                                 printf(" a %02d", s->varnum);
1934                                 break;
1935                         default:
1936                                 printf(" ! %02d", s->varnum);
1937                         }
1938                 else
1939                         switch (s->varkind) {
1940                         case TEMPVAR:
1941                                 if (s->flags & INMEMORY)
1942                                         printf(" Tm%02d", s->regoff);
1943                                 else
1944                                         printf(" Tr%02d", s->regoff);
1945                                 break;
1946                         case STACKVAR:
1947                                 printf(" S %02d", s->varnum);
1948                                 break;
1949                         case LOCALVAR:
1950                                 printf(" L %02d", s->varnum);
1951                                 break;
1952                         case ARGVAR:
1953                                 printf(" A %02d", s->varnum);
1954                                 break;
1955                         default:
1956                                 printf(" ? %02d", s->varnum);
1957                         }
1958         }
1959         else
1960                 printf("     ");
1961                 
1962 }
1963 #endif
1964
1965
1966 char *icmd_builtin_name(functionptr bptr)
1967 {
1968         builtin_descriptor *bdesc = builtin_desc;
1969         while ((bdesc->opcode != 0) && (bdesc->builtin != bptr))
1970                 bdesc++;
1971         return (bdesc->opcode) ? bdesc->name : "<NOT IN TABLE>";
1972 }
1973
1974
1975 static char *jit_type[] = {
1976         "int",
1977         "lng",
1978         "flt",
1979         "dbl",
1980         "adr"
1981 };
1982
1983
1984 void show_icmd_method()
1985 {
1986         int i, j;
1987         int deadcode;
1988         s4  *s4ptr;
1989         instruction *iptr;
1990         basicblock *bptr;
1991         void **tptr;
1992         xtable *ex;
1993
1994         printf("\n");
1995         utf_fprint(stdout, class->name);
1996         printf(".");
1997         utf_fprint(stdout, method->name);
1998         printf(" ");
1999         utf_fprint(stdout, method->descriptor);
2000         printf ("\n\nMax locals: %d\n", (int) maxlocals);
2001         printf ("Max stack:  %d\n", (int) maxstack);
2002
2003         printf ("Exceptions (Number: %d):\n", exceptiontablelength);
2004         for (ex = extable; ex != NULL; ex = ex->down) {
2005                 printf("    L%03d ... ", ex->start->debug_nr );
2006                 printf("L%03d  = ", ex->end->debug_nr);
2007                 printf("L%03d\n", ex->handler->debug_nr);
2008         }
2009         
2010         printf ("Local Table:\n");
2011         for (i = 0; i < maxlocals; i++) {
2012                 printf("   %3d: ", i);
2013                 for (j = TYPE_INT; j <= TYPE_ADR; j++)
2014                         if (locals[i][j].type >= 0) {
2015                                 printf("   (%s) ", jit_type[j]);
2016                                 if (locals[i][j].flags & INMEMORY)
2017                                         printf((regs_ok) ? "m%2d" : "m??", locals[i][j].regoff);
2018                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2019                                         printf((regs_ok) ? "f%02d" : "f??", locals[i][j].regoff);
2020                                 else {
2021                                         if (regs_ok) printf("%3s",regs[locals[i][j].regoff]); else printf("???");
2022                                 }
2023                         }
2024                 printf("\n");
2025         }
2026         printf("\n");
2027
2028         printf ("Interface Table:\n");
2029         for (i = 0; i < maxstack; i++) {
2030                 if ((interfaces[i][0].type >= 0) || (interfaces[i][1].type >= 0) ||
2031                     (interfaces[i][2].type >= 0) || (interfaces[i][3].type >= 0) ||
2032                     (interfaces[i][4].type >= 0)) {
2033                         printf("   %3d: ", i);
2034                         for (j = TYPE_INT; j <= TYPE_ADR; j++)
2035                                 if (interfaces[i][j].type >= 0) {
2036                                         printf("   (%s) ", jit_type[j]);
2037                                         if (interfaces[i][j].flags & SAVEDVAR) {
2038                                                 if (interfaces[i][j].flags & INMEMORY)
2039                                                         printf((regs_ok) ? "M%2d" : "M??", interfaces[i][j].regoff);
2040                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2041                                                         printf((regs_ok) ? "F%02d" : "F??", interfaces[i][j].regoff);
2042                                                 else {
2043                                                         if (regs_ok) printf("%3s",regs[interfaces[i][j].regoff]); else printf("???");
2044                                                 }
2045                                         }
2046                                         else {
2047                                                 if (interfaces[i][j].flags & INMEMORY)
2048                                                         printf((regs_ok) ? "m%2d" : "m??", interfaces[i][j].regoff);
2049                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2050                                                         printf((regs_ok) ? "f%02d" : "f??", interfaces[i][j].regoff);
2051                                                 else {
2052                                                         if (regs_ok) printf("%3s",regs[interfaces[i][j].regoff]); else printf("???");
2053                                                 }
2054                                         }
2055                                 }
2056                         printf("\n");
2057                 }
2058         }
2059         printf("\n");
2060
2061         if (showdisassemble) {
2062 #if defined(__I386__) || defined(__X86_64__)
2063                 u1 *u1ptr;
2064                 int a;
2065
2066                 u1ptr = method->mcode + dseglen;
2067                 for (i = 0; i < block[0].mpc; i++, u1ptr++) {
2068                         a = disassinstr(u1ptr, i);
2069                         i += a;
2070                         u1ptr += a;
2071                 }
2072                 printf("\n");
2073 #else
2074                 s4ptr = (s4 *) (method->mcode + dseglen);
2075                 for (i = 0; i < block[0].mpc; i += 4, s4ptr++) {
2076                         disassinstr(*s4ptr, i); 
2077                 }
2078                 printf("\n");
2079 #endif
2080         }
2081
2082         
2083         for (bptr = block; bptr != NULL; bptr = bptr->next) {
2084                 show_icmd_block(bptr);
2085         }
2086 }
2087
2088
2089 void show_icmd_block(basicblock *bptr)
2090 {
2091         int i, j;
2092         int deadcode;
2093         s4  *s4ptr;
2094         instruction *iptr;
2095
2096         if (bptr->flags != BBDELETED) {
2097                 deadcode = bptr->flags <= BBREACHED;
2098                 printf("[");
2099                 if (deadcode)
2100                         for (j = method->maxstack; j > 0; j--)
2101                                 printf(" ?  ");
2102                 else
2103                         icmd_print_stack(bptr->instack);
2104                 printf("] L%03d(%d - %d) flags=%d:\n", bptr->debug_nr, bptr->icount, bptr->pre_count,bptr->flags);
2105                 iptr = bptr->iinstr;
2106
2107                 for (i=0; i < bptr->icount; i++, iptr++) {
2108                         printf("[");
2109                         if (deadcode) {
2110                                 for (j = method->maxstack; j > 0; j--)
2111                                         printf(" ?  ");
2112                         }
2113                         else
2114                                 icmd_print_stack(iptr->dst);
2115                         printf("]     %4d  ", i);
2116                         /* XXX remove */ /*fflush(stdout);*/
2117                         show_icmd(iptr,deadcode);
2118                         printf("\n");
2119                 }
2120
2121                 if (showdisassemble && (!deadcode)) {
2122 #if defined(__I386__) || defined(__X86_64__)
2123                         u1 *u1ptr;
2124                         int a;
2125
2126                         printf("\n");
2127                         i = bptr->mpc;
2128                         u1ptr = method->mcode + dseglen + i;
2129
2130                         if (bptr->next != NULL) {
2131                                 for (; i < bptr->next->mpc; i++, u1ptr++) {
2132                                         a = disassinstr(u1ptr, i);
2133                                         i += a;
2134                                         u1ptr += a;
2135                                 }
2136                                 printf("\n");
2137
2138                         } else {
2139                                 for (; u1ptr < (u1 *) (method->mcode + method->mcodelength); i++, u1ptr++) {
2140                                         a = disassinstr(u1ptr, i); 
2141                                         i += a;
2142                                         u1ptr += a;
2143                                 }
2144                                 printf("\n");
2145                         }
2146 #else
2147                         printf("\n");
2148                         i = bptr->mpc;
2149                         s4ptr = (s4 *) (method->mcode + dseglen + i);
2150
2151                         if (bptr->next != NULL) {
2152                                 for (; i < bptr->next->mpc; i += 4, s4ptr++) {
2153                                         disassinstr(*s4ptr, i); 
2154                                 }
2155                                 printf("\n");
2156
2157                         } else {
2158                                 for (; s4ptr < (s4 *) (method->mcode + method->mcodelength); i += 4, s4ptr++) {
2159                                         disassinstr(*s4ptr, i); 
2160                                 }
2161                                 printf("\n");
2162                         }
2163 #endif
2164                 }
2165         }
2166 }
2167
2168
2169 void show_icmd(instruction *iptr,bool deadcode)
2170 {
2171         int j;
2172         s4  *s4ptr;
2173         void **tptr;
2174         
2175         printf("%s", icmd_names[iptr->opc]);
2176
2177         switch ((int) iptr->opc) {
2178         case ICMD_IADDCONST:
2179         case ICMD_ISUBCONST:
2180         case ICMD_IMULCONST:
2181         case ICMD_IDIVPOW2:
2182         case ICMD_IREMPOW2:
2183         case ICMD_IREM0X10001:
2184         case ICMD_IANDCONST:
2185         case ICMD_IORCONST:
2186         case ICMD_IXORCONST:
2187         case ICMD_ISHLCONST:
2188         case ICMD_ISHRCONST:
2189         case ICMD_IUSHRCONST:
2190         case ICMD_LSHLCONST:
2191         case ICMD_LSHRCONST:
2192         case ICMD_LUSHRCONST:
2193         case ICMD_ICONST:
2194         case ICMD_ELSE_ICONST:
2195         case ICMD_IFEQ_ICONST:
2196         case ICMD_IFNE_ICONST:
2197         case ICMD_IFLT_ICONST:
2198         case ICMD_IFGE_ICONST:
2199         case ICMD_IFGT_ICONST:
2200         case ICMD_IFLE_ICONST:
2201                 printf(" %d", iptr->val.i);
2202                 break;
2203
2204         case ICMD_LADDCONST:
2205         case ICMD_LSUBCONST:
2206         case ICMD_LMULCONST:
2207         case ICMD_LDIVPOW2:
2208         case ICMD_LREMPOW2:
2209         case ICMD_LANDCONST:
2210         case ICMD_LORCONST:
2211         case ICMD_LXORCONST:
2212         case ICMD_LCONST:
2213 #if defined(__I386__)
2214                 printf(" %lld", iptr->val.l);
2215 #else
2216                 printf(" %ld", iptr->val.l);
2217 #endif
2218                 break;
2219
2220         case ICMD_FCONST:
2221                 printf(" %f", iptr->val.f);
2222                 break;
2223
2224         case ICMD_DCONST:
2225                 printf(" %f", iptr->val.d);
2226                 break;
2227
2228         case ICMD_ACONST:
2229                 printf(" %p", iptr->val.a);
2230                 break;
2231
2232         case ICMD_GETFIELD:
2233         case ICMD_PUTFIELD:
2234                 printf(" %d,", ((fieldinfo *) iptr->val.a)->offset);
2235         case ICMD_PUTSTATIC:
2236         case ICMD_GETSTATIC:
2237                 printf(" ");
2238                 utf_fprint(stdout,
2239                                    ((fieldinfo *) iptr->val.a)->class->name);
2240                 printf(".");
2241                 utf_fprint(stdout,
2242                                    ((fieldinfo *) iptr->val.a)->name);
2243                 printf(" (type ");
2244                 utf_fprint(stdout,
2245                                    ((fieldinfo *) iptr->val.a)->descriptor);
2246                 printf(")");
2247                 break;
2248
2249         case ICMD_IINC:
2250                 printf(" %d + %d", iptr->op1, iptr->val.i);
2251                 break;
2252
2253         case ICMD_IASTORE:
2254         case ICMD_SASTORE:
2255         case ICMD_BASTORE:
2256         case ICMD_CASTORE:
2257         case ICMD_LASTORE:
2258         case ICMD_DASTORE:
2259         case ICMD_FASTORE:
2260         case ICMD_AASTORE:
2261
2262         case ICMD_IALOAD:
2263         case ICMD_SALOAD:
2264         case ICMD_BALOAD:
2265         case ICMD_CALOAD:
2266         case ICMD_LALOAD:
2267         case ICMD_DALOAD:
2268         case ICMD_FALOAD:
2269         case ICMD_AALOAD:
2270                 if (iptr->op1 != 0)
2271                         printf("(opt.)");
2272                 break;
2273
2274         case ICMD_RET:
2275         case ICMD_ILOAD:
2276         case ICMD_LLOAD:
2277         case ICMD_FLOAD:
2278         case ICMD_DLOAD:
2279         case ICMD_ALOAD:
2280         case ICMD_ISTORE:
2281         case ICMD_LSTORE:
2282         case ICMD_FSTORE:
2283         case ICMD_DSTORE:
2284         case ICMD_ASTORE:
2285                 printf(" %d", iptr->op1);
2286                 break;
2287
2288         case ICMD_NEW:
2289                 printf(" ");
2290                 utf_fprint(stdout,
2291                                    ((classinfo *) iptr->val.a)->name);
2292                 break;
2293
2294         case ICMD_NEWARRAY:
2295                 switch (iptr->op1) {
2296                 case 4:
2297                         printf(" boolean");
2298                         break;
2299                 case 5:
2300                         printf(" char");
2301                         break;
2302                 case 6:
2303                         printf(" float");
2304                         break;
2305                 case 7:
2306                         printf(" double");
2307                         break;
2308                 case 8:
2309                         printf(" byte");
2310                         break;
2311                 case 9:
2312                         printf(" short");
2313                         break;
2314                 case 10:
2315                         printf(" int");
2316                         break;
2317                 case 11:
2318                         printf(" long");
2319                         break;
2320                 }
2321                 break;
2322
2323         case ICMD_ANEWARRAY:
2324                 if (iptr->op1) {
2325                         printf(" ");
2326                         utf_fprint(stdout,
2327                                            ((classinfo *) iptr->val.a)->name);
2328                 }
2329                 break;
2330
2331         case ICMD_MULTIANEWARRAY:
2332                 {
2333                         vftbl *vft;
2334                         printf(" %d ",iptr->op1);
2335                         vft = (vftbl *)iptr->val.a;
2336                         if (vft)
2337                                 utf_fprint(stdout,vft->class->name);
2338                         else
2339                                 printf("<null>");
2340                 }
2341                 break;
2342
2343         case ICMD_CHECKCAST:
2344         case ICMD_INSTANCEOF:
2345                 if (iptr->op1) {
2346                         classinfo *c = iptr->val.a;
2347                         if (c->flags & ACC_INTERFACE)
2348                                 printf(" (INTERFACE) ");
2349                         else
2350                                 printf(" (CLASS,%3d) ", c->vftbl->diffval);
2351                         utf_fprint(stdout, c->name);
2352                 }
2353                 break;
2354
2355         case ICMD_BUILTIN3:
2356         case ICMD_BUILTIN2:
2357         case ICMD_BUILTIN1:
2358                 printf(" %s", icmd_builtin_name((functionptr) iptr->val.a));
2359                 break;
2360
2361         case ICMD_INVOKEVIRTUAL:
2362         case ICMD_INVOKESPECIAL:
2363         case ICMD_INVOKESTATIC:
2364         case ICMD_INVOKEINTERFACE:
2365                 printf(" ");
2366                 utf_fprint(stdout,
2367                                    ((methodinfo *) iptr->val.a)->class->name);
2368                 printf(".");
2369                 utf_fprint(stdout,
2370                                    ((methodinfo *) iptr->val.a)->name);
2371                 break;
2372
2373         case ICMD_IFEQ:
2374         case ICMD_IFNE:
2375         case ICMD_IFLT:
2376         case ICMD_IFGE:
2377         case ICMD_IFGT:
2378         case ICMD_IFLE:
2379                 if (deadcode || !iptr->target)
2380                         printf("(%d) op1=%d", iptr->val.i, iptr->op1);
2381                 else
2382                         printf("(%d) L%03d", iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
2383                 break;
2384
2385         case ICMD_IF_LEQ:
2386         case ICMD_IF_LNE:
2387         case ICMD_IF_LLT:
2388         case ICMD_IF_LGE:
2389         case ICMD_IF_LGT:
2390         case ICMD_IF_LLE:
2391                 if (deadcode || !iptr->target)
2392                         printf("(%lld) op1=%d", iptr->val.l, iptr->op1);
2393                 else
2394                         printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
2395                 break;
2396
2397         case ICMD_JSR:
2398         case ICMD_GOTO:
2399         case ICMD_IFNULL:
2400         case ICMD_IFNONNULL:
2401         case ICMD_IF_ICMPEQ:
2402         case ICMD_IF_ICMPNE:
2403         case ICMD_IF_ICMPLT:
2404         case ICMD_IF_ICMPGE:
2405         case ICMD_IF_ICMPGT:
2406         case ICMD_IF_ICMPLE:
2407         case ICMD_IF_LCMPEQ:
2408         case ICMD_IF_LCMPNE:
2409         case ICMD_IF_LCMPLT:
2410         case ICMD_IF_LCMPGE:
2411         case ICMD_IF_LCMPGT:
2412         case ICMD_IF_LCMPLE:
2413         case ICMD_IF_ACMPEQ:
2414         case ICMD_IF_ACMPNE:
2415                 if (deadcode || !iptr->target)
2416                         printf(" op1=%d", iptr->op1);
2417                 else
2418                         printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
2419                 break;
2420
2421         case ICMD_TABLESWITCH:
2422
2423
2424                 if (deadcode || !iptr->target) {
2425                         printf(" %d;", *s4ptr);
2426                 }
2427                 else {
2428                         tptr = (void **) iptr->target;
2429                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr); 
2430                         tptr++;
2431                 }
2432
2433                 s4ptr++;         /* skip default */
2434                 j = *s4ptr++;                               /* low     */
2435                 j = *s4ptr++ - j;                           /* high    */
2436                 while (j >= 0) {
2437                         if (deadcode || !*tptr)
2438                                 printf(" %d", *s4ptr++);
2439                         else {
2440                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2441                                 tptr++;
2442                         }
2443                         j--;
2444                 }
2445                 break;
2446
2447         case ICMD_LOOKUPSWITCH:
2448                 s4ptr = iptr->val.a;
2449
2450                 if (deadcode || !iptr->target) {
2451                         printf(" %d;", *s4ptr);
2452                 }
2453                 else {
2454                         tptr = (void **) iptr->target;
2455                         printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2456                         tptr++;
2457                 }
2458                 s4ptr++;                                         /* default */
2459                 j = *s4ptr++;                                    /* count   */
2460
2461                 while (--j >= 0) {
2462                         if (deadcode || !*tptr) {
2463                                 s4ptr++; /* skip value */
2464                                 printf(" %d",*s4ptr++);
2465                         }
2466                         else {
2467                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2468                                 tptr++;
2469                         }
2470                 }
2471                 break;
2472         }
2473 }
2474
2475
2476 /*
2477  * These are local overrides for various environment variables in Emacs.
2478  * Please do not remove this and leave it at the end of the file, where
2479  * Emacs will automagically detect them.
2480  * ---------------------------------------------------------------------
2481  * Local variables:
2482  * mode: c
2483  * indent-tabs-mode: t
2484  * c-basic-offset: 4
2485  * tab-width: 4
2486  * End:
2487  */