throw verifyerror instead of assert(0)
[cacao.git] / src / vm / jit / stack.c
1 /* src/vm/jit/stack.c - stack analysis
2
3    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    Institut f. Computersprachen - TU Wien
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             Christian Thalinger
31                         Christian Ullrich
32
33    $Id: stack.c 3367 2005-10-06 09:23:36Z edwin $
34
35 */
36
37
38 #include <assert.h>
39 #include <stdio.h>
40 #include <string.h>
41
42 #include "vm/types.h"
43
44 #include "arch.h"
45 #include "md-abi.h"
46
47 #include "mm/memory.h"
48 #include "native/native.h"
49 #include "toolbox/logging.h"
50 #include "vm/global.h"
51 #include "vm/builtin.h"
52 #include "vm/options.h"
53 #include "vm/resolve.h"
54 #include "vm/statistics.h"
55 #include "vm/stringlocal.h"
56 #include "vm/tables.h"
57 #include "vm/jit/codegen.inc.h"
58 #include "vm/jit/disass.h"
59 #include "vm/jit/jit.h"
60 #include "vm/jit/reg.h"
61 #include "vm/jit/stack.h"
62 #include "vm/jit/lsra.h"
63
64
65 /* global variables ***********************************************************/
66
67 #if defined(USE_THREADS)
68 static java_objectheader show_icmd_lock;
69 #endif
70
71
72 /* stack_init ******************************************************************
73
74    Initialized the stack analysis subsystem (called by jit_init).
75
76 *******************************************************************************/
77
78 bool stack_init(void)
79 {
80 #if defined(USE_THREADS)
81         /* initialize the show lock */
82
83         show_icmd_lock.monitorPtr = get_dummyLR();
84 #endif
85
86         /* everything's ok */
87
88         return true;
89 }
90
91
92 /**********************************************************************/
93 /* analyse_stack                                                      */
94 /**********************************************************************/
95
96 /* analyse_stack uses the intermediate code created by parse.c to
97  * build a model of the JVM operand stack for the current method.
98  *
99  * The following checks are performed:
100  *   - check for operand stack underflow (before each instruction)
101  *   - check for operand stack overflow (after[1] each instruction)
102  *   - check for matching stack depth at merging points
103  *   - check for matching basic types[2] at merging points
104  *   - check basic types for instruction input (except for BUILTIN*
105  *         opcodes, INVOKE* opcodes and MULTIANEWARRAY)
106  *
107  * [1]) Checking this after the instruction should be ok. parse.c
108  * counts the number of required stack slots in such a way that it is
109  * only vital that we don't exceed `maxstack` at basic block
110  * boundaries.
111  *
112  * [2]) 'basic types' means the distinction between INT, LONG, FLOAT,
113  * DOUBLE and ADDRESS types. Subtypes of INT and different ADDRESS
114  * types are not discerned.
115  */
116
117 methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
118 {
119         int           b_count;
120         int           b_index;
121         int           stackdepth;
122         stackptr      curstack;
123         stackptr      new;
124         stackptr      copy;
125         int           opcode, i, len, loops;
126         int           superblockend, repeat, deadcode;
127         instruction  *iptr;
128         basicblock   *bptr;
129         basicblock   *tbptr;
130         s4           *s4ptr;
131         void        **tptr;
132         s4           *argren;
133
134         builtintable_entry *bte;
135         unresolved_method  *um;
136         methoddesc         *md;
137
138 #ifdef LSRA
139         m->maxlifetimes = 0;
140 #endif
141
142         argren = DMNEW(s4, cd->maxlocals);   /* table for argument renaming       */
143         for (i = 0; i < cd->maxlocals; i++)
144                 argren[i] = i;
145         
146         new = m->stack;
147         loops = 0;
148         m->basicblocks[0].flags = BBREACHED;
149         m->basicblocks[0].instack = 0;
150         m->basicblocks[0].indepth = 0;
151
152         for (i = 0; i < cd->exceptiontablelength; i++) {
153                 bptr = &m->basicblocks[m->basicblockindex[cd->exceptiontable[i].handlerpc]];
154                 bptr->flags = BBREACHED;
155                 bptr->type = BBTYPE_EXH;
156                 bptr->instack = new;
157                 bptr->indepth = 1;
158                 bptr->pre_count = 10000;
159                 STACKRESET;
160                 NEWXSTACK;
161         }
162
163 #if CONDITIONAL_LOADCONST
164         b_count = m->basicblockcount;
165         bptr = m->basicblocks;
166         while (--b_count >= 0) {
167                 if (bptr->icount != 0) {
168                         iptr = bptr->iinstr + bptr->icount - 1;
169                         switch (iptr->opc) {
170                         case ICMD_RET:
171                         case ICMD_RETURN:
172                         case ICMD_IRETURN:
173                         case ICMD_LRETURN:
174                         case ICMD_FRETURN:
175                         case ICMD_DRETURN:
176                         case ICMD_ARETURN:
177                         case ICMD_ATHROW:
178                                 break;
179
180                         case ICMD_IFEQ:
181                         case ICMD_IFNE:
182                         case ICMD_IFLT:
183                         case ICMD_IFGE:
184                         case ICMD_IFGT:
185                         case ICMD_IFLE:
186
187                         case ICMD_IFNULL:
188                         case ICMD_IFNONNULL:
189
190                         case ICMD_IF_ICMPEQ:
191                         case ICMD_IF_ICMPNE:
192                         case ICMD_IF_ICMPLT:
193                         case ICMD_IF_ICMPGE:
194                         case ICMD_IF_ICMPGT:
195                         case ICMD_IF_ICMPLE:
196
197                         case ICMD_IF_ACMPEQ:
198                         case ICMD_IF_ACMPNE:
199                                 bptr[1].pre_count++;
200                         case ICMD_GOTO:
201                                 m->basicblocks[m->basicblockindex[iptr->op1]].pre_count++;
202                                 break;
203
204                         case ICMD_TABLESWITCH:
205                                 s4ptr = iptr->val.a;
206                                 m->basicblocks[m->basicblockindex[*s4ptr++]].pre_count++;
207                                 i = *s4ptr++;                               /* low     */
208                                 i = *s4ptr++ - i + 1;                       /* high    */
209                                 while (--i >= 0) {
210                                         m->basicblocks[m->basicblockindex[*s4ptr++]].pre_count++;
211                                 }
212                                 break;
213                                         
214                         case ICMD_LOOKUPSWITCH:
215                                 s4ptr = iptr->val.a;
216                                 m->basicblocks[m->basicblockindex[*s4ptr++]].pre_count++;
217                                 i = *s4ptr++;                               /* count   */
218                                 while (--i >= 0) {
219                                         m->basicblocks[m->basicblockindex[s4ptr[1]]].pre_count++;
220                                         s4ptr += 2;
221                                 }
222                                 break;
223                         default:
224                                 bptr[1].pre_count++;
225                                 break;
226                         }
227                 }
228                 bptr++;
229         }
230 #endif /* CONDITIONAL_LOADCONST */
231
232
233         do {
234                 loops++;
235                 b_count = m->basicblockcount;
236                 bptr = m->basicblocks;
237                 superblockend = true;
238                 repeat = false;
239                 STACKRESET;
240                 deadcode = true;
241
242                 while (--b_count >= 0) {
243                         if (bptr->flags == BBDELETED) {
244                                 /* do nothing */
245
246                         } else if (superblockend && (bptr->flags < BBREACHED)) {
247                                 repeat = true;
248
249                         } else if (bptr->flags <= BBREACHED) {
250                                 if (superblockend) {
251                                         stackdepth = bptr->indepth;
252
253                                 } else if (bptr->flags < BBREACHED) {
254                                         COPYCURSTACK(copy);
255                                         bptr->instack = copy;
256                                         bptr->indepth = stackdepth;
257
258                                 } else if (bptr->indepth != stackdepth) {
259                                         show_icmd_method(m, cd, rd);
260                                         printf("Block: %d, required depth: %d, current depth: %d\n", bptr->debug_nr, bptr->indepth, stackdepth);
261                                         *exceptionptr = new_verifyerror(m,"Stack depth mismatch");
262                                         return NULL;
263                                 }
264
265                                 curstack = bptr->instack;
266                                 deadcode = false;
267                                 superblockend = false;
268                                 bptr->flags = BBFINISHED;
269                                 len = bptr->icount;
270                                 iptr = bptr->iinstr;
271                                 b_index = bptr - m->basicblocks;
272
273                                 while (--len >= 0)  {
274                                         opcode = iptr->opc;
275
276 #if defined(USEBUILTINTABLE)
277 # if defined(ENABLE_INTRP)
278                                         if (!opt_intrp) {
279 # endif
280                                                 bte = builtintable_get_automatic(opcode);
281
282                                                 if (bte && bte->opcode == opcode) {
283                                                         iptr->opc = ICMD_BUILTIN;
284                                                         iptr->op1 = false;   /* don't check for exception */
285                                                         iptr->val.a = bte;
286                                                         m->isleafmethod = false;
287                                                         goto builtin;
288                                                 }
289 # if defined(ENABLE_INTRP)
290                                         }
291 # endif
292 #endif /* defined(USEBUILTINTABLE) */
293                                         
294                                         switch (opcode) {
295
296                                                 /* pop 0 push 0 */
297
298                                         case ICMD_CHECKNULL:
299                                                 COUNT(count_check_null);
300                                         case ICMD_NOP:
301
302                                         case ICMD_IFEQ_ICONST:
303                                         case ICMD_IFNE_ICONST:
304                                         case ICMD_IFLT_ICONST:
305                                         case ICMD_IFGE_ICONST:
306                                         case ICMD_IFGT_ICONST:
307                                         case ICMD_IFLE_ICONST:
308                                         case ICMD_ELSE_ICONST:
309                                                 SETDST;
310                                                 break;
311
312                                         case ICMD_RET:
313 #if defined(ENABLE_INTRP)
314                                                 if (!opt_intrp)
315 #endif
316                                                         rd->locals[iptr->op1][TYPE_ADR].type = TYPE_ADR;
317                                         case ICMD_RETURN:
318                                                 COUNT(count_pcmd_return);
319                                                 SETDST;
320                                                 superblockend = true;
321                                                 break;
322
323                                                 /* pop 0 push 1 const */
324                                                 
325                                         case ICMD_ICONST:
326                                                 COUNT(count_pcmd_load);
327                                                 if (len > 0) {
328                                                         switch (iptr[1].opc) {
329                                                         case ICMD_IADD:
330                                                                 iptr[0].opc = ICMD_IADDCONST;
331                                                         icmd_iconst_tail:
332                                                                 iptr[1].opc = ICMD_NOP;
333                                                                 OP1_1(TYPE_INT, TYPE_INT);
334                                                                 COUNT(count_pcmd_op);
335                                                                 break;
336                                                         case ICMD_ISUB:
337                                                                 iptr[0].opc = ICMD_ISUBCONST;
338                                                                 goto icmd_iconst_tail;
339 #if SUPPORT_CONST_MUL
340                                                         case ICMD_IMUL:
341                                                                 iptr[0].opc = ICMD_IMULCONST;
342                                                                 goto icmd_iconst_tail;
343 #else /* SUPPORT_CONST_MUL */
344                                                         case ICMD_IMUL:
345                                                                 if (iptr[0].val.i == 0x00000002)
346                                                                         iptr[0].val.i = 1;
347                                                                 else if (iptr[0].val.i == 0x00000004)
348                                                                         iptr[0].val.i = 2;
349                                                                 else if (iptr[0].val.i == 0x00000008)
350                                                                         iptr[0].val.i = 3;
351                                                                 else if (iptr[0].val.i == 0x00000010)
352                                                                         iptr[0].val.i = 4;
353                                                                 else if (iptr[0].val.i == 0x00000020)
354                                                                         iptr[0].val.i = 5;
355                                                                 else if (iptr[0].val.i == 0x00000040)
356                                                                         iptr[0].val.i = 6;
357                                                                 else if (iptr[0].val.i == 0x00000080)
358                                                                         iptr[0].val.i = 7;
359                                                                 else if (iptr[0].val.i == 0x00000100)
360                                                                         iptr[0].val.i = 8;
361                                                                 else if (iptr[0].val.i == 0x00000200)
362                                                                         iptr[0].val.i = 9;
363                                                                 else if (iptr[0].val.i == 0x00000400)
364                                                                         iptr[0].val.i = 10;
365                                                                 else if (iptr[0].val.i == 0x00000800)
366                                                                         iptr[0].val.i = 11;
367                                                                 else if (iptr[0].val.i == 0x00001000)
368                                                                         iptr[0].val.i = 12;
369                                                                 else if (iptr[0].val.i == 0x00002000)
370                                                                         iptr[0].val.i = 13;
371                                                                 else if (iptr[0].val.i == 0x00004000)
372                                                                         iptr[0].val.i = 14;
373                                                                 else if (iptr[0].val.i == 0x00008000)
374                                                                         iptr[0].val.i = 15;
375                                                                 else if (iptr[0].val.i == 0x00010000)
376                                                                         iptr[0].val.i = 16;
377                                                                 else if (iptr[0].val.i == 0x00020000)
378                                                                         iptr[0].val.i = 17;
379                                                                 else if (iptr[0].val.i == 0x00040000)
380                                                                         iptr[0].val.i = 18;
381                                                                 else if (iptr[0].val.i == 0x00080000)
382                                                                         iptr[0].val.i = 19;
383                                                                 else if (iptr[0].val.i == 0x00100000)
384                                                                         iptr[0].val.i = 20;
385                                                                 else if (iptr[0].val.i == 0x00200000)
386                                                                         iptr[0].val.i = 21;
387                                                                 else if (iptr[0].val.i == 0x00400000)
388                                                                         iptr[0].val.i = 22;
389                                                                 else if (iptr[0].val.i == 0x00800000)
390                                                                         iptr[0].val.i = 23;
391                                                                 else if (iptr[0].val.i == 0x01000000)
392                                                                         iptr[0].val.i = 24;
393                                                                 else if (iptr[0].val.i == 0x02000000)
394                                                                         iptr[0].val.i = 25;
395                                                                 else if (iptr[0].val.i == 0x04000000)
396                                                                         iptr[0].val.i = 26;
397                                                                 else if (iptr[0].val.i == 0x08000000)
398                                                                         iptr[0].val.i = 27;
399                                                                 else if (iptr[0].val.i == 0x10000000)
400                                                                         iptr[0].val.i = 28;
401                                                                 else if (iptr[0].val.i == 0x20000000)
402                                                                         iptr[0].val.i = 29;
403                                                                 else if (iptr[0].val.i == 0x40000000)
404                                                                         iptr[0].val.i = 30;
405                                                                 else if (iptr[0].val.i == 0x80000000)
406                                                                         iptr[0].val.i = 31;
407                                                                 else {
408                                                                         PUSHCONST(TYPE_INT);
409                                                                         break;
410                                                                 }
411                                                                 iptr[0].opc = ICMD_IMULPOW2;
412                                                                 goto icmd_iconst_tail;
413 #endif /* SUPPORT_CONST_MUL */
414                                                         case ICMD_IDIV:
415                                                                 if (iptr[0].val.i == 0x00000002)
416                                                                         iptr[0].val.i = 1;
417                                                                 else if (iptr[0].val.i == 0x00000004)
418                                                                         iptr[0].val.i = 2;
419                                                                 else if (iptr[0].val.i == 0x00000008)
420                                                                         iptr[0].val.i = 3;
421                                                                 else if (iptr[0].val.i == 0x00000010)
422                                                                         iptr[0].val.i = 4;
423                                                                 else if (iptr[0].val.i == 0x00000020)
424                                                                         iptr[0].val.i = 5;
425                                                                 else if (iptr[0].val.i == 0x00000040)
426                                                                         iptr[0].val.i = 6;
427                                                                 else if (iptr[0].val.i == 0x00000080)
428                                                                         iptr[0].val.i = 7;
429                                                                 else if (iptr[0].val.i == 0x00000100)
430                                                                         iptr[0].val.i = 8;
431                                                                 else if (iptr[0].val.i == 0x00000200)
432                                                                         iptr[0].val.i = 9;
433                                                                 else if (iptr[0].val.i == 0x00000400)
434                                                                         iptr[0].val.i = 10;
435                                                                 else if (iptr[0].val.i == 0x00000800)
436                                                                         iptr[0].val.i = 11;
437                                                                 else if (iptr[0].val.i == 0x00001000)
438                                                                         iptr[0].val.i = 12;
439                                                                 else if (iptr[0].val.i == 0x00002000)
440                                                                         iptr[0].val.i = 13;
441                                                                 else if (iptr[0].val.i == 0x00004000)
442                                                                         iptr[0].val.i = 14;
443                                                                 else if (iptr[0].val.i == 0x00008000)
444                                                                         iptr[0].val.i = 15;
445                                                                 else if (iptr[0].val.i == 0x00010000)
446                                                                         iptr[0].val.i = 16;
447                                                                 else if (iptr[0].val.i == 0x00020000)
448                                                                         iptr[0].val.i = 17;
449                                                                 else if (iptr[0].val.i == 0x00040000)
450                                                                         iptr[0].val.i = 18;
451                                                                 else if (iptr[0].val.i == 0x00080000)
452                                                                         iptr[0].val.i = 19;
453                                                                 else if (iptr[0].val.i == 0x00100000)
454                                                                         iptr[0].val.i = 20;
455                                                                 else if (iptr[0].val.i == 0x00200000)
456                                                                         iptr[0].val.i = 21;
457                                                                 else if (iptr[0].val.i == 0x00400000)
458                                                                         iptr[0].val.i = 22;
459                                                                 else if (iptr[0].val.i == 0x00800000)
460                                                                         iptr[0].val.i = 23;
461                                                                 else if (iptr[0].val.i == 0x01000000)
462                                                                         iptr[0].val.i = 24;
463                                                                 else if (iptr[0].val.i == 0x02000000)
464                                                                         iptr[0].val.i = 25;
465                                                                 else if (iptr[0].val.i == 0x04000000)
466                                                                         iptr[0].val.i = 26;
467                                                                 else if (iptr[0].val.i == 0x08000000)
468                                                                         iptr[0].val.i = 27;
469                                                                 else if (iptr[0].val.i == 0x10000000)
470                                                                         iptr[0].val.i = 28;
471                                                                 else if (iptr[0].val.i == 0x20000000)
472                                                                         iptr[0].val.i = 29;
473                                                                 else if (iptr[0].val.i == 0x40000000)
474                                                                         iptr[0].val.i = 30;
475                                                                 else if (iptr[0].val.i == 0x80000000)
476                                                                         iptr[0].val.i = 31;
477                                                                 else {
478                                                                         PUSHCONST(TYPE_INT);
479                                                                         break;
480                                                                 }
481                                                                 iptr[0].opc = ICMD_IDIVPOW2;
482                                                                 goto icmd_iconst_tail;
483                                                         case ICMD_IREM:
484                                                                 /*log_text("stack.c: ICMD_ICONST/ICMD_IREM");*/
485                                                                 if ((iptr[0].val.i == 0x00000002) ||
486                                                                         (iptr[0].val.i == 0x00000004) ||
487                                                                         (iptr[0].val.i == 0x00000008) ||
488                                                                         (iptr[0].val.i == 0x00000010) ||
489                                                                         (iptr[0].val.i == 0x00000020) ||
490                                                                         (iptr[0].val.i == 0x00000040) ||
491                                                                         (iptr[0].val.i == 0x00000080) ||
492                                                                         (iptr[0].val.i == 0x00000100) ||
493                                                                         (iptr[0].val.i == 0x00000200) ||
494                                                                         (iptr[0].val.i == 0x00000400) ||
495                                                                         (iptr[0].val.i == 0x00000800) ||
496                                                                         (iptr[0].val.i == 0x00001000) ||
497                                                                         (iptr[0].val.i == 0x00002000) ||
498                                                                         (iptr[0].val.i == 0x00004000) ||
499                                                                         (iptr[0].val.i == 0x00008000) ||
500                                                                         (iptr[0].val.i == 0x00010000) ||
501                                                                         (iptr[0].val.i == 0x00020000) ||
502                                                                         (iptr[0].val.i == 0x00040000) ||
503                                                                         (iptr[0].val.i == 0x00080000) ||
504                                                                         (iptr[0].val.i == 0x00100000) ||
505                                                                         (iptr[0].val.i == 0x00200000) ||
506                                                                         (iptr[0].val.i == 0x00400000) ||
507                                                                         (iptr[0].val.i == 0x00800000) ||
508                                                                         (iptr[0].val.i == 0x01000000) ||
509                                                                         (iptr[0].val.i == 0x02000000) ||
510                                                                         (iptr[0].val.i == 0x04000000) ||
511                                                                         (iptr[0].val.i == 0x08000000) ||
512                                                                         (iptr[0].val.i == 0x10000000) ||
513                                                                         (iptr[0].val.i == 0x20000000) ||
514                                                                         (iptr[0].val.i == 0x40000000) ||
515                                                                         (iptr[0].val.i == 0x80000000)) {
516                                                                         iptr[0].opc = ICMD_IREMPOW2;
517                                                                         iptr[0].val.i -= 1;
518                                                                         goto icmd_iconst_tail;
519                                                                 }
520                                                                 PUSHCONST(TYPE_INT);
521                                                                 break;
522 #if SUPPORT_CONST_LOGICAL
523                                                         case ICMD_IAND:
524                                                                 iptr[0].opc = ICMD_IANDCONST;
525                                                                 goto icmd_iconst_tail;
526                                                         case ICMD_IOR:
527                                                                 iptr[0].opc = ICMD_IORCONST;
528                                                                 goto icmd_iconst_tail;
529                                                         case ICMD_IXOR:
530                                                                 iptr[0].opc = ICMD_IXORCONST;
531                                                                 goto icmd_iconst_tail;
532 #endif /* SUPPORT_CONST_LOGICAL */
533                                                         case ICMD_ISHL:
534                                                                 iptr[0].opc = ICMD_ISHLCONST;
535                                                                 goto icmd_iconst_tail;
536                                                         case ICMD_ISHR:
537                                                                 iptr[0].opc = ICMD_ISHRCONST;
538                                                                 goto icmd_iconst_tail;
539                                                         case ICMD_IUSHR:
540                                                                 iptr[0].opc = ICMD_IUSHRCONST;
541                                                                 goto icmd_iconst_tail;
542 #if SUPPORT_LONG_SHIFT
543                                                         case ICMD_LSHL:
544                                                                 iptr[0].opc = ICMD_LSHLCONST;
545                                                                 goto icmd_lconst_tail;
546                                                         case ICMD_LSHR:
547                                                                 iptr[0].opc = ICMD_LSHRCONST;
548                                                                 goto icmd_lconst_tail;
549                                                         case ICMD_LUSHR:
550                                                                 iptr[0].opc = ICMD_LUSHRCONST;
551                                                                 goto icmd_lconst_tail;
552 #endif /* SUPPORT_LONG_SHIFT */
553                                                         case ICMD_IF_ICMPEQ:
554                                                                 iptr[0].opc = ICMD_IFEQ;
555                                                         icmd_if_icmp_tail:
556                                                                 iptr[0].op1 = iptr[1].op1;
557                                                                 /* IF_ICMPxx is the last instruction in the   */
558                                                                 /* basic block, just remove it                */
559                                                                 /* iptr[1].opc = ICMD_NOP; */
560                                                                 bptr->icount--;
561                                                                 len--;
562
563                                                                 OP1_0(TYPE_INT);
564                                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
565
566                                                                 iptr[0].target = (void *) tbptr;
567
568                                                                 MARKREACHED(tbptr, copy);
569                                                                 COUNT(count_pcmd_bra);
570                                                                 break;
571                                                         case ICMD_IF_ICMPLT:
572                                                                 iptr[0].opc = ICMD_IFLT;
573                                                                 goto icmd_if_icmp_tail;
574                                                         case ICMD_IF_ICMPLE:
575                                                                 iptr[0].opc = ICMD_IFLE;
576                                                                 goto icmd_if_icmp_tail;
577                                                         case ICMD_IF_ICMPNE:
578                                                                 iptr[0].opc = ICMD_IFNE;
579                                                                 goto icmd_if_icmp_tail;
580                                                         case ICMD_IF_ICMPGT:
581                                                                 iptr[0].opc = ICMD_IFGT;
582                                                                 goto icmd_if_icmp_tail;
583                                                         case ICMD_IF_ICMPGE:
584                                                                 iptr[0].opc = ICMD_IFGE;
585                                                                 goto icmd_if_icmp_tail;
586
587 #if SUPPORT_CONST_STORE
588                                                         case ICMD_IASTORE:
589                                                         case ICMD_BASTORE:
590                                                         case ICMD_CASTORE:
591                                                         case ICMD_SASTORE:
592 # if defined(ENABLE_INTRP)
593                                                                 if (!opt_intrp) {
594 # endif
595 #if SUPPORT_CONST_STORE_ZERO_ONLY
596                                                                         if (iptr[0].val.i == 0) {
597 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
598                                                                                 switch (iptr[1].opc) {
599                                                                                 case ICMD_IASTORE:
600                                                                                         iptr[0].opc = ICMD_IASTORECONST;
601                                                                                         break;
602                                                                                 case ICMD_BASTORE:
603                                                                                         iptr[0].opc = ICMD_BASTORECONST;
604                                                                                         break;
605                                                                                 case ICMD_CASTORE:
606                                                                                         iptr[0].opc = ICMD_CASTORECONST;
607                                                                                         break;
608                                                                                 case ICMD_SASTORE:
609                                                                                         iptr[0].opc = ICMD_SASTORECONST;
610                                                                                         break;
611                                                                                 }
612
613                                                                                 iptr[1].opc = ICMD_NOP;
614                                                                                 OPTT2_0(TYPE_INT, TYPE_ADR);
615                                                                                 COUNT(count_pcmd_op);
616 #if SUPPORT_CONST_STORE_ZERO_ONLY
617                                                                         } else
618                                                                                 PUSHCONST(TYPE_INT);
619 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
620 # if defined(ENABLE_INTRP)
621                                                                 } else
622                                                                         PUSHCONST(TYPE_INT);
623 # endif
624                                                                 break;
625
626                                                         case ICMD_PUTSTATIC:
627                                                         case ICMD_PUTFIELD:
628 #if SUPPORT_CONST_STORE_ZERO_ONLY
629                                                                 if (iptr[0].val.i == 0) {
630 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
631                                                                         switch (iptr[1].opc) {
632                                                                         case ICMD_PUTSTATIC:
633                                                                                 iptr[0].opc = ICMD_PUTSTATICCONST;
634                                                                                 SETDST;
635                                                                                 break;
636                                                                         case ICMD_PUTFIELD:
637                                                                                 iptr[0].opc = ICMD_PUTFIELDCONST;
638                                                                                 OP1_0(TYPE_ADR);
639                                                                                 break;
640                                                                         }
641
642                                                                         iptr[1].opc = ICMD_NOP;
643                                                                         iptr[0].op1 = TYPE_INT;
644                                                                         COUNT(count_pcmd_op);
645 #if SUPPORT_CONST_STORE_ZERO_ONLY
646                                                                 } else
647                                                                         PUSHCONST(TYPE_INT);
648 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
649                                                                 break;
650 #endif /* SUPPORT_CONST_STORE */
651                                                         default:
652                                                                 PUSHCONST(TYPE_INT);
653                                                         }
654                                                 }
655                                                 else
656                                                         PUSHCONST(TYPE_INT);
657                                                 break;
658
659                                         case ICMD_LCONST:
660                                                 COUNT(count_pcmd_load);
661                                                 if (len > 0) {
662                                                         switch (iptr[1].opc) {
663 #if SUPPORT_LONG_ADD
664                                                         case ICMD_LADD:
665                                                                 iptr[0].opc = ICMD_LADDCONST;
666                                                         icmd_lconst_tail:
667                                                                 iptr[1].opc = ICMD_NOP;
668                                                                 OP1_1(TYPE_LNG,TYPE_LNG);
669                                                                 COUNT(count_pcmd_op);
670                                                                 break;
671                                                         case ICMD_LSUB:
672                                                                 iptr[0].opc = ICMD_LSUBCONST;
673                                                                 goto icmd_lconst_tail;
674 #endif /* SUPPORT_LONG_ADD */
675 #if SUPPORT_LONG_MUL && SUPPORT_CONST_MUL
676                                                         case ICMD_LMUL:
677                                                                 iptr[0].opc = ICMD_LMULCONST;
678                                                                 goto icmd_lconst_tail;
679 #else /* SUPPORT_LONG_MUL && SUPPORT_CONST_MUL */
680 # if SUPPORT_LONG_SHIFT
681                                                         case ICMD_LMUL:
682                                                                 if (iptr[0].val.l == 0x00000002)
683                                                                         iptr[0].val.i = 1;
684                                                                 else if (iptr[0].val.l == 0x00000004)
685                                                                         iptr[0].val.i = 2;
686                                                                 else if (iptr[0].val.l == 0x00000008)
687                                                                         iptr[0].val.i = 3;
688                                                                 else if (iptr[0].val.l == 0x00000010)
689                                                                         iptr[0].val.i = 4;
690                                                                 else if (iptr[0].val.l == 0x00000020)
691                                                                         iptr[0].val.i = 5;
692                                                                 else if (iptr[0].val.l == 0x00000040)
693                                                                         iptr[0].val.i = 6;
694                                                                 else if (iptr[0].val.l == 0x00000080)
695                                                                         iptr[0].val.i = 7;
696                                                                 else if (iptr[0].val.l == 0x00000100)
697                                                                         iptr[0].val.i = 8;
698                                                                 else if (iptr[0].val.l == 0x00000200)
699                                                                         iptr[0].val.i = 9;
700                                                                 else if (iptr[0].val.l == 0x00000400)
701                                                                         iptr[0].val.i = 10;
702                                                                 else if (iptr[0].val.l == 0x00000800)
703                                                                         iptr[0].val.i = 11;
704                                                                 else if (iptr[0].val.l == 0x00001000)
705                                                                         iptr[0].val.i = 12;
706                                                                 else if (iptr[0].val.l == 0x00002000)
707                                                                         iptr[0].val.i = 13;
708                                                                 else if (iptr[0].val.l == 0x00004000)
709                                                                         iptr[0].val.i = 14;
710                                                                 else if (iptr[0].val.l == 0x00008000)
711                                                                         iptr[0].val.i = 15;
712                                                                 else if (iptr[0].val.l == 0x00010000)
713                                                                         iptr[0].val.i = 16;
714                                                                 else if (iptr[0].val.l == 0x00020000)
715                                                                         iptr[0].val.i = 17;
716                                                                 else if (iptr[0].val.l == 0x00040000)
717                                                                         iptr[0].val.i = 18;
718                                                                 else if (iptr[0].val.l == 0x00080000)
719                                                                         iptr[0].val.i = 19;
720                                                                 else if (iptr[0].val.l == 0x00100000)
721                                                                         iptr[0].val.i = 20;
722                                                                 else if (iptr[0].val.l == 0x00200000)
723                                                                         iptr[0].val.i = 21;
724                                                                 else if (iptr[0].val.l == 0x00400000)
725                                                                         iptr[0].val.i = 22;
726                                                                 else if (iptr[0].val.l == 0x00800000)
727                                                                         iptr[0].val.i = 23;
728                                                                 else if (iptr[0].val.l == 0x01000000)
729                                                                         iptr[0].val.i = 24;
730                                                                 else if (iptr[0].val.l == 0x02000000)
731                                                                         iptr[0].val.i = 25;
732                                                                 else if (iptr[0].val.l == 0x04000000)
733                                                                         iptr[0].val.i = 26;
734                                                                 else if (iptr[0].val.l == 0x08000000)
735                                                                         iptr[0].val.i = 27;
736                                                                 else if (iptr[0].val.l == 0x10000000)
737                                                                         iptr[0].val.i = 28;
738                                                                 else if (iptr[0].val.l == 0x20000000)
739                                                                         iptr[0].val.i = 29;
740                                                                 else if (iptr[0].val.l == 0x40000000)
741                                                                         iptr[0].val.i = 30;
742                                                                 else if (iptr[0].val.l == 0x80000000)
743                                                                         iptr[0].val.i = 31;
744                                                                 else {
745                                                                         PUSHCONST(TYPE_LNG);
746                                                                         break;
747                                                                 }
748                                                                 iptr[0].opc = ICMD_LMULPOW2;
749                                                                 goto icmd_lconst_tail;
750 # endif /* SUPPORT_LONG_SHIFT */
751 #endif /* SUPPORT_LONG_MUL && SUPPORT_CONST_MUL */
752 #if SUPPORT_LONG_DIV
753                                                         case ICMD_LDIV:
754                                                                 if (iptr[0].val.l == 0x00000002)
755                                                                         iptr[0].val.i = 1;
756                                                                 else if (iptr[0].val.l == 0x00000004)
757                                                                         iptr[0].val.i = 2;
758                                                                 else if (iptr[0].val.l == 0x00000008)
759                                                                         iptr[0].val.i = 3;
760                                                                 else if (iptr[0].val.l == 0x00000010)
761                                                                         iptr[0].val.i = 4;
762                                                                 else if (iptr[0].val.l == 0x00000020)
763                                                                         iptr[0].val.i = 5;
764                                                                 else if (iptr[0].val.l == 0x00000040)
765                                                                         iptr[0].val.i = 6;
766                                                                 else if (iptr[0].val.l == 0x00000080)
767                                                                         iptr[0].val.i = 7;
768                                                                 else if (iptr[0].val.l == 0x00000100)
769                                                                         iptr[0].val.i = 8;
770                                                                 else if (iptr[0].val.l == 0x00000200)
771                                                                         iptr[0].val.i = 9;
772                                                                 else if (iptr[0].val.l == 0x00000400)
773                                                                         iptr[0].val.i = 10;
774                                                                 else if (iptr[0].val.l == 0x00000800)
775                                                                         iptr[0].val.i = 11;
776                                                                 else if (iptr[0].val.l == 0x00001000)
777                                                                         iptr[0].val.i = 12;
778                                                                 else if (iptr[0].val.l == 0x00002000)
779                                                                         iptr[0].val.i = 13;
780                                                                 else if (iptr[0].val.l == 0x00004000)
781                                                                         iptr[0].val.i = 14;
782                                                                 else if (iptr[0].val.l == 0x00008000)
783                                                                         iptr[0].val.i = 15;
784                                                                 else if (iptr[0].val.l == 0x00010000)
785                                                                         iptr[0].val.i = 16;
786                                                                 else if (iptr[0].val.l == 0x00020000)
787                                                                         iptr[0].val.i = 17;
788                                                                 else if (iptr[0].val.l == 0x00040000)
789                                                                         iptr[0].val.i = 18;
790                                                                 else if (iptr[0].val.l == 0x00080000)
791                                                                         iptr[0].val.i = 19;
792                                                                 else if (iptr[0].val.l == 0x00100000)
793                                                                         iptr[0].val.i = 20;
794                                                                 else if (iptr[0].val.l == 0x00200000)
795                                                                         iptr[0].val.i = 21;
796                                                                 else if (iptr[0].val.l == 0x00400000)
797                                                                         iptr[0].val.i = 22;
798                                                                 else if (iptr[0].val.l == 0x00800000)
799                                                                         iptr[0].val.i = 23;
800                                                                 else if (iptr[0].val.l == 0x01000000)
801                                                                         iptr[0].val.i = 24;
802                                                                 else if (iptr[0].val.l == 0x02000000)
803                                                                         iptr[0].val.i = 25;
804                                                                 else if (iptr[0].val.l == 0x04000000)
805                                                                         iptr[0].val.i = 26;
806                                                                 else if (iptr[0].val.l == 0x08000000)
807                                                                         iptr[0].val.i = 27;
808                                                                 else if (iptr[0].val.l == 0x10000000)
809                                                                         iptr[0].val.i = 28;
810                                                                 else if (iptr[0].val.l == 0x20000000)
811                                                                         iptr[0].val.i = 29;
812                                                                 else if (iptr[0].val.l == 0x40000000)
813                                                                         iptr[0].val.i = 30;
814                                                                 else if (iptr[0].val.l == 0x80000000)
815                                                                         iptr[0].val.i = 31;
816                                                                 else {
817                                                                         PUSHCONST(TYPE_LNG);
818                                                                         break;
819                                                                 }
820                                                                 iptr[0].opc = ICMD_LDIVPOW2;
821                                                                 goto icmd_lconst_tail;
822                                                         case ICMD_LREM:
823                                                                 if ((iptr[0].val.l == 0x00000002) ||
824                                                                         (iptr[0].val.l == 0x00000004) ||
825                                                                         (iptr[0].val.l == 0x00000008) ||
826                                                                         (iptr[0].val.l == 0x00000010) ||
827                                                                         (iptr[0].val.l == 0x00000020) ||
828                                                                         (iptr[0].val.l == 0x00000040) ||
829                                                                         (iptr[0].val.l == 0x00000080) ||
830                                                                         (iptr[0].val.l == 0x00000100) ||
831                                                                         (iptr[0].val.l == 0x00000200) ||
832                                                                         (iptr[0].val.l == 0x00000400) ||
833                                                                         (iptr[0].val.l == 0x00000800) ||
834                                                                         (iptr[0].val.l == 0x00001000) ||
835                                                                         (iptr[0].val.l == 0x00002000) ||
836                                                                         (iptr[0].val.l == 0x00004000) ||
837                                                                         (iptr[0].val.l == 0x00008000) ||
838                                                                         (iptr[0].val.l == 0x00010000) ||
839                                                                         (iptr[0].val.l == 0x00020000) ||
840                                                                         (iptr[0].val.l == 0x00040000) ||
841                                                                         (iptr[0].val.l == 0x00080000) ||
842                                                                         (iptr[0].val.l == 0x00100000) ||
843                                                                         (iptr[0].val.l == 0x00200000) ||
844                                                                         (iptr[0].val.l == 0x00400000) ||
845                                                                         (iptr[0].val.l == 0x00800000) ||
846                                                                         (iptr[0].val.l == 0x01000000) ||
847                                                                         (iptr[0].val.l == 0x02000000) ||
848                                                                         (iptr[0].val.l == 0x04000000) ||
849                                                                         (iptr[0].val.l == 0x08000000) ||
850                                                                         (iptr[0].val.l == 0x10000000) ||
851                                                                         (iptr[0].val.l == 0x20000000) ||
852                                                                         (iptr[0].val.l == 0x40000000) ||
853                                                                         (iptr[0].val.l == 0x80000000)) {
854                                                                         iptr[0].opc = ICMD_LREMPOW2;
855                                                                         iptr[0].val.l -= 1;
856                                                                         goto icmd_lconst_tail;
857                                                                 }
858                                                                 PUSHCONST(TYPE_LNG);
859                                                                 break;
860 #endif /* SUPPORT_LONG_DIV */
861 #if SUPPORT_LONG_LOGICAL && SUPPORT_CONST_LOGICAL
862
863                                                         case ICMD_LAND:
864                                                                 iptr[0].opc = ICMD_LANDCONST;
865                                                                 goto icmd_lconst_tail;
866                                                         case ICMD_LOR:
867                                                                 iptr[0].opc = ICMD_LORCONST;
868                                                                 goto icmd_lconst_tail;
869                                                         case ICMD_LXOR:
870                                                                 iptr[0].opc = ICMD_LXORCONST;
871                                                                 goto icmd_lconst_tail;
872 #endif /* SUPPORT_LONG_LOGICAL && SUPPORT_CONST_LOGICAL */
873 #if !defined(NOLONG_CONDITIONAL)
874                                                         case ICMD_LCMP:
875                                                                 if ((len > 1) && (iptr[2].val.i == 0)) {
876                                                                         switch (iptr[2].opc) {
877                                                                         case ICMD_IFEQ:
878                                                                                 iptr[0].opc = ICMD_IF_LEQ;
879                                                                         icmd_lconst_lcmp_tail:
880                                                                                 iptr[0].op1 = iptr[2].op1;
881                                                                                 bptr->icount -= 2;
882                                                                                 len -= 2;
883                                                                                 /* iptr[1].opc = ICMD_NOP;
884                                                                                    iptr[2].opc = ICMD_NOP; */
885                                                                                 OP1_0(TYPE_LNG);
886                                                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
887
888                                                                                 iptr[0].target = (void *) tbptr;
889
890                                                                                 MARKREACHED(tbptr, copy);
891                                                                                 COUNT(count_pcmd_bra);
892                                                                                 COUNT(count_pcmd_op);
893                                                                                 break;
894                                                                         case ICMD_IFNE:
895                                                                                 iptr[0].opc = ICMD_IF_LNE;
896                                                                                 goto icmd_lconst_lcmp_tail;
897                                                                         case ICMD_IFLT:
898                                                                                 iptr[0].opc = ICMD_IF_LLT;
899                                                                                 goto icmd_lconst_lcmp_tail;
900                                                                         case ICMD_IFGT:
901                                                                                 iptr[0].opc = ICMD_IF_LGT;
902                                                                                 goto icmd_lconst_lcmp_tail;
903                                                                         case ICMD_IFLE:
904                                                                                 iptr[0].opc = ICMD_IF_LLE;
905                                                                                 goto icmd_lconst_lcmp_tail;
906                                                                         case ICMD_IFGE:
907                                                                                 iptr[0].opc = ICMD_IF_LGE;
908                                                                                 goto icmd_lconst_lcmp_tail;
909                                                                         default:
910                                                                                 PUSHCONST(TYPE_LNG);
911                                                                         } /* switch (iptr[2].opc) */
912                                                                 } /* if (iptr[2].val.i == 0) */
913                                                                 else
914                                                                         PUSHCONST(TYPE_LNG);
915                                                                 break;
916 #endif /* !defined(NOLONG_CONDITIONAL) */
917
918 #if SUPPORT_CONST_STORE
919                                                         case ICMD_LASTORE:
920 # if defined(ENABLE_INTRP)
921                                                                 if (!opt_intrp) {
922 # endif
923 #if SUPPORT_CONST_STORE_ZERO_ONLY
924                                                                         if (iptr[0].val.l == 0) {
925 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
926                                                                                 iptr[0].opc = ICMD_LASTORECONST;
927                                                                                 iptr[1].opc = ICMD_NOP;
928                                                                                 OPTT2_0(TYPE_INT, TYPE_ADR);
929                                                                                 COUNT(count_pcmd_op);
930 #if SUPPORT_CONST_STORE_ZERO_ONLY
931                                                                         } else
932                                                                                 PUSHCONST(TYPE_LNG);
933 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
934 # if defined(ENABLE_INTRP)
935                                                                 } else
936                                                                         PUSHCONST(TYPE_LNG);
937 # endif
938                                                                 break;
939
940                                                         case ICMD_PUTSTATIC:
941                                                         case ICMD_PUTFIELD:
942 #if SUPPORT_CONST_STORE_ZERO_ONLY
943                                                                 if (iptr[0].val.l == 0) {
944 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
945                                                                         switch (iptr[1].opc) {
946                                                                         case ICMD_PUTSTATIC:
947                                                                                 iptr[0].opc = ICMD_PUTSTATICCONST;
948                                                                                 SETDST;
949                                                                                 break;
950                                                                         case ICMD_PUTFIELD:
951                                                                                 iptr[0].opc = ICMD_PUTFIELDCONST;
952                                                                                 OP1_0(TYPE_ADR);
953                                                                                 break;
954                                                                         }
955
956                                                                         iptr[1].opc = ICMD_NOP;
957                                                                         iptr[0].op1 = TYPE_LNG;
958                                                                         COUNT(count_pcmd_op);
959 #if SUPPORT_CONST_STORE_ZERO_ONLY
960                                                                 } else
961                                                                         PUSHCONST(TYPE_LNG);
962 #endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
963                                                                 break;
964 #endif /* SUPPORT_CONST_STORE */
965                                                         default:
966                                                                 PUSHCONST(TYPE_LNG);
967                                                         }
968                                                 }
969                                                 else
970                                                         PUSHCONST(TYPE_LNG);
971                                                 break;
972
973                                         case ICMD_FCONST:
974                                                 COUNT(count_pcmd_load);
975                                                 PUSHCONST(TYPE_FLT);
976                                                 break;
977
978                                         case ICMD_DCONST:
979                                                 COUNT(count_pcmd_load);
980                                                 PUSHCONST(TYPE_DBL);
981                                                 break;
982
983                                         case ICMD_ACONST:
984                                                 COUNT(count_pcmd_load);
985 #if SUPPORT_CONST_STORE
986                                                 if (len > 0 && iptr->val.a == 0) {
987                                                         switch (iptr[1].opc) {
988 #if !defined(__POWERPC__) && !defined(__X86_64__) && !defined(__I386__) && !defined(__ALPHA__) && !defined(__MIPS__)
989                                                         case ICMD_BUILTIN:
990                                                                 if (iptr[1].val.fp != BUILTIN_aastore) {
991                                                                         PUSHCONST(TYPE_ADR);
992                                                                         break;
993                                                                 }
994                                                                 /* fall through */
995 #endif
996                                                         case ICMD_PUTSTATIC:
997                                                         case ICMD_PUTFIELD:
998                                                                 switch (iptr[1].opc) {
999                                                                 case ICMD_BUILTIN:
1000                                                                         iptr[0].opc = ICMD_AASTORECONST;
1001                                                                         OPTT2_0(TYPE_INT, TYPE_ADR);
1002                                                                         break;
1003                                                                 case ICMD_PUTSTATIC:
1004                                                                         iptr[0].opc = ICMD_PUTSTATICCONST;
1005                                                                         iptr[0].op1 = TYPE_ADR;
1006                                                                         SETDST;
1007                                                                         break;
1008                                                                 case ICMD_PUTFIELD:
1009                                                                         iptr[0].opc = ICMD_PUTFIELDCONST;
1010                                                                         iptr[0].op1 = TYPE_ADR;
1011                                                                         OP1_0(TYPE_ADR);
1012                                                                         break;
1013                                                                 }
1014
1015                                                                 iptr[1].opc = ICMD_NOP;
1016                                                                 COUNT(count_pcmd_op);
1017                                                                 break;
1018
1019                                                         default:
1020                                                                 PUSHCONST(TYPE_ADR);
1021                                                         }
1022                                                 } else
1023 #endif /* SUPPORT_CONST_STORE */
1024                                                         PUSHCONST(TYPE_ADR);
1025                                                 break;
1026
1027                                                 /* pop 0 push 1 load */
1028                                                 
1029                                         case ICMD_ILOAD:
1030                                         case ICMD_LLOAD:
1031                                         case ICMD_FLOAD:
1032                                         case ICMD_DLOAD:
1033                                         case ICMD_ALOAD:
1034                                                 COUNT(count_load_instruction);
1035                                                 i = opcode - ICMD_ILOAD;
1036                                                 iptr->op1 = argren[iptr->op1];
1037 #if defined(ENABLE_INTRP)
1038                                                 if (!opt_intrp)
1039 #endif
1040                                                         rd->locals[iptr->op1][i].type = i;
1041                                                 LOAD(i, LOCALVAR, iptr->op1);
1042                                                 break;
1043
1044                                                 /* pop 2 push 1 */
1045
1046                                         case ICMD_LALOAD:
1047                                         case ICMD_IALOAD:
1048                                         case ICMD_FALOAD:
1049                                         case ICMD_DALOAD:
1050                                         case ICMD_AALOAD:
1051                                                 COUNT(count_check_null);
1052                                                 COUNT(count_check_bound);
1053                                                 COUNT(count_pcmd_mem);
1054                                                 OP2IAT_1(opcode - ICMD_IALOAD);
1055                                                 break;
1056
1057                                         case ICMD_BALOAD:
1058                                         case ICMD_CALOAD:
1059                                         case ICMD_SALOAD:
1060                                                 COUNT(count_check_null);
1061                                                 COUNT(count_check_bound);
1062                                                 COUNT(count_pcmd_mem);
1063                                                 OP2IAT_1(TYPE_INT);
1064                                                 break;
1065
1066                                                 /* pop 0 push 0 iinc */
1067
1068                                         case ICMD_IINC:
1069 #if defined(STATISTICS)
1070                                                 if (opt_stat) {
1071                                                         i = stackdepth;
1072                                                         if (i >= 10)
1073                                                                 count_store_depth[10]++;
1074                                                         else
1075                                                                 count_store_depth[i]++;
1076                                                 }
1077 #endif
1078                                                 copy = curstack;
1079                                                 i = stackdepth - 1;
1080                                                 while (copy) {
1081                                                         if ((copy->varkind == LOCALVAR) &&
1082                                                                 (copy->varnum == iptr->op1)) {
1083                                                                 copy->varkind = TEMPVAR;
1084                                                                 copy->varnum = i;
1085                                                         }
1086                                                         i--;
1087                                                         copy = copy->prev;
1088                                                 }
1089                                                 SETDST;
1090                                                 break;
1091
1092                                                 /* pop 1 push 0 store */
1093
1094                                         case ICMD_ISTORE:
1095                                         case ICMD_LSTORE:
1096                                         case ICMD_FSTORE:
1097                                         case ICMD_DSTORE:
1098                                         case ICMD_ASTORE:
1099                                         icmd_store:
1100                                                 REQUIRE_1;
1101
1102                                         i = opcode - ICMD_ISTORE;
1103 #if defined(ENABLE_INTRP)
1104                                                 if (!opt_intrp)
1105 #endif
1106                                                         rd->locals[iptr->op1][i].type = i;
1107 #if defined(STATISTICS)
1108                                         if (opt_stat) {
1109                                                 count_pcmd_store++;
1110                                                 i = new - curstack;
1111                                                 if (i >= 20)
1112                                                         count_store_length[20]++;
1113                                                 else
1114                                                         count_store_length[i]++;
1115                                                 i = stackdepth - 1;
1116                                                 if (i >= 10)
1117                                                         count_store_depth[10]++;
1118                                                 else
1119                                                         count_store_depth[i]++;
1120                                         }
1121 #endif
1122                                         copy = curstack->prev;
1123                                         i = stackdepth - 2;
1124                                         while (copy) {
1125                                                 if ((copy->varkind == LOCALVAR) &&
1126                                                         (copy->varnum == iptr->op1)) {
1127                                                         copy->varkind = TEMPVAR;
1128                                                         copy->varnum = i;
1129                                                 }
1130                                                 i--;
1131                                                 copy = copy->prev;
1132                                         }
1133                                         if ((new - curstack) == 1) {
1134                                                 curstack->varkind = LOCALVAR;
1135                                                 curstack->varnum = iptr->op1;
1136                                         };
1137                                         STORE(opcode - ICMD_ISTORE);
1138                                         break;
1139
1140                                         /* pop 3 push 0 */
1141
1142                                         case ICMD_AASTORE:
1143                                                 COUNT(count_check_null);
1144                                                 COUNT(count_check_bound);
1145                                                 COUNT(count_pcmd_mem);
1146
1147                                                 bte = (builtintable_entry *) iptr->val.a;
1148                                                 md = bte->md;
1149                                                 i = iptr->op1;
1150
1151                                                 if (md->memuse > rd->memuse)
1152                                                         rd->memuse = md->memuse;
1153                                                 if (md->argintreguse > rd->argintreguse)
1154                                                         rd->argintreguse = md->argintreguse;
1155
1156                                                 /* make all stack variables saved */
1157
1158                                                 copy = curstack;
1159                                                 while (copy) {
1160                                                         copy->flags |= SAVEDVAR;
1161                                                         copy = copy->prev;
1162                                                 }
1163
1164                                                 OP3TIA_0(TYPE_ADR);
1165                                                 break;
1166
1167                                         case ICMD_IASTORE:
1168                                         case ICMD_LASTORE:
1169                                         case ICMD_FASTORE:
1170                                         case ICMD_DASTORE:
1171                                                 COUNT(count_check_null);
1172                                                 COUNT(count_check_bound);
1173                                                 COUNT(count_pcmd_mem);
1174                                                 OP3TIA_0(opcode - ICMD_IASTORE);
1175                                                 break;
1176
1177                                         case ICMD_BASTORE:
1178                                         case ICMD_CASTORE:
1179                                         case ICMD_SASTORE:
1180                                                 COUNT(count_check_null);
1181                                                 COUNT(count_check_bound);
1182                                                 COUNT(count_pcmd_mem);
1183                                                 OP3TIA_0(TYPE_INT);
1184                                                 break;
1185
1186                                                 /* pop 1 push 0 */
1187
1188                                         case ICMD_POP:
1189 #ifdef TYPECHECK_STACK_COMPCAT
1190                                                 if (opt_verify) {
1191                                                         REQUIRE_1;
1192                                                         if (IS_2_WORD_TYPE(curstack->type)) {
1193                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1194                                                                 return NULL;
1195                                                         }
1196                                                 }
1197 #endif
1198                                                 OP1_0ANY;
1199                                                 break;
1200
1201                                         case ICMD_IRETURN:
1202                                         case ICMD_LRETURN:
1203                                         case ICMD_FRETURN:
1204                                         case ICMD_DRETURN:
1205                                         case ICMD_ARETURN:
1206                                                 md_return_alloc(m, rd, opcode - ICMD_IRETURN, curstack);
1207                                                 COUNT(count_pcmd_return);
1208                                                 OP1_0(opcode - ICMD_IRETURN);
1209                                                 superblockend = true;
1210                                                 break;
1211
1212                                         case ICMD_ATHROW:
1213                                                 COUNT(count_check_null);
1214                                                 OP1_0(TYPE_ADR);
1215                                                 STACKRESET;
1216                                                 SETDST;
1217                                                 superblockend = true;
1218                                                 break;
1219
1220                                         case ICMD_PUTSTATIC:
1221                                                 COUNT(count_pcmd_mem);
1222                                                 OP1_0(iptr->op1);
1223                                                 break;
1224
1225                                                 /* pop 1 push 0 branch */
1226
1227                                         case ICMD_IFNULL:
1228                                         case ICMD_IFNONNULL:
1229                                                 COUNT(count_pcmd_bra);
1230                                                 OP1_0(TYPE_ADR);
1231                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1232
1233                                                 iptr[0].target = (void *) tbptr;
1234
1235                                                 MARKREACHED(tbptr, copy);
1236                                                 break;
1237
1238                                         case ICMD_IFEQ:
1239                                         case ICMD_IFNE:
1240                                         case ICMD_IFLT:
1241                                         case ICMD_IFGE:
1242                                         case ICMD_IFGT:
1243                                         case ICMD_IFLE:
1244                                                 COUNT(count_pcmd_bra);
1245 #if CONDITIONAL_LOADCONST
1246 # if defined(ENABLE_INTRP)
1247                                                 if (!opt_intrp) {
1248 # endif
1249                                                         tbptr = m->basicblocks + b_index;
1250                                                         if ((b_count >= 3) &&
1251                                                                 ((b_index + 2) == m->basicblockindex[iptr[0].op1]) &&
1252                                                                 (tbptr[1].pre_count == 1) &&
1253                                                                 (tbptr[1].iinstr[0].opc == ICMD_ICONST) &&
1254                                                                 (tbptr[1].iinstr[1].opc == ICMD_GOTO)   &&
1255                                                                 ((b_index + 3) == m->basicblockindex[tbptr[1].iinstr[1].op1]) &&
1256                                                                 (tbptr[2].pre_count == 1) &&
1257                                                                 (tbptr[2].iinstr[0].opc == ICMD_ICONST)  &&
1258                                                                 (tbptr[2].icount==1)) {
1259                                                                 /*printf("tbptr[2].icount=%d\n",tbptr[2].icount);*/
1260                                                                 OP1_1(TYPE_INT, TYPE_INT);
1261                                                                 switch (iptr[0].opc) {
1262                                                                 case ICMD_IFEQ:
1263                                                                         iptr[0].opc = ICMD_IFNE_ICONST;
1264                                                                         break;
1265                                                                 case ICMD_IFNE:
1266                                                                         iptr[0].opc = ICMD_IFEQ_ICONST;
1267                                                                         break;
1268                                                                 case ICMD_IFLT:
1269                                                                         iptr[0].opc = ICMD_IFGE_ICONST;
1270                                                                         break;
1271                                                                 case ICMD_IFGE:
1272                                                                         iptr[0].opc = ICMD_IFLT_ICONST;
1273                                                                         break;
1274                                                                 case ICMD_IFGT:
1275                                                                         iptr[0].opc = ICMD_IFLE_ICONST;
1276                                                                         break;
1277                                                                 case ICMD_IFLE:
1278                                                                         iptr[0].opc = ICMD_IFGT_ICONST;
1279                                                                         break;
1280                                                                 }
1281 #if 1
1282                                                                 iptr[0].val.i = iptr[1].val.i;
1283                                                                 iptr[1].opc = ICMD_ELSE_ICONST;
1284                                                                 iptr[1].val.i = iptr[3].val.i;
1285                                                                 iptr[2].opc = ICMD_NOP;
1286                                                                 iptr[3].opc = ICMD_NOP;
1287 #else
1288                                                                 /* HACK: save compare value in iptr[1].op1 */    
1289                                                                 iptr[1].op1 = iptr[0].val.i;     
1290                                                                 iptr[0].val.i = tbptr[1].iinstr[0].val.i;        
1291                                                                 iptr[1].opc = ICMD_ELSE_ICONST;          
1292                                                                 iptr[1].val.i = tbptr[2].iinstr[0].val.i;        
1293                                                                 tbptr[1].iinstr[0].opc = ICMD_NOP;       
1294                                                                 tbptr[1].iinstr[1].opc = ICMD_NOP;       
1295                                                                 tbptr[2].iinstr[0].opc = ICMD_NOP;       
1296 #endif
1297                                                                 tbptr[1].flags = BBDELETED;
1298                                                                 tbptr[2].flags = BBDELETED;
1299                                                                 tbptr[1].icount = 0;
1300                                                                 tbptr[2].icount = 0;
1301                                                                 if (tbptr[3].pre_count == 2) {
1302                                                                         len += tbptr[3].icount + 3;
1303                                                                         bptr->icount += tbptr[3].icount + 3;
1304                                                                         tbptr[3].flags = BBDELETED;
1305                                                                         tbptr[3].icount = 0;
1306                                                                         b_index++;
1307                                                                 }
1308                                                                 else {
1309                                                                         bptr->icount++;
1310                                                                         len ++;
1311                                                                 }
1312                                                                 b_index += 2;
1313                                                                 break;
1314                                                         }
1315 # if defined(ENABLE_INTRP)
1316                                                 }
1317 # endif
1318
1319 #endif /* CONDITIONAL_LOADCONST */
1320
1321                                                 OP1_0(TYPE_INT);
1322                                                 iptr->val.i = 0;
1323                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1324
1325                                                 iptr[0].target = (void *) tbptr;
1326
1327                                                 MARKREACHED(tbptr, copy);
1328                                                 break;
1329
1330                                                 /* pop 0 push 0 branch */
1331
1332                                         case ICMD_GOTO:
1333                                                 COUNT(count_pcmd_bra);
1334                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1335
1336                                                 iptr[0].target = (void *) tbptr;
1337
1338                                                 MARKREACHED(tbptr, copy);
1339                                                 SETDST;
1340                                                 superblockend = true;
1341                                                 break;
1342
1343                                                 /* pop 1 push 0 table branch */
1344
1345                                         case ICMD_TABLESWITCH:
1346                                                 COUNT(count_pcmd_table);
1347                                                 OP1_0(TYPE_INT);
1348                                                 s4ptr = iptr->val.a;
1349                                                 tbptr = m->basicblocks + m->basicblockindex[*s4ptr++];
1350                                                 MARKREACHED(tbptr, copy);
1351                                                 i = *s4ptr++;                          /* low     */
1352                                                 i = *s4ptr++ - i + 1;                  /* high    */
1353
1354                                                 tptr = DMNEW(void*, i+1);
1355                                                 iptr->target = (void *) tptr;
1356
1357                                                 tptr[0] = (void *) tbptr;
1358                                                 tptr++;
1359
1360                                                 while (--i >= 0) {
1361                                                         tbptr = m->basicblocks + m->basicblockindex[*s4ptr++];
1362
1363                                                         tptr[0] = (void *) tbptr;
1364                                                         tptr++;
1365
1366                                                         MARKREACHED(tbptr, copy);
1367                                                 }
1368                                                 SETDST;
1369                                                 superblockend = true;
1370                                                 break;
1371                                                         
1372                                                 /* pop 1 push 0 table branch */
1373
1374                                         case ICMD_LOOKUPSWITCH:
1375                                                 COUNT(count_pcmd_table);
1376                                                 OP1_0(TYPE_INT);
1377                                                 s4ptr = iptr->val.a;
1378                                                 tbptr = m->basicblocks + m->basicblockindex[*s4ptr++];
1379                                                 MARKREACHED(tbptr, copy);
1380                                                 i = *s4ptr++;                          /* count   */
1381
1382                                                 tptr = DMNEW(void*, i+1);
1383                                                 iptr->target = (void *) tptr;
1384
1385                                                 tptr[0] = (void *) tbptr;
1386                                                 tptr++;
1387
1388                                                 while (--i >= 0) {
1389                                                         tbptr = m->basicblocks + m->basicblockindex[s4ptr[1]];
1390
1391                                                         tptr[0] = (void *) tbptr;
1392                                                         tptr++;
1393                                                                 
1394                                                         MARKREACHED(tbptr, copy);
1395                                                         s4ptr += 2;
1396                                                 }
1397                                                 SETDST;
1398                                                 superblockend = true;
1399                                                 break;
1400
1401                                         case ICMD_MONITORENTER:
1402                                                 COUNT(count_check_null);
1403                                         case ICMD_MONITOREXIT:
1404                                                 OP1_0(TYPE_ADR);
1405                                                 break;
1406
1407                                                 /* pop 2 push 0 branch */
1408
1409                                         case ICMD_IF_ICMPEQ:
1410                                         case ICMD_IF_ICMPNE:
1411                                         case ICMD_IF_ICMPLT:
1412                                         case ICMD_IF_ICMPGE:
1413                                         case ICMD_IF_ICMPGT:
1414                                         case ICMD_IF_ICMPLE:
1415                                                 COUNT(count_pcmd_bra);
1416                                                 OP2_0(TYPE_INT);
1417                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1418                                                         
1419                                                 iptr[0].target = (void *) tbptr;
1420
1421                                                 MARKREACHED(tbptr, copy);
1422                                                 break;
1423
1424                                         case ICMD_IF_ACMPEQ:
1425                                         case ICMD_IF_ACMPNE:
1426                                                 COUNT(count_pcmd_bra);
1427                                                 OP2_0(TYPE_ADR);
1428                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1429
1430                                                 iptr[0].target = (void *) tbptr;
1431
1432                                                 MARKREACHED(tbptr, copy);
1433                                                 break;
1434
1435                                                 /* pop 2 push 0 */
1436
1437                                         case ICMD_PUTFIELD:
1438                                                 COUNT(count_check_null);
1439                                                 COUNT(count_pcmd_mem);
1440                                                 OPTT2_0(iptr->op1,TYPE_ADR);
1441                                                 break;
1442
1443                                         case ICMD_POP2:
1444                                                 REQUIRE_1;
1445                                                 if (!IS_2_WORD_TYPE(curstack->type)) {
1446                                                         /* ..., cat1 */
1447 #ifdef TYPECHECK_STACK_COMPCAT
1448                                                         if (opt_verify) {
1449                                                                 REQUIRE_2;
1450                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1451                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1452                                                                         return NULL;
1453                                                                 }
1454                                                         }
1455 #endif
1456                                                         OP1_0ANY;                /* second pop */
1457                                                 }
1458                                                 else
1459                                                         iptr->opc = ICMD_POP;
1460                                                 OP1_0ANY;
1461                                                 break;
1462
1463                                                 /* pop 0 push 1 dup */
1464                                                 
1465                                         case ICMD_DUP:
1466 #ifdef TYPECHECK_STACK_COMPCAT
1467                                                 if (opt_verify) {
1468                                                         REQUIRE_1;
1469                                                         if (IS_2_WORD_TYPE(curstack->type)) {
1470                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1471                                                                 return NULL;
1472                                                         }
1473                                                 }
1474 #endif
1475                                                 COUNT(count_dup_instruction);
1476                                                 DUP;
1477                                                 break;
1478
1479                                         case ICMD_DUP2:
1480                                                 REQUIRE_1;
1481                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1482                                                         /* ..., cat2 */
1483                                                         iptr->opc = ICMD_DUP;
1484                                                         DUP;
1485                                                 }
1486                                                 else {
1487                                                         REQUIRE_2;
1488                                                         /* ..., ????, cat1 */
1489 #ifdef TYPECHECK_STACK_COMPCAT
1490                                                         if (opt_verify) {
1491                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1492                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1493                                                                         return NULL;
1494                                                                 }
1495                                                         }
1496 #endif
1497                                                         copy = curstack;
1498                                                         NEWSTACK(copy->prev->type, copy->prev->varkind,
1499                                                                          copy->prev->varnum);
1500                                                         NEWSTACK(copy->type, copy->varkind,
1501                                                                          copy->varnum);
1502                                                         SETDST;
1503                                                         stackdepth += 2;
1504                                                 }
1505                                                 break;
1506
1507                                                 /* pop 2 push 3 dup */
1508                                                 
1509                                         case ICMD_DUP_X1:
1510 #ifdef TYPECHECK_STACK_COMPCAT
1511                                                 if (opt_verify) {
1512                                                         REQUIRE_2;
1513                                                         if (IS_2_WORD_TYPE(curstack->type) ||
1514                                                                 IS_2_WORD_TYPE(curstack->prev->type)) {
1515                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1516                                                                         return NULL;
1517                                                         }
1518                                                 }
1519 #endif
1520                                                 DUP_X1;
1521                                                 break;
1522
1523                                         case ICMD_DUP2_X1:
1524                                                 REQUIRE_2;
1525                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1526                                                         /* ..., ????, cat2 */
1527 #ifdef TYPECHECK_STACK_COMPCAT
1528                                                         if (opt_verify) {
1529                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1530                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1531                                                                         return NULL;
1532                                                                 }
1533                                                         }
1534 #endif
1535                                                         iptr->opc = ICMD_DUP_X1;
1536                                                         DUP_X1;
1537                                                 }
1538                                                 else {
1539                                                         /* ..., ????, cat1 */
1540 #ifdef TYPECHECK_STACK_COMPCAT
1541                                                         if (opt_verify) {
1542                                                                 REQUIRE_3;
1543                                                                 if (IS_2_WORD_TYPE(curstack->prev->type)
1544                                                                         || IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1545                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1546                                                                         return NULL;
1547                                                                 }
1548                                                         }
1549 #endif
1550                                                         DUP2_X1;
1551                                                 }
1552                                                 break;
1553
1554                                                 /* pop 3 push 4 dup */
1555                                                 
1556                                         case ICMD_DUP_X2:
1557                                                 REQUIRE_2;
1558                                                 if (IS_2_WORD_TYPE(curstack->prev->type)) {
1559                                                         /* ..., cat2, ???? */
1560 #ifdef TYPECHECK_STACK_COMPCAT
1561                                                         if (opt_verify) {
1562                                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1563                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1564                                                                         return NULL;
1565                                                                 }
1566                                                         }
1567 #endif
1568                                                         iptr->opc = ICMD_DUP_X1;
1569                                                         DUP_X1;
1570                                                 }
1571                                                 else {
1572                                                         /* ..., cat1, ???? */
1573 #ifdef TYPECHECK_STACK_COMPCAT
1574                                                         if (opt_verify) {
1575                                                                 REQUIRE_3;
1576                                                                 if (IS_2_WORD_TYPE(curstack->type)
1577                                                                         || IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1578                                                                         *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1579                                                                         return NULL;
1580                                                                 }
1581                                                         }
1582 #endif
1583                                                         DUP_X2;
1584                                                 }
1585                                                 break;
1586
1587                                         case ICMD_DUP2_X2:
1588                                                 REQUIRE_2;
1589                                                 if (IS_2_WORD_TYPE(curstack->type)) {
1590                                                         /* ..., ????, cat2 */
1591                                                         if (IS_2_WORD_TYPE(curstack->prev->type)) {
1592                                                                 /* ..., cat2, cat2 */
1593                                                                 iptr->opc = ICMD_DUP_X1;
1594                                                                 DUP_X1;
1595                                                         }
1596                                                         else {
1597                                                                 /* ..., cat1, cat2 */
1598 #ifdef TYPECHECK_STACK_COMPCAT
1599                                                                 if (opt_verify) {
1600                                                                         REQUIRE_3;
1601                                                                         if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1602                                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1603                                                                                 return NULL;
1604                                                                         }
1605                                                                 }
1606 #endif
1607                                                                 iptr->opc = ICMD_DUP_X2;
1608                                                                 DUP_X2;
1609                                                         }
1610                                                 }
1611                                                 else {
1612                                                         REQUIRE_3;
1613                                                         /* ..., ????, ????, cat1 */
1614                                                         if (IS_2_WORD_TYPE(curstack->prev->prev->type)) {
1615                                                                 /* ..., cat2, ????, cat1 */
1616 #ifdef TYPECHECK_STACK_COMPCAT
1617                                                                 if (opt_verify) {
1618                                                                         if (IS_2_WORD_TYPE(curstack->prev->type)) {
1619                                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1620                                                                                 return NULL;
1621                                                                         }
1622                                                                 }
1623 #endif
1624                                                                 iptr->opc = ICMD_DUP2_X1;
1625                                                                 DUP2_X1;
1626                                                         }
1627                                                         else {
1628                                                                 /* ..., cat1, ????, cat1 */
1629 #ifdef TYPECHECK_STACK_COMPCAT
1630                                                                 if (opt_verify) {
1631                                                                         REQUIRE_4;
1632                                                                         if (IS_2_WORD_TYPE(curstack->prev->type)
1633                                                                                 || IS_2_WORD_TYPE(curstack->prev->prev->prev->type)) {
1634                                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1635                                                                                 return NULL;
1636                                                                         }
1637                                                                 }
1638 #endif
1639                                                                 DUP2_X2;
1640                                                         }
1641                                                 }
1642                                                 break;
1643
1644                                                 /* pop 2 push 2 swap */
1645                                                 
1646                                         case ICMD_SWAP:
1647 #ifdef TYPECHECK_STACK_COMPCAT
1648                                                 if (opt_verify) {
1649                                                         REQUIRE_2;
1650                                                         if (IS_2_WORD_TYPE(curstack->type)
1651                                                                 || IS_2_WORD_TYPE(curstack->prev->type)) {
1652                                                                 *exceptionptr = new_verifyerror(m, "Attempt to split long or double on the stack");
1653                                                                 return NULL;
1654                                                         }
1655                                                 }
1656 #endif
1657                                                 SWAP;
1658                                                 break;
1659
1660                                                 /* pop 2 push 1 */
1661
1662                                         case ICMD_IDIV:
1663                                         case ICMD_IREM:
1664 #if !SUPPORT_DIVISION
1665                                                 bte = (builtintable_entry *) iptr->val.a;
1666                                                 md = bte->md;
1667                                                 i = iptr->op1;
1668
1669                                                 if (md->memuse > rd->memuse)
1670                                                         rd->memuse = md->memuse;
1671                                                 if (md->argintreguse > rd->argintreguse)
1672                                                         rd->argintreguse = md->argintreguse;
1673
1674                                                 /* make all stack variables saved */
1675
1676                                                 copy = curstack;
1677                                                 while (copy) {
1678                                                         copy->flags |= SAVEDVAR;
1679                                                         copy = copy->prev;
1680                                                 }
1681 #endif /* !SUPPORT_DIVISION */
1682
1683                                         case ICMD_ISHL:
1684                                         case ICMD_ISHR:
1685                                         case ICMD_IUSHR:
1686                                         case ICMD_IADD:
1687                                         case ICMD_ISUB:
1688                                         case ICMD_IMUL:
1689                                         case ICMD_IAND:
1690                                         case ICMD_IOR:
1691                                         case ICMD_IXOR:
1692                                                 COUNT(count_pcmd_op);
1693                                                 OP2_1(TYPE_INT);
1694                                                 break;
1695
1696                                         case ICMD_LDIV:
1697                                         case ICMD_LREM:
1698 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1699                                                 bte = (builtintable_entry *) iptr->val.a;
1700                                                 md = bte->md;
1701                                                 i = iptr->op1;
1702
1703                                                 if (md->memuse > rd->memuse)
1704                                                         rd->memuse = md->memuse;
1705                                                 if (md->argintreguse > rd->argintreguse)
1706                                                         rd->argintreguse = md->argintreguse;
1707
1708                                                 /* make all stack variables saved */
1709
1710                                                 copy = curstack;
1711                                                 while (copy) {
1712                                                         copy->flags |= SAVEDVAR;
1713                                                         copy = copy->prev;
1714                                                 }
1715 #endif /* !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) */
1716
1717                                         case ICMD_LMUL:
1718                                         case ICMD_LADD:
1719                                         case ICMD_LSUB:
1720 #if SUPPORT_LONG_LOGICAL
1721                                         case ICMD_LAND:
1722                                         case ICMD_LOR:
1723                                         case ICMD_LXOR:
1724 #endif /* SUPPORT_LONG_LOGICAL */
1725                                                 COUNT(count_pcmd_op);
1726                                                 OP2_1(TYPE_LNG);
1727                                                 break;
1728
1729                                         case ICMD_LSHL:
1730                                         case ICMD_LSHR:
1731                                         case ICMD_LUSHR:
1732                                                 COUNT(count_pcmd_op);
1733                                                 OP2IT_1(TYPE_LNG);
1734                                                 break;
1735
1736                                         case ICMD_FADD:
1737                                         case ICMD_FSUB:
1738                                         case ICMD_FMUL:
1739                                         case ICMD_FDIV:
1740                                         case ICMD_FREM:
1741                                                 COUNT(count_pcmd_op);
1742                                                 OP2_1(TYPE_FLT);
1743                                                 break;
1744
1745                                         case ICMD_DADD:
1746                                         case ICMD_DSUB:
1747                                         case ICMD_DMUL:
1748                                         case ICMD_DDIV:
1749                                         case ICMD_DREM:
1750                                                 COUNT(count_pcmd_op);
1751                                                 OP2_1(TYPE_DBL);
1752                                                 break;
1753
1754                                         case ICMD_LCMP:
1755                                                 COUNT(count_pcmd_op);
1756 #if !defined(NOLONG_CONDITIONAL)
1757                                                 if ((len > 0) && (iptr[1].val.i == 0)) {
1758                                                         switch (iptr[1].opc) {
1759                                                         case ICMD_IFEQ:
1760                                                                 iptr[0].opc = ICMD_IF_LCMPEQ;
1761                                                         icmd_lcmp_if_tail:
1762                                                                 iptr[0].op1 = iptr[1].op1;
1763                                                                 len--;
1764                                                                 bptr->icount--;
1765                                                                 /* iptr[1].opc = ICMD_NOP; */
1766                                                                 OP2_0(TYPE_LNG);
1767                                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1768                         
1769                                                                 iptr[0].target = (void *) tbptr;
1770
1771                                                                 MARKREACHED(tbptr, copy);
1772                                                                 COUNT(count_pcmd_bra);
1773                                                                 break;
1774                                                         case ICMD_IFNE:
1775                                                                 iptr[0].opc = ICMD_IF_LCMPNE;
1776                                                                 goto icmd_lcmp_if_tail;
1777                                                         case ICMD_IFLT:
1778                                                                 iptr[0].opc = ICMD_IF_LCMPLT;
1779                                                                 goto icmd_lcmp_if_tail;
1780                                                         case ICMD_IFGT:
1781                                                                 iptr[0].opc = ICMD_IF_LCMPGT;
1782                                                                 goto icmd_lcmp_if_tail;
1783                                                         case ICMD_IFLE:
1784                                                                 iptr[0].opc = ICMD_IF_LCMPLE;
1785                                                                 goto icmd_lcmp_if_tail;
1786                                                         case ICMD_IFGE:
1787                                                                 iptr[0].opc = ICMD_IF_LCMPGE;
1788                                                                 goto icmd_lcmp_if_tail;
1789                                                         default:
1790                                                                 OPTT2_1(TYPE_LNG, TYPE_INT);
1791                                                         }
1792                                                 }
1793                                                 else
1794 #endif
1795                                                         OPTT2_1(TYPE_LNG, TYPE_INT);
1796                                                 break;
1797                                         case ICMD_FCMPL:
1798                                         case ICMD_FCMPG:
1799                                                 COUNT(count_pcmd_op);
1800                                                 OPTT2_1(TYPE_FLT, TYPE_INT);
1801                                                 break;
1802                                         case ICMD_DCMPL:
1803                                         case ICMD_DCMPG:
1804                                                 COUNT(count_pcmd_op);
1805                                                 OPTT2_1(TYPE_DBL, TYPE_INT);
1806                                                 break;
1807
1808                                                 /* pop 1 push 1 */
1809                                                 
1810                                         case ICMD_INEG:
1811                                         case ICMD_INT2BYTE:
1812                                         case ICMD_INT2CHAR:
1813                                         case ICMD_INT2SHORT:
1814                                                 COUNT(count_pcmd_op);
1815                                                 OP1_1(TYPE_INT, TYPE_INT);
1816                                                 break;
1817                                         case ICMD_LNEG:
1818                                                 COUNT(count_pcmd_op);
1819                                                 OP1_1(TYPE_LNG, TYPE_LNG);
1820                                                 break;
1821                                         case ICMD_FNEG:
1822                                                 COUNT(count_pcmd_op);
1823                                                 OP1_1(TYPE_FLT, TYPE_FLT);
1824                                                 break;
1825                                         case ICMD_DNEG:
1826                                                 COUNT(count_pcmd_op);
1827                                                 OP1_1(TYPE_DBL, TYPE_DBL);
1828                                                 break;
1829
1830                                         case ICMD_I2L:
1831                                                 COUNT(count_pcmd_op);
1832                                                 OP1_1(TYPE_INT, TYPE_LNG);
1833                                                 break;
1834                                         case ICMD_I2F:
1835                                                 COUNT(count_pcmd_op);
1836                                                 OP1_1(TYPE_INT, TYPE_FLT);
1837                                                 break;
1838                                         case ICMD_I2D:
1839                                                 COUNT(count_pcmd_op);
1840                                                 OP1_1(TYPE_INT, TYPE_DBL);
1841                                                 break;
1842                                         case ICMD_L2I:
1843                                                 COUNT(count_pcmd_op);
1844                                                 OP1_1(TYPE_LNG, TYPE_INT);
1845                                                 break;
1846                                         case ICMD_L2F:
1847                                                 COUNT(count_pcmd_op);
1848                                                 OP1_1(TYPE_LNG, TYPE_FLT);
1849                                                 break;
1850                                         case ICMD_L2D:
1851                                                 COUNT(count_pcmd_op);
1852                                                 OP1_1(TYPE_LNG, TYPE_DBL);
1853                                                 break;
1854                                         case ICMD_F2I:
1855                                                 COUNT(count_pcmd_op);
1856                                                 OP1_1(TYPE_FLT, TYPE_INT);
1857                                                 break;
1858                                         case ICMD_F2L:
1859                                                 COUNT(count_pcmd_op);
1860                                                 OP1_1(TYPE_FLT, TYPE_LNG);
1861                                                 break;
1862                                         case ICMD_F2D:
1863                                                 COUNT(count_pcmd_op);
1864                                                 OP1_1(TYPE_FLT, TYPE_DBL);
1865                                                 break;
1866                                         case ICMD_D2I:
1867                                                 COUNT(count_pcmd_op);
1868                                                 OP1_1(TYPE_DBL, TYPE_INT);
1869                                                 break;
1870                                         case ICMD_D2L:
1871                                                 COUNT(count_pcmd_op);
1872                                                 OP1_1(TYPE_DBL, TYPE_LNG);
1873                                                 break;
1874                                         case ICMD_D2F:
1875                                                 COUNT(count_pcmd_op);
1876                                                 OP1_1(TYPE_DBL, TYPE_FLT);
1877                                                 break;
1878
1879                                         case ICMD_CHECKCAST:
1880                                                 OP1_1(TYPE_ADR, TYPE_ADR);
1881                                                 break;
1882
1883                                         case ICMD_ARRAYCHECKCAST:
1884                                                 bte = (builtintable_entry *) iptr->val.a;
1885                                                 md = bte->md;
1886
1887                                                 if (md->memuse > rd->memuse)
1888                                                         rd->memuse = md->memuse;
1889                                                 if (md->argintreguse > rd->argintreguse)
1890                                                         rd->argintreguse = md->argintreguse;
1891
1892                                                 /* make all stack variables saved */
1893
1894                                                 copy = curstack;
1895                                                 while (copy) {
1896                                                         copy->flags |= SAVEDVAR;
1897                                                         copy = copy->prev;
1898                                                 }
1899
1900                                                 OP1_1(TYPE_ADR, TYPE_ADR);
1901                                                 break;
1902
1903                                         case ICMD_INSTANCEOF:
1904                                         case ICMD_ARRAYLENGTH:
1905                                                 OP1_1(TYPE_ADR, TYPE_INT);
1906                                                 break;
1907
1908                                         case ICMD_NEWARRAY:
1909                                         case ICMD_ANEWARRAY:
1910                                                 OP1_1(TYPE_INT, TYPE_ADR);
1911                                                 break;
1912
1913                                         case ICMD_GETFIELD:
1914                                                 COUNT(count_check_null);
1915                                                 COUNT(count_pcmd_mem);
1916                                                 OP1_1(TYPE_ADR, iptr->op1);
1917                                                 break;
1918
1919                                                 /* pop 0 push 1 */
1920                                                 
1921                                         case ICMD_GETSTATIC:
1922                                                 COUNT(count_pcmd_mem);
1923                                                 OP0_1(iptr->op1);
1924                                                 break;
1925
1926                                         case ICMD_NEW:
1927                                                 OP0_1(TYPE_ADR);
1928                                                 break;
1929
1930                                         case ICMD_JSR:
1931                                                 OP0_1(TYPE_ADR);
1932                                                 tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
1933
1934                                                 iptr[0].target = (void *) tbptr;
1935
1936                                                 /* This is a dirty hack. The typechecker
1937                                                  * needs it because the OP1_0ANY below
1938                                                  * overwrites iptr->dst.
1939                                                  */
1940                                                 iptr->val.a = (void *) iptr->dst;
1941
1942                                                 tbptr->type = BBTYPE_SBR;
1943
1944                                                 /* We need to check for overflow right here because
1945                                                  * the pushed value is poped after MARKREACHED. */
1946                                                 CHECKOVERFLOW;
1947                                                 MARKREACHED(tbptr, copy);
1948                                                 OP1_0ANY;
1949                                                 break;
1950
1951                                         /* pop many push any */
1952
1953                                         case ICMD_BUILTIN:
1954 #if defined(USEBUILTINTABLE)
1955                                         builtin:
1956 #endif
1957                                                 bte = (builtintable_entry *) iptr->val.a;
1958                                                 md = bte->md;
1959                                                 goto _callhandling;
1960
1961                                         case ICMD_INVOKESTATIC:
1962                                         case ICMD_INVOKESPECIAL:
1963                                         case ICMD_INVOKEVIRTUAL:
1964                                         case ICMD_INVOKEINTERFACE:
1965                                                 COUNT(count_pcmd_met);
1966                                                 um = iptr->target;
1967                                                 md = um->methodref->parseddesc.md;
1968 /*                          if (lm->flags & ACC_STATIC) */
1969 /*                              {COUNT(count_check_null);} */    
1970
1971                                         _callhandling:
1972                                                 i = md->paramcount;
1973
1974                                                 if (md->memuse > rd->memuse)
1975                                                         rd->memuse = md->memuse;
1976                                                 if (md->argintreguse > rd->argintreguse)
1977                                                         rd->argintreguse = md->argintreguse;
1978                                                 if (md->argfltreguse > rd->argfltreguse)
1979                                                         rd->argfltreguse = md->argfltreguse;
1980
1981                                                 REQUIRE(i);
1982
1983                                                 copy = curstack;
1984                                                 for (i-- ; i >= 0; i--) {
1985 #if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
1986                                                 /* If we pass float arguments in integer argument registers, we
1987                                                  * are not allowed to precolor them here. Floats have to be moved
1988                                                  * to this regs explicitly in codegen().
1989                                                  * Only arguments that are passed by stack anyway can be precolored
1990                                                  * (michi 2005/07/24) */
1991                                                         if (!(copy->flags & SAVEDVAR) &&
1992                                                            (!IS_FLT_DBL_TYPE(copy->type) || md->params[i].inmemory)) {
1993 #else
1994                                                         if (!(copy->flags & SAVEDVAR)) {
1995 #endif
1996                                                                 copy->varkind = ARGVAR;
1997                                                                 copy->varnum = i;
1998
1999 #if defined(ENABLE_INTRP)
2000                                                                 if (!opt_intrp) {
2001 #endif
2002                                                                         if (md->params[i].inmemory) {
2003                                                                                 copy->flags = INMEMORY;
2004                                                                                 copy->regoff = md->params[i].regoff;
2005                                                                         } else {
2006                                                                                 copy->flags = 0;
2007                                                                                 if (IS_FLT_DBL_TYPE(copy->type))
2008 #if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
2009                                                                                         assert(0); /* XXX is this assert ok? */
2010 #else
2011                                                                                 copy->regoff =
2012                                                                                         rd->argfltregs[md->params[i].regoff];
2013 #endif
2014                                                                                 else {
2015 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2016                                                                                         if (IS_2_WORD_TYPE(copy->type))
2017                                                                                                 copy->regoff = PACK_REGS(
2018                                                                                                                                                  rd->argintregs[GET_LOW_REG(md->params[i].regoff)],
2019                                                                                                                                                  rd->argintregs[GET_HIGH_REG(md->params[i].regoff)]);
2020                                                                                         else
2021 #endif
2022                                                                                                 copy->regoff =
2023                                                                                                         rd->argintregs[md->params[i].regoff];
2024                                                                                 }
2025                                                                         }
2026 #if defined(ENABLE_INTRP)
2027                                                                 }
2028 #endif
2029                                                         }
2030                                                         copy = copy->prev;
2031                                                 }
2032
2033                                                 while (copy) {
2034                                                         copy->flags |= SAVEDVAR;
2035                                                         copy = copy->prev;
2036                                                 }
2037
2038                                                 i = md->paramcount;
2039                                                 POPMANY(i);
2040                                                 if (md->returntype.type != TYPE_VOID)
2041                                                         OP0_1(md->returntype.type);
2042                                                 break;
2043
2044                                         case ICMD_INLINE_START:
2045                                         case ICMD_INLINE_END:
2046                                                 SETDST;
2047                                                 break;
2048
2049                                         case ICMD_MULTIANEWARRAY:
2050                                                 if (rd->argintreguse < 3)
2051                                                         rd->argintreguse = 3;
2052
2053                                                 i = iptr->op1;
2054
2055                                                 REQUIRE(i);
2056 #if defined(SPECIALMEMUSE)
2057 # if defined(__DARWIN__)
2058                                                 if (rd->memuse < (i + INT_ARG_CNT + LA_WORD_SIZE))
2059                                                         rd->memuse = i + LA_WORD_SIZE + INT_ARG_CNT;
2060 # else
2061                                                 if (rd->memuse < (i + LA_WORD_SIZE + 3))
2062                                                         rd->memuse = i + LA_WORD_SIZE + 3;
2063 # endif
2064 #else
2065 # if defined(__I386__)
2066                                                 if (rd->memuse < i + 3)
2067                                                         rd->memuse = i + 3; /* n integer args spilled on stack */
2068 # else
2069                                                 if (rd->memuse < i)
2070                                                         rd->memuse = i; /* n integer args spilled on stack */
2071 # endif /* defined(__I386__) */
2072 #endif
2073                                                 copy = curstack;
2074                                                 while (--i >= 0) {
2075                                                         /* check INT type here? Currently typecheck does this. */
2076                                                         if (!(copy->flags & SAVEDVAR)) {
2077                                                                 copy->varkind = ARGVAR;
2078                                                                 copy->varnum = i + INT_ARG_CNT;
2079                                                                 copy->flags |= INMEMORY;
2080 #if defined(SPECIALMEMUSE)
2081 # if defined(__DARWIN__)
2082                                                                 copy->regoff = i + LA_WORD_SIZE + INT_ARG_CNT;
2083 # else
2084                                                                 copy->regoff = i + LA_WORD_SIZE + 3;
2085 # endif
2086 #else
2087 # if defined(__I386__)
2088                                                                 copy->regoff = i + 3;
2089 # else
2090                                                                 copy->regoff = i;
2091 # endif /* defined(__I386__) */
2092 #endif /* defined(SPECIALMEMUSE) */
2093                                                         }
2094                                                         copy = copy->prev;
2095                                                 }
2096                                                 while (copy) {
2097                                                         copy->flags |= SAVEDVAR;
2098                                                         copy = copy->prev;
2099                                                 }
2100                                                 i = iptr->op1;
2101                                                 POPMANY(i);
2102                                                 OP0_1(TYPE_ADR);
2103                                                 break;
2104
2105                                         case ICMD_CLEAR_ARGREN:
2106                                                 for (i = iptr->op1; i < cd->maxlocals; i++)
2107                                                         argren[i] = i;
2108                                                 iptr->opc = opcode = ICMD_NOP;
2109                                                 SETDST;
2110                                                 break;
2111                                                 
2112                                         case ICMD_READONLY_ARG:
2113                                         case ICMD_READONLY_ARG+1:
2114                                         case ICMD_READONLY_ARG+2:
2115                                         case ICMD_READONLY_ARG+3:
2116                                         case ICMD_READONLY_ARG+4:
2117
2118                                                 REQUIRE_1;
2119                                                 if (curstack->varkind == LOCALVAR) {
2120                                                         i = curstack->varnum;
2121                                                         argren[iptr->op1] = i;
2122                                                         iptr->op1 = i;
2123                                                 }
2124                                                 opcode = iptr->opc = opcode - ICMD_READONLY_ARG + ICMD_ISTORE;
2125                                                 goto icmd_store;
2126
2127                                                 break;
2128
2129                                         default:
2130                                                 *exceptionptr =
2131                                                         new_exception_message(string_java_lang_InternalError,
2132                                                                                                   "Unknown ICMD");
2133                                                 return NULL;
2134                                         } /* switch */
2135
2136                                         CHECKOVERFLOW;
2137                                         iptr++;
2138                                 } /* while instructions */
2139
2140                                 bptr->outstack = curstack;
2141                                 bptr->outdepth = stackdepth;
2142                                 BBEND(curstack, i);
2143                         } /* if */
2144                         else
2145                                 superblockend = true;
2146                         bptr++;
2147                 } /* while blocks */
2148         } while (repeat && !deadcode);
2149
2150 #if defined(STATISTICS)
2151         if (opt_stat) {
2152                 if (m->basicblockcount > count_max_basic_blocks)
2153                         count_max_basic_blocks = m->basicblockcount;
2154                 count_basic_blocks += m->basicblockcount;
2155                 if (m->instructioncount > count_max_javainstr)                  count_max_javainstr = m->instructioncount;
2156                 count_javainstr += m->instructioncount;
2157                 if (m->stackcount > count_upper_bound_new_stack)
2158                         count_upper_bound_new_stack = m->stackcount;
2159                 if ((new - m->stack) > count_max_new_stack)
2160                         count_max_new_stack = (new - m->stack);
2161
2162                 b_count = m->basicblockcount;
2163                 bptr = m->basicblocks;
2164                 while (--b_count >= 0) {
2165                         if (bptr->flags > BBREACHED) {
2166                                 if (bptr->indepth >= 10)
2167                                         count_block_stack[10]++;
2168                                 else
2169                                         count_block_stack[bptr->indepth]++;
2170                                 len = bptr->icount;
2171                                 if (len < 10) 
2172                                         count_block_size_distribution[len]++;
2173                                 else if (len <= 12)
2174                                         count_block_size_distribution[10]++;
2175                                 else if (len <= 14)
2176                                         count_block_size_distribution[11]++;
2177                                 else if (len <= 16)
2178                                         count_block_size_distribution[12]++;
2179                                 else if (len <= 18)
2180                                         count_block_size_distribution[13]++;
2181                                 else if (len <= 20)
2182                                         count_block_size_distribution[14]++;
2183                                 else if (len <= 25)
2184                                         count_block_size_distribution[15]++;
2185                                 else if (len <= 30)
2186                                         count_block_size_distribution[16]++;
2187                                 else
2188                                         count_block_size_distribution[17]++;
2189                         }
2190                         bptr++;
2191                 }
2192
2193                 if (loops == 1)
2194                         count_analyse_iterations[0]++;
2195                 else if (loops == 2)
2196                         count_analyse_iterations[1]++;
2197                 else if (loops == 3)
2198                         count_analyse_iterations[2]++;
2199                 else if (loops == 4)
2200                         count_analyse_iterations[3]++;
2201                 else
2202                         count_analyse_iterations[4]++;
2203
2204                 if (m->basicblockcount <= 5)
2205                         count_method_bb_distribution[0]++;
2206                 else if (m->basicblockcount <= 10)
2207                         count_method_bb_distribution[1]++;
2208                 else if (m->basicblockcount <= 15)
2209                         count_method_bb_distribution[2]++;
2210                 else if (m->basicblockcount <= 20)
2211                         count_method_bb_distribution[3]++;
2212                 else if (m->basicblockcount <= 30)
2213                         count_method_bb_distribution[4]++;
2214                 else if (m->basicblockcount <= 40)
2215                         count_method_bb_distribution[5]++;
2216                 else if (m->basicblockcount <= 50)
2217                         count_method_bb_distribution[6]++;
2218                 else if (m->basicblockcount <= 75)
2219                         count_method_bb_distribution[7]++;
2220                 else
2221                         count_method_bb_distribution[8]++;
2222         }
2223 #endif
2224
2225         /* just return methodinfo* to signal everything was ok */
2226
2227         return m;
2228 }
2229
2230
2231 /**********************************************************************/
2232 /* DEBUGGING HELPERS                                                  */
2233 /**********************************************************************/
2234
2235 void icmd_print_stack(codegendata *cd, stackptr s)
2236 {
2237         int i, j;
2238         stackptr t;
2239
2240         i = cd->maxstack;
2241         t = s;
2242         
2243         while (t) {
2244                 i--;
2245                 t = t->prev;
2246         }
2247         j = cd->maxstack - i;
2248         while (--i >= 0)
2249                 printf("    ");
2250
2251         while (s) {
2252                 j--;
2253                 if (s->flags & SAVEDVAR)
2254                         switch (s->varkind) {
2255                         case TEMPVAR:
2256                                 if (s->flags & INMEMORY)
2257                                         printf(" M%02d", s->regoff);
2258 #ifdef HAS_ADDRESS_REGISTER_FILE
2259                                 else if (s->type == TYPE_ADR)
2260                                         printf(" R%02d", s->regoff);
2261 #endif
2262                                 else if (IS_FLT_DBL_TYPE(s->type))
2263                                         printf(" F%02d", s->regoff);
2264                                 else {
2265 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2266                                         if (IS_2_WORD_TYPE(s->type))
2267                                                 printf(" %3s/%3s", regs[GET_LOW_REG(s->regoff)],
2268                             regs[GET_HIGH_REG(s->regoff)]);
2269                                         else
2270 #endif
2271 #if defined(ENABLE_INTRP)
2272                                                 printf(" %3d", s->regoff);
2273 #else
2274                                                 printf(" %3s", regs[s->regoff]);
2275 #endif
2276                                 }
2277                                 break;
2278                         case STACKVAR:
2279                                 printf(" I%02d", s->varnum);
2280                                 break;
2281                         case LOCALVAR:
2282                                 printf(" L%02d", s->varnum);
2283                                 break;
2284                         case ARGVAR:
2285                                 if (s->varnum == -1) {
2286                                         /* Return Value                                  */
2287                                         /* varkind ARGVAR "misused for this special case */
2288                                         printf("  RA");
2289                                 } else /* "normal" Argvar */
2290                                         printf(" A%02d", s->varnum);
2291 #ifdef INVOKE_NEW_DEBUG
2292                                 if (s->flags & INMEMORY)
2293                                         printf("(M%i)", s->regoff);
2294                                 else
2295                                         printf("(R%i)", s->regoff);
2296 #endif
2297                                 break;
2298                         default:
2299                                 printf(" !%02d", j);
2300                         }
2301                 else
2302                         switch (s->varkind) {
2303                         case TEMPVAR:
2304                                 if (s->flags & INMEMORY)
2305                                         printf(" m%02d", s->regoff);
2306 #ifdef HAS_ADDRESS_REGISTER_FILE
2307                                 else if (s->type == TYPE_ADR)
2308                                         printf(" r%02d", s->regoff);
2309 #endif
2310                                 else if (IS_FLT_DBL_TYPE(s->type))
2311                                         printf(" f%02d", s->regoff);
2312                                 else {
2313 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2314                                         if (IS_2_WORD_TYPE(s->type))
2315                                                 printf(" %3s/%3s", regs[GET_LOW_REG(s->regoff)],
2316                             regs[GET_HIGH_REG(s->regoff)]);
2317                                         else
2318 #endif
2319 #if defined(ENABLE_INTRP)
2320                                                 printf(" %3d", s->regoff);
2321 #else
2322                                                 printf(" %3s", regs[s->regoff]);
2323 #endif
2324                                 }
2325                                 break;
2326                         case STACKVAR:
2327                                 printf(" i%02d", s->varnum);
2328                                 break;
2329                         case LOCALVAR:
2330                                 printf(" l%02d", s->varnum);
2331                                 break;
2332                         case ARGVAR:
2333                                 if (s->varnum == -1) {
2334                                         /* Return Value                                  */
2335                                         /* varkind ARGVAR "misused for this special case */
2336                                         printf("  ra");
2337                                 } else /* "normal" Argvar */
2338                                 printf(" a%02d", s->varnum);
2339 #ifdef INVOKE_NEW_DEBUG
2340                                 if (s->flags & INMEMORY)
2341                                         printf("(M%i)", s->regoff);
2342                                 else
2343                                         printf("(R%i)", s->regoff);
2344 #endif
2345                                 break;
2346                         default:
2347                                 printf(" ?%02d", j);
2348                         }
2349                 s = s->prev;
2350         }
2351 }
2352
2353
2354 #if 0
2355 static void print_reg(stackptr s) {
2356         if (s) {
2357                 if (s->flags & SAVEDVAR)
2358                         switch (s->varkind) {
2359                         case TEMPVAR:
2360                                 if (s->flags & INMEMORY)
2361                                         printf(" tm%02d", s->regoff);
2362                                 else
2363                                         printf(" tr%02d", s->regoff);
2364                                 break;
2365                         case STACKVAR:
2366                                 printf(" s %02d", s->varnum);
2367                                 break;
2368                         case LOCALVAR:
2369                                 printf(" l %02d", s->varnum);
2370                                 break;
2371                         case ARGVAR:
2372                                 printf(" a %02d", s->varnum);
2373                                 break;
2374                         default:
2375                                 printf(" ! %02d", s->varnum);
2376                         }
2377                 else
2378                         switch (s->varkind) {
2379                         case TEMPVAR:
2380                                 if (s->flags & INMEMORY)
2381                                         printf(" Tm%02d", s->regoff);
2382                                 else
2383                                         printf(" Tr%02d", s->regoff);
2384                                 break;
2385                         case STACKVAR:
2386                                 printf(" S %02d", s->varnum);
2387                                 break;
2388                         case LOCALVAR:
2389                                 printf(" L %02d", s->varnum);
2390                                 break;
2391                         case ARGVAR:
2392                                 printf(" A %02d", s->varnum);
2393                                 break;
2394                         default:
2395                                 printf(" ? %02d", s->varnum);
2396                         }
2397         }
2398         else
2399                 printf("     ");
2400                 
2401 }
2402 #endif
2403
2404
2405 static char *jit_type[] = {
2406         "int",
2407         "lng",
2408         "flt",
2409         "dbl",
2410         "adr"
2411 };
2412
2413
2414 /* show_icmd_method ************************************************************
2415
2416    XXX
2417
2418 *******************************************************************************/
2419
2420 void show_icmd_method(methodinfo *m, codegendata *cd, registerdata *rd)
2421 {
2422         basicblock     *bptr;
2423         exceptiontable *ex;
2424         s4              i, j;
2425         u1             *u1ptr;
2426
2427 #if defined(USE_THREADS)
2428         /* We need to enter a lock here, since the binutils disassembler is not   */
2429         /* reentrant-able and we could not read functions printed at the same     */
2430         /* time.                                                                  */
2431
2432         builtin_monitorenter(&show_icmd_lock);
2433 #endif
2434
2435         printf("\n");
2436         utf_fprint_classname(stdout, m->class->name);
2437         printf(".");
2438         utf_fprint(stdout, m->name);
2439         utf_fprint(stdout, m->descriptor);
2440         printf("\n\nMax locals: %d\n", (int) cd->maxlocals);
2441         printf("Max stack:  %d\n", (int) cd->maxstack);
2442         printf("Line number table length: %d\n", m->linenumbercount);
2443
2444         printf("Exceptions (Number: %d):\n", cd->exceptiontablelength);
2445         for (ex = cd->exceptiontable; ex != NULL; ex = ex->down) {
2446                 printf("    L%03d ... ", ex->start->debug_nr );
2447                 printf("L%03d  = ", ex->end->debug_nr);
2448                 printf("L%03d", ex->handler->debug_nr);
2449                 printf("  (catchtype: ");
2450                 if (ex->catchtype.any)
2451                         if (IS_CLASSREF(ex->catchtype))
2452                                 utf_display_classname(ex->catchtype.ref->name);
2453                         else
2454                                 utf_display_classname(ex->catchtype.cls->name);
2455                 else
2456                         printf("ANY");
2457                 printf(")\n");
2458         }
2459         
2460         printf("Local Table:\n");
2461         for (i = 0; i < cd->maxlocals; i++) {
2462                 printf("   %3d: ", i);
2463                 for (j = TYPE_INT; j <= TYPE_ADR; j++) {
2464 #if defined(ENABLE_INTRP)
2465                         if (!opt_intrp) {
2466 #endif
2467                                 if (rd->locals[i][j].type >= 0) {
2468                                         printf("   (%s) ", jit_type[j]);
2469                                         if (rd->locals[i][j].flags & INMEMORY)
2470                                                 printf("m%2d", rd->locals[i][j].regoff);
2471 #ifdef HAS_ADDRESS_REGISTER_FILE
2472                                         else if (j == TYPE_ADR)
2473                                                 printf("r%02d", rd->locals[i][j].regoff);
2474 #endif
2475                                         else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2476                                                 printf("f%02d", rd->locals[i][j].regoff);
2477                                         else {
2478 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2479                                                 if (IS_2_WORD_TYPE(j))
2480                                                         printf(" %3s/%3s",
2481                                                                    regs[GET_LOW_REG(rd->locals[i][j].regoff)],
2482                                                                    regs[GET_HIGH_REG(rd->locals[i][j].regoff)]);
2483                                                 else
2484 #endif
2485                                                         printf("%3s", regs[rd->locals[i][j].regoff]);
2486                                         }
2487                                 }
2488 #if defined(ENABLE_INTRP)
2489                         }
2490 #endif
2491                 }
2492                 printf("\n");
2493         }
2494         printf("\n");
2495
2496 #ifdef LSRA
2497         if (!opt_lsra) {
2498 #endif
2499 #if defined(ENABLE_INTRP)
2500                 if (!opt_intrp) {
2501 #endif
2502         printf("Interface Table:\n");
2503         for (i = 0; i < cd->maxstack; i++) {
2504                 if ((rd->interfaces[i][0].type >= 0) ||
2505                         (rd->interfaces[i][1].type >= 0) ||
2506                     (rd->interfaces[i][2].type >= 0) ||
2507                         (rd->interfaces[i][3].type >= 0) ||
2508                     (rd->interfaces[i][4].type >= 0)) {
2509                         printf("   %3d: ", i);
2510                         for (j = TYPE_INT; j <= TYPE_ADR; j++)
2511                                 if (rd->interfaces[i][j].type >= 0) {
2512                                         printf("   (%s) ", jit_type[j]);
2513                                         if (rd->interfaces[i][j].flags & SAVEDVAR) {
2514                                                 if (rd->interfaces[i][j].flags & INMEMORY)
2515                                                         printf("M%2d", rd->interfaces[i][j].regoff);
2516 #ifdef HAS_ADDRESS_REGISTER_FILE
2517                                                 else if (j == TYPE_ADR)
2518                                                         printf("R%02d", rd->interfaces[i][j].regoff);
2519 #endif
2520                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2521                                                         printf("F%02d", rd->interfaces[i][j].regoff);
2522                                                 else {
2523 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2524                                                         if (IS_2_WORD_TYPE(j))
2525                                                                 printf(" %3s/%3s",
2526                              regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
2527                              regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
2528                                                         else
2529 #endif
2530                                                                 printf("%3s",regs[rd->interfaces[i][j].regoff]);
2531                                                 }
2532                                         }
2533                                         else {
2534                                                 if (rd->interfaces[i][j].flags & INMEMORY)
2535                                                         printf("m%2d", rd->interfaces[i][j].regoff);
2536 #ifdef HAS_ADDRESS_REGISTER_FILE
2537                                                 else if (j == TYPE_ADR)
2538                                                         printf("r%02d", rd->interfaces[i][j].regoff);
2539 #endif
2540                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
2541                                                         printf("f%02d", rd->interfaces[i][j].regoff);
2542                                                 else {
2543 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
2544                                                         if (IS_2_WORD_TYPE(j))
2545                                                                 printf(" %3s/%3s",
2546                              regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
2547                                                          regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
2548                                                         else
2549 #endif
2550                                                                 printf("%3s",regs[rd->interfaces[i][j].regoff]);
2551                                                 }
2552                                         }
2553                                 }
2554                         printf("\n");
2555                 }
2556         }
2557         printf("\n");
2558
2559 #if defined(ENABLE_INTRP)
2560                 }
2561 #endif
2562 #ifdef LSRA
2563         }
2564 #endif
2565
2566         /* show code before first basic block */
2567
2568         if (opt_showdisassemble) {
2569                 u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen);
2570
2571                 for (; u1ptr < (u1 *) ((ptrint) m->mcode + cd->dseglen + m->basicblocks[0].mpc);)
2572                         u1ptr = disassinstr(u1ptr);
2573
2574                 printf("\n");
2575         }
2576
2577         /* show code of all basic blocks */
2578
2579         for (bptr = m->basicblocks; bptr != NULL; bptr = bptr->next) {
2580                 show_icmd_block(m, cd, bptr);
2581         }
2582
2583         /* show stubs code */
2584
2585         if (opt_showdisassemble && opt_showexceptionstubs) {
2586                 printf("\nException stubs code:\n");
2587                 printf("Length: %d\n\n", (s4) (m->mcodelength -
2588                                                                            ((ptrint) cd->dseglen +
2589                                                                                 m->basicblocks[m->basicblockcount].mpc)));
2590
2591                 u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen +
2592                                                 m->basicblocks[m->basicblockcount].mpc);
2593
2594                 for (; (ptrint) u1ptr < ((ptrint) m->mcode + m->mcodelength);)
2595                         u1ptr = disassinstr(u1ptr);
2596
2597                 printf("\n");
2598         }
2599
2600 #if defined(USE_THREADS)
2601         builtin_monitorexit(&show_icmd_lock);
2602 #endif
2603 }
2604
2605
2606 void show_icmd_block(methodinfo *m, codegendata *cd, basicblock *bptr)
2607 {
2608         s4           i, j;
2609         bool         deadcode;
2610         instruction *iptr;
2611         u1          *u1ptr;
2612
2613         if (bptr->flags != BBDELETED) {
2614                 deadcode = bptr->flags <= BBREACHED;
2615                 printf("[");
2616                 if (deadcode)
2617                         for (j = cd->maxstack; j > 0; j--)
2618                                 printf(" ?  ");
2619                 else
2620                         icmd_print_stack(cd, bptr->instack);
2621                 printf("] L%03d(%d - %d) flags=%d:\n", bptr->debug_nr, bptr->icount, bptr->pre_count,bptr->flags);
2622                 iptr = bptr->iinstr;
2623
2624                 for (i = 0; i < bptr->icount; i++, iptr++) {
2625                         printf("[");
2626                         if (deadcode) {
2627                                 for (j = cd->maxstack; j > 0; j--)
2628                                         printf(" ?  ");
2629                         }
2630                         else
2631                                 icmd_print_stack(cd, iptr->dst);
2632                         printf("] %5d (line: %5d)  ", i, iptr->line);
2633
2634 #ifdef LSRA_EDX
2635                         if (icmd_uses_tmp[iptr->opc][0])
2636                                 printf("  ---");
2637                         else
2638                                 printf("  EAX");
2639                         if (icmd_uses_tmp[iptr->opc][1])
2640                                 printf(" ---");
2641                         else
2642                                 printf(" ECX");
2643                         if (icmd_uses_tmp[iptr->opc][2])
2644                                 printf(" ---  ");
2645                         else
2646                                 printf(" EDX  ");
2647 #endif
2648
2649                         show_icmd(iptr, deadcode);
2650                         printf("\n");
2651                 }
2652
2653                 if (opt_showdisassemble && (!deadcode)) {
2654                         printf("\n");
2655                         u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen + bptr->mpc);
2656
2657                         if (bptr->next != NULL) {
2658                                 for (; u1ptr < (u1 *) ((ptrint) m->mcode + cd->dseglen + bptr->next->mpc);)
2659                                         u1ptr = disassinstr(u1ptr);
2660
2661                         } else {
2662                                 for (; u1ptr < (u1 *) ((ptrint) m->mcode + m->mcodelength);)
2663                                         u1ptr = disassinstr(u1ptr); 
2664                         }
2665                         printf("\n");
2666                 }
2667         }
2668 }
2669
2670
2671 void show_icmd(instruction *iptr, bool deadcode)
2672 {
2673         int j;
2674         s4  *s4ptr;
2675         void **tptr = NULL;
2676         
2677         printf("%s", icmd_names[iptr->opc]);
2678
2679         switch (iptr->opc) {
2680         case ICMD_IADDCONST:
2681         case ICMD_ISUBCONST:
2682         case ICMD_IMULCONST:
2683         case ICMD_IMULPOW2:
2684         case ICMD_IDIVPOW2:
2685         case ICMD_IREMPOW2:
2686         case ICMD_IANDCONST:
2687         case ICMD_IORCONST:
2688         case ICMD_IXORCONST:
2689         case ICMD_ISHLCONST:
2690         case ICMD_ISHRCONST:
2691         case ICMD_IUSHRCONST:
2692         case ICMD_LSHLCONST:
2693         case ICMD_LSHRCONST:
2694         case ICMD_LUSHRCONST:
2695         case ICMD_ICONST:
2696         case ICMD_ELSE_ICONST:
2697         case ICMD_IASTORECONST:
2698         case ICMD_BASTORECONST:
2699         case ICMD_CASTORECONST:
2700         case ICMD_SASTORECONST:
2701                 printf(" %d (0x%08x)", iptr->val.i, iptr->val.i);
2702                 break;
2703
2704         case ICMD_IFEQ_ICONST:
2705         case ICMD_IFNE_ICONST:
2706         case ICMD_IFLT_ICONST:
2707         case ICMD_IFGE_ICONST:
2708         case ICMD_IFGT_ICONST:
2709         case ICMD_IFLE_ICONST:
2710                 printf("(%d) %d", iptr[1].op1, iptr->val.i);
2711                 break;
2712
2713         case ICMD_LADDCONST:
2714         case ICMD_LSUBCONST:
2715         case ICMD_LMULCONST:
2716         case ICMD_LMULPOW2:
2717         case ICMD_LDIVPOW2:
2718         case ICMD_LREMPOW2:
2719         case ICMD_LANDCONST:
2720         case ICMD_LORCONST:
2721         case ICMD_LXORCONST:
2722         case ICMD_LCONST:
2723         case ICMD_LASTORECONST:
2724 #if SIZEOF_VOID_P == 4
2725                 printf(" %lld (0x%016llx)", iptr->val.l, iptr->val.l);
2726 #else
2727                 printf(" %ld (0x%016lx)", iptr->val.l, iptr->val.l);
2728 #endif
2729                 break;
2730
2731         case ICMD_FCONST:
2732                 printf(" %f (0x%08x)", iptr->val.f, iptr->val.i);
2733                 break;
2734
2735         case ICMD_DCONST:
2736 #if SIZEOF_VOID_P == 4
2737                 printf(" %g (0x%016llx)", iptr->val.d, iptr->val.l);
2738 #else
2739                 printf(" %g (0x%016lx)", iptr->val.d, iptr->val.l);
2740 #endif
2741                 break;
2742
2743         case ICMD_ACONST:
2744         case ICMD_AASTORECONST:
2745                 printf(" %p", iptr->val.a);
2746
2747                 if (iptr->val.a) {
2748                         /* check if this is a constant string */
2749
2750                         if (iptr->op1 == 0) {
2751                                 printf(", String = \"");
2752                                 utf_display(javastring_toutf(iptr->val.a, false));
2753                                 printf("\"");
2754
2755                         } else {
2756                                 /* it is a BUILTIN argument */
2757
2758                                 printf(", Class = \"");
2759
2760                                 /* is it resolved? */
2761
2762                                 if (iptr[1].target == NULL) {
2763                                         builtintable_entry *bte = iptr[1].val.a;
2764
2765                                         /* NEW gets a classinfo* as argument */
2766
2767                                         if (bte->fp == BUILTIN_new) {
2768                                                 utf_display(((classinfo *) iptr->val.a)->name);
2769
2770                                         } else {
2771                                                 utf_display(((vftbl_t *) iptr->val.a)->class->name);
2772                                         }
2773
2774                                 } else {
2775                                         /* iptr->target is a constant_classref */
2776
2777                                         utf_display(((constant_classref *) iptr->val.a)->name);
2778                                 }
2779                                 printf("\"");
2780                         }
2781                 }
2782                 break;
2783
2784         case ICMD_GETFIELD:
2785         case ICMD_PUTFIELD:
2786                 if (iptr->val.a)         
2787                         printf(" %d, ", ((fieldinfo *) iptr->val.a)->offset);
2788                 else     
2789                         printf(" (NOT RESOLVED), ");
2790                 utf_display_classname(((unresolved_field *) iptr->target)->fieldref->classref->name);
2791                 printf(".");
2792                 utf_display(((unresolved_field *) iptr->target)->fieldref->name);
2793                 printf(" (type ");
2794                 utf_display(((unresolved_field *) iptr->target)->fieldref->descriptor);
2795                 printf(")"); 
2796                 break;
2797
2798         case ICMD_PUTSTATIC:
2799         case ICMD_GETSTATIC:
2800                 if (iptr->val.a) {
2801                         if (!((fieldinfo *) iptr->val.a)->class->initialized)
2802                                 printf(" (NOT INITIALIZED) ");
2803                         else
2804                                 printf(" ");
2805                 } else
2806                         printf(" (NOT RESOLVED) ");
2807                 utf_display_classname(((unresolved_field *) iptr->target)->fieldref->classref->name);
2808                 printf(".");
2809                 utf_display(((unresolved_field *) iptr->target)->fieldref->name);
2810                 printf(" (type ");
2811                 utf_display(((unresolved_field *) iptr->target)->fieldref->descriptor);
2812                 printf(")");
2813                 break;
2814
2815         case ICMD_PUTSTATICCONST:
2816         case ICMD_PUTFIELDCONST:
2817                 switch (iptr[1].op1) {
2818                 case TYPE_INT:
2819                         printf(" %d,", iptr->val.i);
2820                         break;
2821                 case TYPE_LNG:
2822 #if SIZEOF_VOID_P == 4
2823                         printf(" %lld,", iptr->val.l);
2824 #else
2825                         printf(" %ld,", iptr->val.l);
2826 #endif
2827                         break;
2828                 case TYPE_ADR:
2829                         printf(" %p,", iptr->val.a);
2830                         break;
2831                 case TYPE_FLT:
2832                         printf(" %g,", iptr->val.f);
2833                         break;
2834                 case TYPE_DBL:
2835                         printf(" %g,", iptr->val.d);
2836                         break;
2837                 }
2838                 if (iptr->opc == ICMD_PUTFIELDCONST)     
2839                         printf(" NOT RESOLVED,");        
2840                 printf(" ");     
2841                 utf_display_classname(((unresolved_field *) iptr[1].target)->fieldref->classref->name);          
2842                 printf(".");     
2843                 utf_display(((unresolved_field *) iptr[1].target)->fieldref->name);      
2844                 printf(" (type ");       
2845                 utf_display(((unresolved_field *) iptr[1].target)->fieldref->descriptor);        
2846                 printf(")");     
2847                 break;
2848
2849         case ICMD_IINC:
2850                 printf(" %d + %d", iptr->op1, iptr->val.i);
2851                 break;
2852
2853         case ICMD_IASTORE:
2854         case ICMD_SASTORE:
2855         case ICMD_BASTORE:
2856         case ICMD_CASTORE:
2857         case ICMD_LASTORE:
2858         case ICMD_DASTORE:
2859         case ICMD_FASTORE:
2860         case ICMD_AASTORE:
2861
2862         case ICMD_IALOAD:
2863         case ICMD_SALOAD:
2864         case ICMD_BALOAD:
2865         case ICMD_CALOAD:
2866         case ICMD_LALOAD:
2867         case ICMD_DALOAD:
2868         case ICMD_FALOAD:
2869         case ICMD_AALOAD:
2870                 if (iptr->op1 != 0)
2871                         printf("(opt.)");
2872                 break;
2873
2874         case ICMD_RET:
2875         case ICMD_ILOAD:
2876         case ICMD_LLOAD:
2877         case ICMD_FLOAD:
2878         case ICMD_DLOAD:
2879         case ICMD_ALOAD:
2880         case ICMD_ISTORE:
2881         case ICMD_LSTORE:
2882         case ICMD_FSTORE:
2883         case ICMD_DSTORE:
2884         case ICMD_ASTORE:
2885                 printf(" %d", iptr->op1);
2886                 break;
2887
2888         case ICMD_NEW:
2889                 printf(" ");
2890                 utf_display_classname(((classinfo *) iptr->val.a)->name);
2891                 break;
2892
2893         case ICMD_NEWARRAY:
2894                 switch (iptr->op1) {
2895                 case 4:
2896                         printf(" boolean");
2897                         break;
2898                 case 5:
2899                         printf(" char");
2900                         break;
2901                 case 6:
2902                         printf(" float");
2903                         break;
2904                 case 7:
2905                         printf(" double");
2906                         break;
2907                 case 8:
2908                         printf(" byte");
2909                         break;
2910                 case 9:
2911                         printf(" short");
2912                         break;
2913                 case 10:
2914                         printf(" int");
2915                         break;
2916                 case 11:
2917                         printf(" long");
2918                         break;
2919                 }
2920                 break;
2921
2922         case ICMD_ANEWARRAY:
2923                 if (iptr->op1) {
2924                         printf(" ");
2925                         utf_display_classname(((classinfo *) iptr->val.a)->name);
2926                 }
2927                 break;
2928
2929         case ICMD_MULTIANEWARRAY:
2930                 if (iptr->target) {
2931                         printf(" (NOT RESOLVED) %d ",iptr->op1);
2932                         utf_display(((constant_classref *) iptr->val.a)->name);
2933                 } else {
2934                         printf(" %d ",iptr->op1);
2935                         utf_display_classname(((vftbl_t *) iptr->val.a)->class->name);
2936                 }
2937                 break;
2938
2939         case ICMD_CHECKCAST:
2940         case ICMD_INSTANCEOF:
2941                 {
2942                         classinfo *c = iptr->val.a;
2943                         if (c) {
2944                                 if (c->flags & ACC_INTERFACE)
2945                                         printf(" (INTERFACE) ");
2946                                 else
2947                                         printf(" (CLASS,%3d) ", c->vftbl->diffval);
2948                         } else {
2949                                 printf(" (NOT RESOLVED) ");
2950                         }
2951                         utf_display_classname(((constant_classref *) iptr->target)->name);
2952                 }
2953                 break;
2954
2955         case ICMD_ARRAYCHECKCAST:
2956                 if (iptr->op1) {
2957                         classinfo *c = ((vftbl_t *) iptr->target)->class;
2958                         if (c->flags & ACC_INTERFACE)
2959                                 printf(" (INTERFACE) ");
2960                         else
2961                                 printf(" (CLASS,%3d) ", c->vftbl->diffval);
2962                         utf_display_classname(c->name);
2963                 } else {
2964                         printf(" (NOT RESOLVED) ");
2965                         utf_display_classname(((constant_classref *) iptr->target)->name);
2966                 }
2967                 break;
2968
2969         case ICMD_INLINE_START:
2970                 printf(" ");
2971                 utf_display_classname(iptr->method->class->name);
2972                 printf(".");
2973                 utf_display_classname(iptr->method->name);
2974                 utf_display_classname(iptr->method->descriptor);
2975                 printf(", depth=%i", iptr->op1);
2976                 break;
2977         case ICMD_INLINE_END:
2978                 break;
2979
2980         case ICMD_BUILTIN:
2981                 printf(" %s", ((builtintable_entry *) iptr->val.a)->name);
2982                 break;
2983
2984         case ICMD_INVOKEVIRTUAL:
2985         case ICMD_INVOKESPECIAL:
2986         case ICMD_INVOKESTATIC:
2987         case ICMD_INVOKEINTERFACE:
2988                 if (!iptr->val.a)
2989                         printf(" (NOT RESOLVED) ");
2990                 else
2991                         printf(" ");
2992                 utf_display_classname(((unresolved_method *) iptr->target)->methodref->classref->name);
2993                 printf(".");
2994                 utf_display(((unresolved_method *) iptr->target)->methodref->name);
2995                 utf_display(((unresolved_method *) iptr->target)->methodref->descriptor);
2996                 break;
2997
2998         case ICMD_IFEQ:
2999         case ICMD_IFNE:
3000         case ICMD_IFLT:
3001         case ICMD_IFGE:
3002         case ICMD_IFGT:
3003         case ICMD_IFLE:
3004                 if (deadcode || !iptr->target)
3005                         printf("(%d) op1=%d", iptr->val.i, iptr->op1);
3006                 else
3007                         printf("(%d) L%03d", iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
3008                 break;
3009
3010         case ICMD_IF_LEQ:
3011         case ICMD_IF_LNE:
3012         case ICMD_IF_LLT:
3013         case ICMD_IF_LGE:
3014         case ICMD_IF_LGT:
3015         case ICMD_IF_LLE:
3016                 if (deadcode || !iptr->target)
3017 #if SIZEOF_VOID_P == 4
3018                         printf("(%lld) op1=%d", iptr->val.l, iptr->op1);
3019 #else
3020                         printf("(%ld) op1=%d", iptr->val.l, iptr->op1);
3021 #endif
3022                 else
3023 #if SIZEOF_VOID_P == 4
3024                         printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
3025 #else
3026                         printf("(%ld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
3027 #endif
3028                 break;
3029
3030         case ICMD_JSR:
3031         case ICMD_GOTO:
3032         case ICMD_IFNULL:
3033         case ICMD_IFNONNULL:
3034         case ICMD_IF_ICMPEQ:
3035         case ICMD_IF_ICMPNE:
3036         case ICMD_IF_ICMPLT:
3037         case ICMD_IF_ICMPGE:
3038         case ICMD_IF_ICMPGT:
3039         case ICMD_IF_ICMPLE:
3040         case ICMD_IF_LCMPEQ:
3041         case ICMD_IF_LCMPNE:
3042         case ICMD_IF_LCMPLT:
3043         case ICMD_IF_LCMPGE:
3044         case ICMD_IF_LCMPGT:
3045         case ICMD_IF_LCMPLE:
3046         case ICMD_IF_ACMPEQ:
3047         case ICMD_IF_ACMPNE:
3048                 if (deadcode || !iptr->target)
3049                         printf(" op1=%d", iptr->op1);
3050                 else
3051                         printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
3052                 break;
3053
3054         case ICMD_TABLESWITCH:
3055                 s4ptr = (s4*)iptr->val.a;
3056
3057                 if (deadcode || !iptr->target) {
3058                         printf(" %d;", *s4ptr);
3059                 }
3060                 else {
3061                         tptr = (void **) iptr->target;
3062                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr); 
3063                         tptr++;
3064                 }
3065
3066                 s4ptr++;         /* skip default */
3067                 j = *s4ptr++;                               /* low     */
3068                 j = *s4ptr++ - j;                           /* high    */
3069                 while (j >= 0) {
3070                         if (deadcode || !*tptr)
3071                                 printf(" %d", *s4ptr++);
3072                         else {
3073                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
3074                                 tptr++;
3075                         }
3076                         j--;
3077                 }
3078                 break;
3079
3080         case ICMD_LOOKUPSWITCH:
3081                 s4ptr = (s4*)iptr->val.a;
3082
3083                 if (deadcode || !iptr->target) {
3084                         printf(" %d;", *s4ptr);
3085                 }
3086                 else {
3087                         tptr = (void **) iptr->target;
3088                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
3089                         tptr++;
3090                 }
3091                 s4ptr++;                                         /* default */
3092                 j = *s4ptr++;                                    /* count   */
3093
3094                 while (--j >= 0) {
3095                         if (deadcode || !*tptr) {
3096                                 s4ptr++; /* skip value */
3097                                 printf(" %d",*s4ptr++);
3098                         }
3099                         else {
3100                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
3101                                 tptr++;
3102                         }
3103                 }
3104                 break;
3105         }
3106 }
3107
3108
3109 /*
3110  * These are local overrides for various environment variables in Emacs.
3111  * Please do not remove this and leave it at the end of the file, where
3112  * Emacs will automagically detect them.
3113  * ---------------------------------------------------------------------
3114  * Local variables:
3115  * mode: c
3116  * indent-tabs-mode: t
3117  * c-basic-offset: 4
3118  * tab-width: 4
3119  * End:
3120  */