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