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