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