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