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