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