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