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