* src/vm/jit/jit.h (ICMD_ELSE_ICONST): Removed.
[cacao.git] / src / vm / jit / show.c
1 /* src/vm/jit/show.c - showing the intermediate representation
2
3    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, 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., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Andreas Krall
28
29    Changes: Edwin Steiner
30             Christian Thalinger
31             Christian Ullrich
32
33    $Id$
34
35 */
36
37
38 #include "config.h"
39 #include "vm/types.h"
40
41 #include <assert.h>
42
43 #include "mm/memory.h"
44
45 #if defined(ENABLE_THREADS)
46 # include "threads/native/lock.h"
47 #else
48 # include "threads/none/lock.h"
49 #endif
50
51 #include "vm/global.h"
52 #include "vm/options.h"
53 #include "vm/builtin.h"
54 #include "vm/stringlocal.h"
55 #include "vm/jit/jit.h"
56 #include "vm/jit/show.h"
57 #include "vm/jit/disass.h"
58
59
60 /* global variables ***********************************************************/
61
62 #if defined(ENABLE_THREADS) && !defined(NDEBUG)
63 static java_objectheader *show_global_lock;
64 #endif
65
66
67 /* show_init *******************************************************************
68
69    Initialized the show subsystem (called by jit_init).
70
71 *******************************************************************************/
72
73 #if !defined(NDEBUG)
74 bool show_init(void)
75 {
76 #if defined(ENABLE_THREADS)
77         /* initialize the show lock */
78
79         show_global_lock = NEW(java_objectheader);
80
81         lock_init_object_lock(show_global_lock);
82 #endif
83
84         /* everything's ok */
85
86         return true;
87 }
88 #endif
89
90
91 /* show_print_stack ************************************************************
92
93    Print the stack representation starting with the given top stackptr.
94
95    NOTE: Currently this function may only be called after register allocation!
96
97 *******************************************************************************/
98
99 #if !defined(NDEBUG)
100 static void show_print_stack(codegendata *cd, stackptr s)
101 {
102         int i, j;
103         stackptr t;
104
105         i = cd->maxstack;
106         t = s;
107         
108         while (t) {
109                 i--;
110                 t = t->prev;
111         }
112         j = cd->maxstack - i;
113         while (--i >= 0)
114                 printf("    ");
115
116         while (s) {
117                 j--;
118                 if (s->flags & SAVEDVAR)
119                         switch (s->varkind) {
120                         case TEMPVAR:
121                                 if (s->flags & INMEMORY)
122                                         printf(" M%02d", s->regoff);
123 #ifdef HAS_ADDRESS_REGISTER_FILE
124                                 else if (s->type == TYPE_ADR)
125                                         printf(" R%02d", s->regoff);
126 #endif
127                                 else if (IS_FLT_DBL_TYPE(s->type))
128                                         printf(" F%02d", s->regoff);
129                                 else {
130 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
131                                         if (IS_2_WORD_TYPE(s->type)) {
132 # if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
133 #  if defined(ENABLE_INTRP)
134                                                 if (opt_intrp)
135                                                         printf(" %3d/%3d", GET_LOW_REG(s->regoff),
136                                                                    GET_HIGH_REG(s->regoff));
137                                                 else
138 #  endif
139                                                         printf(" %3s/%3s", regs[GET_LOW_REG(s->regoff)],
140                                                                    regs[GET_HIGH_REG(s->regoff)]);
141 # else
142                                                 printf(" %3d/%3d", GET_LOW_REG(s->regoff),
143                                                            GET_HIGH_REG(s->regoff));
144 # endif
145                                         } 
146                                         else 
147 #endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */
148                                                 {
149 #if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
150 # if defined(ENABLE_INTRP)
151                                                         if (opt_intrp)
152                                                                 printf(" %3d", s->regoff);
153                                                         else
154 # endif
155                                                                 printf(" %3s", regs[s->regoff]);
156 #else
157                                                         printf(" %3d", s->regoff);
158 #endif
159                                                 }
160                                 }
161                                 break;
162                         case STACKVAR:
163                                 printf(" I%02d", s->varnum);
164                                 break;
165                         case LOCALVAR:
166                                 printf(" L%02d", s->varnum);
167                                 break;
168                         case ARGVAR:
169                                 if (s->varnum == -1) {
170                                         /* Return Value                                  */
171                                         /* varkind ARGVAR "misused for this special case */
172                                         printf("  V0");
173                                 } 
174                                 else /* "normal" Argvar */
175                                         printf(" A%02d", s->varnum);
176                                 break;
177                         default:
178                                 printf(" !%02d", j);
179                         }
180                 else
181                         switch (s->varkind) {
182                         case TEMPVAR:
183                                 if (s->flags & INMEMORY)
184                                         printf(" m%02d", s->regoff);
185 #ifdef HAS_ADDRESS_REGISTER_FILE
186                                 else if (s->type == TYPE_ADR)
187                                         printf(" r%02d", s->regoff);
188 #endif
189                                 else if (IS_FLT_DBL_TYPE(s->type))
190                                         printf(" f%02d", s->regoff);
191                                 else {
192 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
193                                         if (IS_2_WORD_TYPE(s->type)) {
194 # if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
195 #  if defined(ENABLE_INTRP)
196                                                 if (opt_intrp)
197                                                         printf(" %3d/%3d", GET_LOW_REG(s->regoff),
198                                                                    GET_HIGH_REG(s->regoff));
199                                                 else
200 #  endif
201                                                         printf(" %3s/%3s", regs[GET_LOW_REG(s->regoff)],
202                                                                    regs[GET_HIGH_REG(s->regoff)]);
203 # else
204                                                 printf(" %3d/%3d", GET_LOW_REG(s->regoff),
205                                                            GET_HIGH_REG(s->regoff));
206 # endif
207                                         } 
208                                         else
209 #endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */
210                                                 {
211 #if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
212 # if defined(ENABLE_INTRP)
213                                                         if (opt_intrp)
214                                                                 printf(" %3d", s->regoff);
215                                                         else
216 # endif
217                                                                 printf(" %3s", regs[s->regoff]);
218 #else
219                                                         printf(" %3d", s->regoff);
220 #endif
221                                                 }
222                                 }
223                                 break;
224                         case STACKVAR:
225                                 printf(" i%02d", s->varnum);
226                                 break;
227                         case LOCALVAR:
228                                 printf(" l%02d", s->varnum);
229                                 break;
230                         case ARGVAR:
231                                 if (s->varnum == -1) {
232                                         /* Return Value                                  */
233                                         /* varkind ARGVAR "misused for this special case */
234                                         printf("  v0");
235                                 } 
236                                 else /* "normal" Argvar */
237                                 printf(" a%02d", s->varnum);
238                                 break;
239                         default:
240                                 printf(" ?%02d", j);
241                         }
242                 s = s->prev;
243         }
244 }
245 #endif /* !defined(NDEBUG) */
246
247
248 #if 0
249 static void print_reg(stackptr s) {
250         if (s) {
251                 if (s->flags & SAVEDVAR)
252                         switch (s->varkind) {
253                         case TEMPVAR:
254                                 if (s->flags & INMEMORY)
255                                         printf(" tm%02d", s->regoff);
256                                 else
257                                         printf(" tr%02d", s->regoff);
258                                 break;
259                         case STACKVAR:
260                                 printf(" s %02d", s->varnum);
261                                 break;
262                         case LOCALVAR:
263                                 printf(" l %02d", s->varnum);
264                                 break;
265                         case ARGVAR:
266                                 printf(" a %02d", s->varnum);
267                                 break;
268                         default:
269                                 printf(" ! %02d", s->varnum);
270                         }
271                 else
272                         switch (s->varkind) {
273                         case TEMPVAR:
274                                 if (s->flags & INMEMORY)
275                                         printf(" Tm%02d", s->regoff);
276                                 else
277                                         printf(" Tr%02d", s->regoff);
278                                 break;
279                         case STACKVAR:
280                                 printf(" S %02d", s->varnum);
281                                 break;
282                         case LOCALVAR:
283                                 printf(" L %02d", s->varnum);
284                                 break;
285                         case ARGVAR:
286                                 printf(" A %02d", s->varnum);
287                                 break;
288                         default:
289                                 printf(" ? %02d", s->varnum);
290                         }
291         }
292         else
293                 printf("     ");
294                 
295 }
296 #endif
297
298
299 #if !defined(NDEBUG)
300 static char *jit_type[] = {
301         "int",
302         "lng",
303         "flt",
304         "dbl",
305         "adr"
306 };
307 #endif
308
309
310 /* show_method *****************************************************************
311
312    Print the intermediate representation of a method.
313
314    NOTE: Currently this function may only be called after register allocation!
315
316 *******************************************************************************/
317
318 #if !defined(NDEBUG)
319 void new_show_method(jitdata *jd, int stage)
320 {
321         methodinfo     *m;
322         codeinfo       *code;
323         codegendata    *cd;
324         registerdata   *rd;
325         basicblock     *bptr;
326         exceptiontable *ex;
327         s4              i, j;
328         u1             *u1ptr;
329
330         /* get required compiler data */
331
332         m    = jd->m;
333         code = jd->code;
334         cd   = jd->cd;
335         rd   = jd->new_rd;
336
337         /* We need to enter a lock here, since the binutils disassembler
338            is not reentrant-able and we could not read functions printed
339            at the same time. */
340
341         LOCK_MONITOR_ENTER(show_global_lock);
342
343         printf("\n");
344
345         method_println(m);
346
347         printf("\n(NEW INSTRUCTION FORMAT)\n");
348         printf("\nBasic blocks: %d\n", jd->new_basicblockcount);
349         printf("Code length:  %d\n", (jd->new_basicblocks[jd->new_basicblockcount].mpc - 
350                                                                   jd->new_basicblocks[0].mpc));
351         printf("Data length:  %d\n", cd->dseglen);
352         printf("Max locals:   %d\n", cd->maxlocals);
353         printf("Max stack:    %d\n", cd->maxstack);
354         printf("Line number table length: %d\n", m->linenumbercount);
355
356         if (stage >= SHOW_PARSE) {
357                 printf("Exceptions (Number: %d):\n", cd->exceptiontablelength);
358                 for (ex = cd->exceptiontable; ex != NULL; ex = ex->down) {
359                         printf("    L%03d ... ", ex->start->debug_nr );
360                         printf("L%03d  = ", ex->end->debug_nr);
361                         printf("L%03d", ex->handler->debug_nr);
362                         printf("  (catchtype: ");
363                         if (ex->catchtype.any)
364                                 if (IS_CLASSREF(ex->catchtype))
365                                         utf_display_printable_ascii_classname(ex->catchtype.ref->name);
366                                 else
367                                         utf_display_printable_ascii_classname(ex->catchtype.cls->name);
368                         else
369                                 printf("ANY");
370                         printf(")\n");
371                 }
372         }
373         
374         if (stage >= SHOW_PARSE && rd) {
375         printf("Local Table:\n");
376         for (i = 0; i < cd->maxlocals; i++) {
377                 printf("   %3d: ", i);
378
379 #if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
380                 for (j = TYPE_INT; j <= TYPE_ADR; j++) {
381 # if defined(ENABLE_INTRP)
382                         if (!opt_intrp) {
383 # endif
384                                 if (rd->locals[i][j].type >= 0) {
385                                         printf("   (%s) ", jit_type[j]);
386                                         if (stage >= SHOW_REGS) {
387                                                 if (rd->locals[i][j].flags & INMEMORY)
388                                                         printf("m%2d", rd->locals[i][j].regoff);
389 # ifdef HAS_ADDRESS_REGISTER_FILE
390                                                 else if (j == TYPE_ADR)
391                                                         printf("r%02d", rd->locals[i][j].regoff);
392 # endif
393                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
394                                                         printf("f%02d", rd->locals[i][j].regoff);
395                                                 else {
396 # if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
397                                                         if (IS_2_WORD_TYPE(j))
398                                                                 printf(" %3s/%3s",
399                                                                            regs[GET_LOW_REG(rd->locals[i][j].regoff)],
400                                                                            regs[GET_HIGH_REG(rd->locals[i][j].regoff)]);
401                                                         else
402 # endif
403                                                                 printf("%3s", regs[rd->locals[i][j].regoff]);
404                                                 }
405                                         }
406                                 }
407 # if defined(ENABLE_INTRP)
408                         }
409 # endif
410                 }
411 #endif /* defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER) */
412
413                 printf("\n");
414         }
415         printf("\n");
416         }
417
418         if (stage >= SHOW_STACK && rd) {
419 #if defined(ENABLE_LSRA)
420         if (!opt_lsra) {
421 #endif
422 #if defined(ENABLE_INTRP)
423                 if (!opt_intrp) {
424 #endif
425         printf("Interface Table:\n");
426         for (i = 0; i < cd->maxstack; i++) {
427                 if ((rd->interfaces[i][0].type >= 0) ||
428                         (rd->interfaces[i][1].type >= 0) ||
429                     (rd->interfaces[i][2].type >= 0) ||
430                         (rd->interfaces[i][3].type >= 0) ||
431                     (rd->interfaces[i][4].type >= 0)) {
432                         printf("   %3d: ", i);
433
434 #if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
435 # if defined(ENABLE_INTRP)
436                         if (!opt_intrp) {
437 # endif
438                                 for (j = TYPE_INT; j <= TYPE_ADR; j++) {
439                                         if (rd->interfaces[i][j].type >= 0) {
440                                                 printf("   (%s) ", jit_type[j]);
441                                                 if (stage >= SHOW_REGS) {
442                                                         if (rd->interfaces[i][j].flags & SAVEDVAR) {
443                                                                 if (rd->interfaces[i][j].flags & INMEMORY)
444                                                                         printf("M%2d", rd->interfaces[i][j].regoff);
445 #ifdef HAS_ADDRESS_REGISTER_FILE
446                                                                 else if (j == TYPE_ADR)
447                                                                         printf("R%02d", rd->interfaces[i][j].regoff);
448 #endif
449                                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
450                                                                         printf("F%02d", rd->interfaces[i][j].regoff);
451                                                                 else {
452 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
453                                                                         if (IS_2_WORD_TYPE(j))
454                                                                                 printf(" %3s/%3s",
455                                                                                            regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
456                                                                                            regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
457                                                                         else
458 #endif
459                                                                                 printf("%3s",regs[rd->interfaces[i][j].regoff]);
460                                                                 }
461                                                         }
462                                                         else {
463                                                                 if (rd->interfaces[i][j].flags & INMEMORY)
464                                                                         printf("m%2d", rd->interfaces[i][j].regoff);
465 #ifdef HAS_ADDRESS_REGISTER_FILE
466                                                                 else if (j == TYPE_ADR)
467                                                                         printf("r%02d", rd->interfaces[i][j].regoff);
468 #endif
469                                                                 else if ((j == TYPE_FLT) || (j == TYPE_DBL))
470                                                                         printf("f%02d", rd->interfaces[i][j].regoff);
471                                                                 else {
472 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
473                                                                         if (IS_2_WORD_TYPE(j))
474                                                                                 printf(" %3s/%3s",
475                                                                                            regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
476                                                                                            regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
477                                                                         else
478 #endif
479                                                                                 printf("%3s",regs[rd->interfaces[i][j].regoff]);
480                                                                 }
481                                                         }
482                                                 }
483                                         }
484                                 }
485                                 printf("\n");
486 # if defined(ENABLE_INTRP)
487                         }
488 # endif
489 #endif /* defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER) */
490
491                 }
492         }
493         printf("\n");
494
495 #if defined(ENABLE_INTRP)
496                 }
497 #endif
498 #if defined(ENABLE_LSRA)
499         }
500 #endif
501         } /* if >= SHOW_STACK */
502
503         if (code->rplpoints) {
504                 printf("Replacement Points:\n");
505                 replace_show_replacement_points(code);
506                 printf("\n");
507         }
508
509 #if defined(ENABLE_DISASSEMBLER)
510         /* show code before first basic block */
511
512         if ((stage >= SHOW_CODE) && JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
513                 u1ptr = (u1 *) ((ptrint) code->mcode + cd->dseglen);
514
515                 for (; u1ptr < (u1 *) ((ptrint) code->mcode + cd->dseglen + jd->new_basicblocks[0].mpc);)
516                         DISASSINSTR(u1ptr);
517
518                 printf("\n");
519         }
520 #endif
521
522         /* show code of all basic blocks */
523
524         for (bptr = jd->new_basicblocks; bptr != NULL; bptr = bptr->next)
525                 new_show_basicblock(jd, bptr, stage);
526
527 #if defined(ENABLE_DISASSEMBLER)
528         /* show stubs code */
529
530         if (stage >= SHOW_CODE && opt_showdisassemble && opt_showexceptionstubs) {
531                 printf("\nException stubs code:\n");
532                 printf("Length: %d\n\n", (s4) (code->mcodelength -
533                                                                            ((ptrint) cd->dseglen +
534                                                                                 jd->new_basicblocks[jd->new_basicblockcount].mpc)));
535
536                 u1ptr = (u1 *) ((ptrint) code->mcode + cd->dseglen +
537                                                 jd->new_basicblocks[jd->new_basicblockcount].mpc);
538
539                 for (; (ptrint) u1ptr < ((ptrint) code->mcode + code->mcodelength);)
540                         DISASSINSTR(u1ptr);
541
542                 printf("\n");
543         }
544 #endif
545
546         LOCK_MONITOR_EXIT(show_global_lock);
547
548         /* finally flush the output */
549
550         fflush(stdout);
551 }
552 #endif /* !defined(NDEBUG) */
553
554 #if !defined(NDEBUG)
555 void show_method(jitdata *jd)
556 {
557         methodinfo     *m;
558         codeinfo       *code;
559         codegendata    *cd;
560         registerdata   *rd;
561         basicblock     *bptr;
562         exceptiontable *ex;
563         s4              i, j;
564         u1             *u1ptr;
565
566         /* get required compiler data */
567
568         m    = jd->m;
569         code = jd->code;
570         cd   = jd->cd;
571         rd   = jd->rd;
572
573         /* We need to enter a lock here, since the binutils disassembler
574            is not reentrant-able and we could not read functions printed
575            at the same time. */
576
577         LOCK_MONITOR_ENTER(show_global_lock);
578
579         printf("\n");
580
581         method_println(m);
582
583         printf("\nBasic blocks: %d\n", m->basicblockcount);
584         printf("Code length:  %d\n", (m->basicblocks[m->basicblockcount].mpc - 
585                                                                   m->basicblocks[0].mpc));
586         printf("Data length:  %d\n", cd->dseglen);
587         printf("Max locals:   %d\n", cd->maxlocals);
588         printf("Max stack:    %d\n", cd->maxstack);
589         printf("Line number table length: %d\n", m->linenumbercount);
590
591         printf("Exceptions (Number: %d):\n", cd->exceptiontablelength);
592         for (ex = cd->exceptiontable; ex != NULL; ex = ex->down) {
593                 printf("    L%03d ... ", ex->start->debug_nr );
594                 printf("L%03d  = ", ex->end->debug_nr);
595                 printf("L%03d", ex->handler->debug_nr);
596                 printf("  (catchtype: ");
597                 if (ex->catchtype.any)
598                         if (IS_CLASSREF(ex->catchtype))
599                                 utf_display_printable_ascii_classname(ex->catchtype.ref->name);
600                         else
601                                 utf_display_printable_ascii_classname(ex->catchtype.cls->name);
602                 else
603                         printf("ANY");
604                 printf(")\n");
605         }
606         
607         printf("Local Table:\n");
608         for (i = 0; i < cd->maxlocals; i++) {
609                 printf("   %3d: ", i);
610
611 #if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
612                 for (j = TYPE_INT; j <= TYPE_ADR; j++) {
613 # if defined(ENABLE_INTRP)
614                         if (!opt_intrp) {
615 # endif
616                                 if (rd->locals[i][j].type >= 0) {
617                                         printf("   (%s) ", jit_type[j]);
618                                         if (rd->locals[i][j].flags & INMEMORY)
619                                                 printf("m%2d", rd->locals[i][j].regoff);
620 # ifdef HAS_ADDRESS_REGISTER_FILE
621                                         else if (j == TYPE_ADR)
622                                                 printf("r%02d", rd->locals[i][j].regoff);
623 # endif
624                                         else if ((j == TYPE_FLT) || (j == TYPE_DBL))
625                                                 printf("f%02d", rd->locals[i][j].regoff);
626                                         else {
627 # if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
628                                                 if (IS_2_WORD_TYPE(j))
629                                                         printf(" %3s/%3s",
630                                                                    regs[GET_LOW_REG(rd->locals[i][j].regoff)],
631                                                                    regs[GET_HIGH_REG(rd->locals[i][j].regoff)]);
632                                                 else
633 # endif
634                                                         printf("%3s", regs[rd->locals[i][j].regoff]);
635                                         }
636                                 }
637 # if defined(ENABLE_INTRP)
638                         }
639 # endif
640                 }
641 #endif /* defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER) */
642
643                 printf("\n");
644         }
645         printf("\n");
646
647 #if defined(ENABLE_LSRA)
648         if (!opt_lsra) {
649 #endif
650 #if defined(ENABLE_INTRP)
651                 if (!opt_intrp) {
652 #endif
653         printf("Interface Table:\n");
654         for (i = 0; i < cd->maxstack; i++) {
655                 if ((rd->interfaces[i][0].type >= 0) ||
656                         (rd->interfaces[i][1].type >= 0) ||
657                     (rd->interfaces[i][2].type >= 0) ||
658                         (rd->interfaces[i][3].type >= 0) ||
659                     (rd->interfaces[i][4].type >= 0)) {
660                         printf("   %3d: ", i);
661
662 #if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
663 # if defined(ENABLE_INTRP)
664                         if (!opt_intrp) {
665 # endif
666                                 for (j = TYPE_INT; j <= TYPE_ADR; j++) {
667                                         if (rd->interfaces[i][j].type >= 0) {
668                                                 printf("   (%s) ", jit_type[j]);
669                                                 if (rd->interfaces[i][j].flags & SAVEDVAR) {
670                                                         if (rd->interfaces[i][j].flags & INMEMORY)
671                                                                 printf("M%2d", rd->interfaces[i][j].regoff);
672 #ifdef HAS_ADDRESS_REGISTER_FILE
673                                                         else if (j == TYPE_ADR)
674                                                                 printf("R%02d", rd->interfaces[i][j].regoff);
675 #endif
676                                                         else if ((j == TYPE_FLT) || (j == TYPE_DBL))
677                                                                 printf("F%02d", rd->interfaces[i][j].regoff);
678                                                         else {
679 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
680                                                                 if (IS_2_WORD_TYPE(j))
681                                                                         printf(" %3s/%3s",
682                                                                                    regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
683                                                                                    regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
684                                                                 else
685 #endif
686                                                                         printf("%3s",regs[rd->interfaces[i][j].regoff]);
687                                                         }
688                                                 }
689                                                 else {
690                                                         if (rd->interfaces[i][j].flags & INMEMORY)
691                                                                 printf("m%2d", rd->interfaces[i][j].regoff);
692 #ifdef HAS_ADDRESS_REGISTER_FILE
693                                                         else if (j == TYPE_ADR)
694                                                                 printf("r%02d", rd->interfaces[i][j].regoff);
695 #endif
696                                                         else if ((j == TYPE_FLT) || (j == TYPE_DBL))
697                                                                 printf("f%02d", rd->interfaces[i][j].regoff);
698                                                         else {
699 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
700                                                                 if (IS_2_WORD_TYPE(j))
701                                                                         printf(" %3s/%3s",
702                                                                                    regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
703                                                                                    regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
704                                                                 else
705 #endif
706                                                                         printf("%3s",regs[rd->interfaces[i][j].regoff]);
707                                                         }
708                                                 }
709                                         }
710                                 }
711                                 printf("\n");
712 # if defined(ENABLE_INTRP)
713                         }
714 # endif
715 #endif /* defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER) */
716
717                 }
718         }
719         printf("\n");
720
721 #if defined(ENABLE_INTRP)
722                 }
723 #endif
724 #if defined(ENABLE_LSRA)
725         }
726 #endif
727
728         if (code->rplpoints) {
729                 printf("Replacement Points:\n");
730                 replace_show_replacement_points(code);
731                 printf("\n");
732         }
733
734 #if defined(ENABLE_DISASSEMBLER)
735         /* show code before first basic block */
736
737         if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
738                 u1ptr = (u1 *) ((ptrint) code->mcode + cd->dseglen);
739
740                 for (; u1ptr < (u1 *) ((ptrint) code->mcode + cd->dseglen + m->basicblocks[0].mpc);)
741                         DISASSINSTR(u1ptr);
742
743                 printf("\n");
744         }
745 #endif
746
747         /* show code of all basic blocks */
748
749         for (bptr = m->basicblocks; bptr != NULL; bptr = bptr->next)
750                 show_basicblock(jd, bptr);
751
752 #if defined(ENABLE_DISASSEMBLER)
753         /* show stubs code */
754
755         if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) && opt_showexceptionstubs) {
756                 printf("\nException stubs code:\n");
757                 printf("Code length: %d\n\n", (s4) (code->mcodelength -
758                                                                                         ((ptrint) cd->dseglen +
759                                                                                          m->basicblocks[m->basicblockcount].mpc)));
760
761                 u1ptr = (u1 *) ((ptrint) code->mcode + cd->dseglen +
762                                                 m->basicblocks[m->basicblockcount].mpc);
763
764                 for (; (ptrint) u1ptr < ((ptrint) code->mcode + code->mcodelength);)
765                         DISASSINSTR(u1ptr);
766
767                 printf("\n");
768         }
769 #endif
770
771         LOCK_MONITOR_EXIT(show_global_lock);
772
773         /* finally flush the output */
774
775         fflush(stdout);
776 }
777 #endif /* !defined(NDEBUG) */
778
779
780 /* show_basicblock *************************************************************
781
782    Print the intermediate representation of a basic block.
783
784    NOTE: Currently this function may only be called after register allocation!
785
786 *******************************************************************************/
787
788 #if !defined(NDEBUG)
789 void new_show_basicblock(jitdata *jd, basicblock *bptr, int stage)
790 {
791         methodinfo  *m;
792         codeinfo    *code;
793         codegendata *cd;
794         s4           i;
795         bool         deadcode;
796         new_instruction *iptr;
797         u1          *u1ptr;
798
799         /* get required compiler data */
800
801         m    = jd->m;
802         code = jd->code;
803         cd   = jd->cd;
804
805         if (bptr->flags != BBDELETED) {
806                 deadcode = bptr->flags <= BBREACHED;
807
808                 printf("======== %sL%03d ======== (flags: %d, bitflags: %01x, next: %d, type: ",
809                                 (bptr->bitflags & BBFLAG_REPLACEMENT) ? "<REPLACE> " : "",
810                            bptr->debug_nr, bptr->flags, bptr->bitflags, 
811                            (bptr->next) ? (bptr->next->debug_nr) : -1);
812
813                 switch (bptr->type) {
814                 case BBTYPE_STD:
815                         printf("STD");
816                         break;
817                 case BBTYPE_EXH:
818                         printf("EXH");
819                         break;
820                 case BBTYPE_SBR:
821                         printf("SBR");
822                         break;
823                 }
824
825                 printf(", instruction count: %d, predecessors: %d):\n",
826                            bptr->icount, bptr->pre_count);
827
828                 iptr = /*XXX*/ (new_instruction *) bptr->iinstr;
829
830                 for (i = 0; i < bptr->icount; i++, iptr++) {
831                         printf("%4d:  ", iptr->line);
832
833                         new_show_icmd(jd, iptr, deadcode, stage);
834                         printf("\n");
835                 }
836
837 #if defined(ENABLE_DISASSEMBLER)
838                 if ((stage >= SHOW_CODE) && JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) &&
839                         (!deadcode)) {
840                         printf("\n");
841                         u1ptr = (u1 *) ((ptrint) code->mcode + cd->dseglen + bptr->mpc);
842
843                         if (bptr->next != NULL) {
844                                 for (; u1ptr < (u1 *) ((ptrint) code->mcode + cd->dseglen + bptr->next->mpc);)
845                                         DISASSINSTR(u1ptr);
846
847                         } 
848                         else {
849                                 for (; u1ptr < (u1 *) ((ptrint) code->mcode + code->mcodelength);)
850                                         DISASSINSTR(u1ptr); 
851                         }
852                         printf("\n");
853                 }
854 #endif
855         }
856 }
857 #endif /* !defined(NDEBUG) */
858
859 #if !defined(NDEBUG)
860 void show_basicblock(jitdata *jd, basicblock *bptr)
861 {
862         methodinfo  *m;
863         codeinfo    *code;
864         codegendata *cd;
865         s4           i, j;
866         bool         deadcode;
867         instruction *iptr;
868         u1          *u1ptr;
869
870         /* get required compiler data */
871
872         m    = jd->m;
873         code = jd->code;
874         cd   = jd->cd;
875
876         if (bptr->flags != BBDELETED) {
877                 deadcode = bptr->flags <= BBREACHED;
878
879                 printf("[");
880
881                 if (deadcode)
882                         for (j = cd->maxstack; j > 0; j--)
883                                 printf(" ?  ");
884                 else
885                         show_print_stack(cd, bptr->instack);
886
887                 printf("] %sL%03d(flags: %d, bitflags: %01x, next: %d, type: ",
888                                 (bptr->bitflags & BBFLAG_REPLACEMENT) ? "<REPLACE> " : "",
889                            bptr->debug_nr, bptr->flags, bptr->bitflags, 
890                            (bptr->next) ? (bptr->next->debug_nr) : -1);
891
892                 switch (bptr->type) {
893                 case BBTYPE_STD:
894                         printf("STD");
895                         break;
896                 case BBTYPE_EXH:
897                         printf("EXH");
898                         break;
899                 case BBTYPE_SBR:
900                         printf("SBR");
901                         break;
902                 }
903
904                 printf(", instruction count: %d, predecessors: %d):\n",
905                            bptr->icount, bptr->pre_count);
906
907                 iptr = bptr->iinstr;
908
909                 for (i = 0; i < bptr->icount; i++, iptr++) {
910                         printf("[");
911
912                         if (deadcode)
913                                 for (j = cd->maxstack; j > 0; j--)
914                                         printf(" ?  ");
915                         else
916                                 show_print_stack(cd, iptr->dst);
917
918                         printf("] %5d (line: %5d)  ", i, iptr->line);
919
920                         show_icmd(iptr, deadcode);
921                         printf("\n");
922                 }
923
924 #if defined(ENABLE_DISASSEMBLER)
925                 if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) && (!deadcode)) {
926                         printf("\n");
927                         u1ptr = (u1 *) ((ptrint) code->mcode + cd->dseglen + bptr->mpc);
928
929                         if (bptr->next != NULL) {
930                                 for (; u1ptr < (u1 *) ((ptrint) code->mcode + cd->dseglen + bptr->next->mpc);)
931                                         DISASSINSTR(u1ptr);
932
933                         } 
934                         else {
935                                 for (; u1ptr < (u1 *) ((ptrint) code->mcode + code->mcodelength);)
936                                         DISASSINSTR(u1ptr); 
937                         }
938                         printf("\n");
939                 }
940 #endif
941         }
942 }
943 #endif /* !defined(NDEBUG) */
944
945
946 /* show_icmd *******************************************************************
947
948    Print the intermediate representation of an instruction.
949
950    NOTE: Currently this function may only be called after register allocation!
951
952 *******************************************************************************/
953
954 #if !defined(NDEBUG)
955
956 #define SHOW_TARGET(target)                                          \
957         if (stage >= SHOW_STACK) {                                   \
958             printf("--> L%03d ", (target).block->debug_nr);          \
959         }                                                            \
960         else if (stage >= SHOW_PARSE) {                              \
961             printf("--> insindex %d (L%03d) ", (target).insindex,    \
962                 jd->new_basicblocks[jd->new_basicblockindex[         \
963                 (target).insindex]].debug_nr);                       \
964         }                                                            \
965         else {                                                       \
966             printf("--> insindex %d ", (target).insindex);           \
967         }
968
969 #define SHOW_INT_CONST(val)                                          \
970         if (stage >= SHOW_PARSE) {                                   \
971             printf("%ld ", (long) (val));                            \
972         }                                                            \
973         else {                                                       \
974             printf("iconst ");                                       \
975         }
976
977 #define SHOW_LNG_CONST(val)                                          \
978         if (stage >= SHOW_PARSE) {                                   \
979             printf("%lld ", (long long)(val));                       \
980         }                                                            \
981         else {                                                       \
982             printf("lconst ");                                       \
983         }
984
985 #define SHOW_FLT_CONST(val)                                          \
986         if (stage >= SHOW_PARSE) {                                   \
987             printf("%g ", (val));                                    \
988         }                                                            \
989         else {                                                       \
990             printf("fconst ");                                       \
991         }
992
993 #define SHOW_DBL_CONST(val)                                          \
994         if (stage >= SHOW_PARSE) {                                   \
995             printf("%g ", (val));                                    \
996         }                                                            \
997         else {                                                       \
998             printf("dconst ");                                       \
999         }
1000
1001 #define SHOW_INDEX(index)                                            \
1002         if (stage >= SHOW_PARSE) {                                   \
1003             printf("%d ", index);                                    \
1004         }                                                            \
1005         else {                                                       \
1006             printf("index");                                         \
1007         }
1008
1009 #define SHOW_STRING(val)                                             \
1010         if (stage >= SHOW_PARSE) {                                   \
1011             putchar('"');                                            \
1012             utf_display_printable_ascii(                             \
1013                 javastring_toutf((java_lang_String *)(val), false)); \
1014             printf("\" ");                                           \
1015         }                                                            \
1016         else {                                                       \
1017             printf("string ");                                       \
1018         }
1019
1020 #define SHOW_CLASSREF_OR_CLASSINFO(c)                                \
1021         if (stage >= SHOW_PARSE) {                                   \
1022             if (IS_CLASSREF(c))                                      \
1023                 class_classref_print(c.ref);                         \
1024             else                                                     \
1025                 class_print(c.cls);                                  \
1026             putchar(' ');                                            \
1027         }                                                            \
1028         else {                                                       \
1029             printf("class ");                                        \
1030         }
1031
1032 #define SHOW_FIELD(fmiref)                                           \
1033         if (stage >= SHOW_PARSE) {                                   \
1034             field_fieldref_print(fmiref);                            \
1035             putchar(' ');                                            \
1036         }                                                            \
1037         else {                                                       \
1038             printf("field ");                                        \
1039         }
1040
1041 #define SHOW_STACKVAR(sp)                                            \
1042         new_show_stackvar(jd, (sp), stage)
1043
1044 #define SHOW_S1(iptr)                                                \
1045         if (stage >= SHOW_STACK) {                                   \
1046             SHOW_STACKVAR(iptr->s1.var);                             \
1047         }
1048
1049 #define SHOW_S2(iptr)                                                \
1050         if (stage >= SHOW_STACK) {                                   \
1051             SHOW_STACKVAR(iptr->sx.s23.s2.var);                      \
1052         }
1053
1054 #define SHOW_S3(iptr)                                                \
1055         if (stage >= SHOW_STACK) {                                   \
1056             SHOW_STACKVAR(iptr->sx.s23.s3.var);                      \
1057         }
1058
1059 #define SHOW_DST(iptr)                                               \
1060         if (stage >= SHOW_STACK) {                                   \
1061             printf("=> ");                                           \
1062             SHOW_STACKVAR(iptr->dst.var);                            \
1063         }
1064
1065 #define SHOW_S1_LOCAL(iptr)                                          \
1066         if (stage >= SHOW_STACK) {                                   \
1067             printf("L%d ", iptr->s1.localindex);                     \
1068         }
1069
1070 #define SHOW_DST_LOCAL(iptr)                                         \
1071         if (stage >= SHOW_STACK) {                                   \
1072             printf("=> L%d ", iptr->dst.localindex);                 \
1073         }
1074
1075 static void new_show_stackvar(jitdata *jd, stackptr sp, int stage)
1076 {
1077         char type;
1078
1079         switch (sp->type) {
1080                 case TYPE_INT: type = 'i'; break;
1081                 case TYPE_LNG: type = 'l'; break;
1082                 case TYPE_FLT: type = 'f'; break;
1083                 case TYPE_DBL: type = 'd'; break;
1084                 case TYPE_ADR: type = 'a'; break;
1085                 default:       type = '?';
1086         }
1087         printf("S%c%d", type, (int) (sp - jd->new_stack));
1088
1089         if (stage >= SHOW_REGS) {
1090                 putchar('(');
1091
1092                 if (sp->flags & SAVEDVAR) {
1093                         switch (sp->varkind) {
1094                         case TEMPVAR:
1095                                 if (sp->flags & INMEMORY)
1096                                         printf("M%02d", sp->regoff);
1097 #ifdef HAS_ADDRESS_REGISTER_FILE
1098                                 else if (sp->type == TYPE_ADR)
1099                                         printf("R%02d", sp->regoff);
1100 #endif
1101                                 else if (IS_FLT_DBL_TYPE(sp->type))
1102                                         printf("F%02d", sp->regoff);
1103                                 else {
1104 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
1105                                         if (IS_2_WORD_TYPE(sp->type)) {
1106 # if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
1107 #  if defined(ENABLE_INTRP)
1108                                                 if (opt_intrp)
1109                                                         printf("%3d/%3d", GET_LOW_REG(sp->regoff),
1110                                                                    GET_HIGH_REG(sp->regoff));
1111                                                 else
1112 #  endif
1113                                                         printf("%3s/%3s", regs[GET_LOW_REG(sp->regoff)],
1114                                                                    regs[GET_HIGH_REG(sp->regoff)]);
1115 # else
1116                                                 printf("%3d/%3d", GET_LOW_REG(sp->regoff),
1117                                                            GET_HIGH_REG(sp->regoff));
1118 # endif
1119                                         } 
1120                                         else 
1121 #endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */
1122                                                 {
1123 #if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
1124 # if defined(ENABLE_INTRP)
1125                                                         if (opt_intrp)
1126                                                                 printf("%3d", sp->regoff);
1127                                                         else
1128 # endif
1129                                                                 printf("%3s", regs[sp->regoff]);
1130 #else
1131                                                         printf("%3d", sp->regoff);
1132 #endif
1133                                                 }
1134                                 }
1135                                 break;
1136                         case STACKVAR:
1137                                 printf("I%02d", sp->varnum);
1138                                 break;
1139                         case LOCALVAR:
1140                                 printf("L%02d", sp->varnum);
1141                                 break;
1142                         case ARGVAR:
1143                                 if (sp->varnum == -1) {
1144                                         /* Return Value                                  */
1145                                         /* varkind ARGVAR "misused for this special case */
1146                                         printf(" V0");
1147                                 } 
1148                                 else /* "normal" Argvar */
1149                                         printf("A%02d", sp->varnum);
1150                                 break;
1151                         default:
1152                                 printf("!xx {kind=%d, num=%d}", sp->varkind, sp->varnum);
1153                         }
1154                 }
1155                 else { /* not SAVEDVAR */
1156                         switch (sp->varkind) {
1157                         case TEMPVAR:
1158                                 if (sp->flags & INMEMORY)
1159                                         printf("m%02d", sp->regoff);
1160 #ifdef HAS_ADDRESS_REGISTER_FILE
1161                                 else if (sp->type == TYPE_ADR)
1162                                         printf("r%02d", sp->regoff);
1163 #endif
1164                                 else if (IS_FLT_DBL_TYPE(sp->type))
1165                                         printf("f%02d", sp->regoff);
1166                                 else {
1167 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
1168                                         if (IS_2_WORD_TYPE(sp->type)) {
1169 # if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
1170 #  if defined(ENABLE_INTRP)
1171                                                 if (opt_intrp)
1172                                                         printf("%3d/%3d", GET_LOW_REG(sp->regoff),
1173                                                                    GET_HIGH_REG(sp->regoff));
1174                                                 else
1175 #  endif
1176                                                         printf("%3s/%3s", regs[GET_LOW_REG(sp->regoff)],
1177                                                                    regs[GET_HIGH_REG(sp->regoff)]);
1178 # else
1179                                                 printf("%3d/%3d", GET_LOW_REG(sp->regoff),
1180                                                            GET_HIGH_REG(sp->regoff));
1181 # endif
1182                                         } 
1183                                         else
1184 #endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */
1185                                                 {
1186 #if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
1187 # if defined(ENABLE_INTRP)
1188                                                         if (opt_intrp)
1189                                                                 printf("%3d", sp->regoff);
1190                                                         else
1191 # endif
1192                                                                 printf("%3s", regs[sp->regoff]);
1193 #else
1194                                                         printf("%3d", sp->regoff);
1195 #endif
1196                                                 }
1197                                 }
1198                                 break;
1199                         case STACKVAR:
1200                                 printf("i%02d", sp->varnum);
1201                                 break;
1202                         case LOCALVAR:
1203                                 printf("l%02d", sp->varnum);
1204                                 break;
1205                         case ARGVAR:
1206                                 if (sp->varnum == -1) {
1207                                         /* Return Value                                  */
1208                                         /* varkind ARGVAR "misused for this special case */
1209                                         printf(" v0");
1210                                 } 
1211                                 else /* "normal" Argvar */
1212                                 printf("a%02d", sp->varnum);
1213                                 break;
1214                         default:
1215                                 printf("?xx {kind=%d, num=%d}", sp->varkind, sp->varnum);
1216                         }
1217                 }
1218
1219                 putchar(')');
1220         }
1221         putchar(' ');
1222 }
1223
1224 void new_show_icmd(jitdata *jd, new_instruction *iptr, bool deadcode, int stage)
1225 {
1226         u2                 opcode;
1227         branch_target_t   *table;
1228         lookup_target_t   *lookup;
1229         constant_FMIref   *fmiref;
1230         stackptr          *argp;
1231         s4                 i;
1232
1233         /* get the opcode and the condition */
1234
1235         opcode    =  iptr->opc;
1236
1237         printf("%s ", icmd_names[opcode]);
1238
1239         if (stage < SHOW_PARSE)
1240                 return;
1241
1242         if (deadcode)
1243                 stage = SHOW_PARSE;
1244
1245         /* Print the condition for conditional instructions. */
1246
1247         /* XXX print condition from flags */
1248
1249         if (iptr->flags.bits & INS_FLAG_UNRESOLVED)
1250                 printf("(UNRESOLVED) ");
1251
1252         switch (opcode) {
1253
1254         case ICMD_POP:
1255         case ICMD_CHECKNULL:
1256         case ICMD_CHECKNULL_POP:
1257                 SHOW_S1(iptr);
1258                 break;
1259
1260                 /* unary */
1261         case ICMD_ARRAYLENGTH:
1262         case ICMD_INEG:
1263         case ICMD_LNEG:
1264         case ICMD_FNEG:
1265         case ICMD_DNEG:
1266         case ICMD_I2L:
1267         case ICMD_I2F:
1268         case ICMD_I2D:
1269         case ICMD_L2I:
1270         case ICMD_L2F:
1271         case ICMD_L2D:
1272         case ICMD_F2I:
1273         case ICMD_F2L:
1274         case ICMD_F2D:
1275         case ICMD_D2I:
1276         case ICMD_D2L:
1277         case ICMD_D2F:
1278         case ICMD_INT2BYTE:
1279         case ICMD_INT2CHAR:
1280         case ICMD_INT2SHORT:
1281                 SHOW_S1(iptr);
1282                 SHOW_DST(iptr);
1283                 break;
1284
1285                 /* binary */
1286         case ICMD_IADD:
1287         case ICMD_LADD:
1288         case ICMD_FADD:
1289         case ICMD_DADD:
1290         case ICMD_ISUB:
1291         case ICMD_LSUB:
1292         case ICMD_FSUB:
1293         case ICMD_DSUB:
1294         case ICMD_IMUL:
1295         case ICMD_LMUL:
1296         case ICMD_FMUL:
1297         case ICMD_DMUL:
1298         case ICMD_IDIV:
1299         case ICMD_LDIV:
1300         case ICMD_FDIV:
1301         case ICMD_DDIV:
1302         case ICMD_IREM:
1303         case ICMD_LREM:
1304         case ICMD_FREM:
1305         case ICMD_DREM:
1306         case ICMD_ISHL:
1307         case ICMD_LSHL:
1308         case ICMD_ISHR:
1309         case ICMD_LSHR:
1310         case ICMD_IUSHR:
1311         case ICMD_LUSHR:
1312         case ICMD_IAND:
1313         case ICMD_LAND:
1314         case ICMD_IOR:
1315         case ICMD_LOR:
1316         case ICMD_IXOR:
1317         case ICMD_LXOR:
1318         case ICMD_LCMP:
1319         case ICMD_FCMPL:
1320         case ICMD_FCMPG:
1321         case ICMD_DCMPL:
1322         case ICMD_DCMPG:
1323                 SHOW_S1(iptr);
1324                 SHOW_S2(iptr);
1325                 SHOW_DST(iptr);
1326                 break;
1327
1328                 /* binary/const INT */
1329         case ICMD_IADDCONST:
1330         case ICMD_ISUBCONST:
1331         case ICMD_IMULCONST:
1332         case ICMD_IMULPOW2:
1333         case ICMD_IDIVPOW2:
1334         case ICMD_IREMPOW2:
1335         case ICMD_IANDCONST:
1336         case ICMD_IORCONST:
1337         case ICMD_IXORCONST:
1338         case ICMD_ISHLCONST:
1339         case ICMD_ISHRCONST:
1340         case ICMD_IUSHRCONST:
1341         case ICMD_LSHLCONST:
1342         case ICMD_LSHRCONST:
1343         case ICMD_LUSHRCONST:
1344                 SHOW_S1(iptr);
1345                 SHOW_INT_CONST(iptr->sx.val.i); 
1346                 SHOW_DST(iptr);
1347                 break;
1348
1349                 /* ?ASTORECONST (trinary/const INT) */
1350         case ICMD_IASTORECONST:
1351         case ICMD_BASTORECONST:
1352         case ICMD_CASTORECONST:
1353         case ICMD_SASTORECONST:
1354                 SHOW_S1(iptr);
1355                 SHOW_S2(iptr);
1356                 SHOW_INT_CONST(iptr->sx.s23.s3.constval);
1357                 break;
1358
1359                 /* const INT */
1360         case ICMD_ICONST:
1361                 SHOW_INT_CONST(iptr->sx.val.i); 
1362                 SHOW_DST(iptr);
1363                 break;
1364
1365                 /* binary/const LNG */
1366         case ICMD_LADDCONST:
1367         case ICMD_LSUBCONST:
1368         case ICMD_LMULCONST:
1369         case ICMD_LMULPOW2:
1370         case ICMD_LDIVPOW2:
1371         case ICMD_LREMPOW2:
1372         case ICMD_LANDCONST:
1373         case ICMD_LORCONST:
1374         case ICMD_LXORCONST:
1375                 SHOW_S1(iptr);
1376                 SHOW_LNG_CONST(iptr->sx.val.l); 
1377                 SHOW_DST(iptr);
1378                 break;
1379
1380                 /* trinary/const LNG (<= pointer size) */
1381         case ICMD_LASTORECONST:
1382                 SHOW_S1(iptr);
1383                 SHOW_S2(iptr);
1384                 SHOW_LNG_CONST(iptr->sx.s23.s3.constval);
1385                 break;
1386
1387                 /* const LNG */
1388         case ICMD_LCONST:
1389                 SHOW_LNG_CONST(iptr->sx.val.l); 
1390                 SHOW_DST(iptr);
1391                 break;
1392
1393                 /* const FLT */
1394         case ICMD_FCONST:
1395                 SHOW_FLT_CONST(iptr->sx.val.f); 
1396                 SHOW_DST(iptr);
1397                 break;
1398
1399                 /* const DBL */
1400         case ICMD_DCONST:
1401                 SHOW_DBL_CONST(iptr->sx.val.d); 
1402                 SHOW_DST(iptr);
1403                 break;
1404
1405                 /* const ADR */
1406         case ICMD_ACONST:
1407                 if (iptr->flags.bits & INS_FLAG_CLASS) {
1408                         SHOW_CLASSREF_OR_CLASSINFO(iptr->sx.val.c);
1409                 }
1410                 else if (iptr->sx.val.anyptr == NULL) {
1411                         printf("NULL ");
1412                 }
1413                 else {
1414                         SHOW_STRING(iptr->sx.val.stringconst);
1415                 }
1416                 SHOW_DST(iptr);
1417                 break;
1418
1419         case ICMD_AASTORECONST:
1420                 SHOW_S1(iptr);
1421                 SHOW_S2(iptr);
1422                 printf("%p ", (void*) iptr->sx.s23.s3.constval);
1423                 break;
1424
1425         case ICMD_GETFIELD:        /* 1 -> 1 */
1426         case ICMD_PUTFIELD:        /* 2 -> 0 */
1427         case ICMD_PUTSTATIC:       /* 1 -> 0 */
1428         case ICMD_GETSTATIC:       /* 0 -> 1 */
1429         case ICMD_PUTSTATICCONST:  /* 0 -> 0 */
1430         case ICMD_PUTFIELDCONST:   /* 1 -> 0 */
1431                 if (opcode != ICMD_GETSTATIC && opcode != ICMD_PUTSTATICCONST) {
1432                         SHOW_S1(iptr);
1433                         if (opcode == ICMD_PUTFIELD) {
1434                                 SHOW_S2(iptr);
1435                         }
1436                 }
1437                 NEW_INSTRUCTION_GET_FIELDREF(iptr, fmiref);
1438                 SHOW_FIELD(fmiref);
1439
1440                 if (opcode == ICMD_GETSTATIC || opcode == ICMD_GETFIELD) {
1441                         SHOW_DST(iptr);
1442                 }
1443                 break;
1444
1445         case ICMD_IINC:
1446                 SHOW_S1_LOCAL(iptr);
1447                 SHOW_INT_CONST(iptr->sx.val.i);
1448                 SHOW_DST_LOCAL(iptr);
1449                 break;
1450
1451         case ICMD_IASTORE:
1452         case ICMD_SASTORE:
1453         case ICMD_BASTORE:
1454         case ICMD_CASTORE:
1455         case ICMD_LASTORE:
1456         case ICMD_DASTORE:
1457         case ICMD_FASTORE:
1458         case ICMD_AASTORE:
1459                 SHOW_S1(iptr);
1460                 SHOW_S2(iptr);
1461                 SHOW_S3(iptr);
1462                 break;
1463
1464         case ICMD_IALOAD:
1465         case ICMD_SALOAD:
1466         case ICMD_BALOAD:
1467         case ICMD_CALOAD:
1468         case ICMD_LALOAD:
1469         case ICMD_DALOAD:
1470         case ICMD_FALOAD:
1471         case ICMD_AALOAD:
1472                 SHOW_S1(iptr);
1473                 SHOW_S2(iptr);
1474                 SHOW_DST(iptr);
1475                 break;
1476
1477         case ICMD_RET:
1478                 SHOW_S1_LOCAL(iptr);
1479                 break;
1480
1481         case ICMD_ILOAD:
1482         case ICMD_LLOAD:
1483         case ICMD_FLOAD:
1484         case ICMD_DLOAD:
1485         case ICMD_ALOAD:
1486                 SHOW_S1_LOCAL(iptr);
1487                 SHOW_DST(iptr);
1488                 break;
1489
1490         case ICMD_ISTORE:
1491         case ICMD_LSTORE:
1492         case ICMD_FSTORE:
1493         case ICMD_DSTORE:
1494         case ICMD_ASTORE:
1495                 SHOW_S1(iptr);
1496                 SHOW_DST_LOCAL(iptr);
1497                 break;
1498
1499         case ICMD_NEW:
1500                 SHOW_DST(iptr);
1501                 break;
1502
1503         case ICMD_NEWARRAY:
1504                 SHOW_DST(iptr);
1505                 break;
1506
1507         case ICMD_ANEWARRAY:
1508                 SHOW_DST(iptr);
1509                 break;
1510
1511         case ICMD_MULTIANEWARRAY:
1512                 if (stage >= SHOW_STACK) {
1513                         argp = iptr->sx.s23.s2.args;
1514                         i = iptr->s1.argcount;
1515                         while (i--) {
1516                                 SHOW_STACKVAR(*(argp++));
1517                         }
1518                 }
1519                 else {
1520                         printf("argcount=%d ", iptr->s1.argcount);
1521                 }
1522                 SHOW_DST(iptr);
1523                 break;
1524
1525         case ICMD_CHECKCAST:
1526                 SHOW_S1(iptr);
1527                 SHOW_DST(iptr);
1528                 break;
1529
1530         case ICMD_INSTANCEOF:
1531                 SHOW_S1(iptr);
1532                 SHOW_DST(iptr);
1533                 break;
1534
1535         case ICMD_INLINE_START:
1536         case ICMD_INLINE_END:
1537                 break;
1538
1539         case ICMD_BUILTIN:
1540                 if (stage >= SHOW_STACK) {
1541                         argp = iptr->sx.s23.s2.args;
1542                         i = iptr->s1.argcount;
1543                         while (i--) {
1544                                 SHOW_STACKVAR(*(argp++));
1545                         }
1546                 }
1547                 printf("%s ", iptr->sx.s23.s3.bte->name);
1548                 if (iptr->sx.s23.s3.bte->md->returntype.type != TYPE_VOID) {
1549                         SHOW_DST(iptr);
1550                 }
1551                 break;
1552
1553         case ICMD_INVOKEVIRTUAL:
1554         case ICMD_INVOKESPECIAL:
1555         case ICMD_INVOKESTATIC:
1556         case ICMD_INVOKEINTERFACE:
1557                 if (stage >= SHOW_STACK) {
1558                         argp = iptr->sx.s23.s2.args;
1559                         i = iptr->s1.argcount;
1560                         while (i--) {
1561                                 SHOW_STACKVAR(*(argp++));
1562                         }
1563                 }
1564                 NEW_INSTRUCTION_GET_METHODREF(iptr, fmiref);
1565                 method_methodref_print(fmiref);
1566                 if (fmiref->parseddesc.md->returntype.type != TYPE_VOID) {
1567                         SHOW_DST(iptr);
1568                 }
1569                 break;
1570
1571         case ICMD_IFEQ:
1572         case ICMD_IFNE:
1573         case ICMD_IFLT:
1574         case ICMD_IFGE:
1575         case ICMD_IFGT:
1576         case ICMD_IFLE:
1577                 SHOW_S1(iptr);
1578                 SHOW_TARGET(iptr->dst);
1579                 break;
1580
1581         case ICMD_IF_LEQ:
1582         case ICMD_IF_LNE:
1583         case ICMD_IF_LLT:
1584         case ICMD_IF_LGE:
1585         case ICMD_IF_LGT:
1586         case ICMD_IF_LLE:
1587                 SHOW_S1(iptr);
1588                 SHOW_TARGET(iptr->dst);
1589                 break;
1590
1591         case ICMD_GOTO:
1592         case ICMD_INLINE_GOTO:
1593                 SHOW_TARGET(iptr->dst);
1594                 break;
1595
1596         case ICMD_JSR:
1597                 SHOW_TARGET(iptr->sx.s23.s3.jsrtarget);
1598                 SHOW_DST(iptr);
1599                 break;
1600
1601         case ICMD_IFNULL:
1602         case ICMD_IFNONNULL:
1603                 SHOW_S1(iptr);
1604                 SHOW_TARGET(iptr->dst);
1605                 break;
1606
1607         case ICMD_IF_ICMPEQ:
1608         case ICMD_IF_ICMPNE:
1609         case ICMD_IF_ICMPLT:
1610         case ICMD_IF_ICMPGE:
1611         case ICMD_IF_ICMPGT:
1612         case ICMD_IF_ICMPLE:
1613
1614         case ICMD_IF_LCMPEQ:
1615         case ICMD_IF_LCMPNE:
1616         case ICMD_IF_LCMPLT:
1617         case ICMD_IF_LCMPGE:
1618         case ICMD_IF_LCMPGT:
1619         case ICMD_IF_LCMPLE:
1620
1621         case ICMD_IF_FCMPEQ:
1622         case ICMD_IF_FCMPNE:
1623
1624         case ICMD_IF_FCMPL_LT:
1625         case ICMD_IF_FCMPL_GE:
1626         case ICMD_IF_FCMPL_GT:
1627         case ICMD_IF_FCMPL_LE:
1628
1629         case ICMD_IF_FCMPG_LT:
1630         case ICMD_IF_FCMPG_GE:
1631         case ICMD_IF_FCMPG_GT:
1632         case ICMD_IF_FCMPG_LE:
1633
1634         case ICMD_IF_DCMPEQ:
1635         case ICMD_IF_DCMPNE:
1636
1637         case ICMD_IF_DCMPL_LT:
1638         case ICMD_IF_DCMPL_GE:
1639         case ICMD_IF_DCMPL_GT:
1640         case ICMD_IF_DCMPL_LE:
1641
1642         case ICMD_IF_DCMPG_LT:
1643         case ICMD_IF_DCMPG_GE:
1644         case ICMD_IF_DCMPG_GT:
1645         case ICMD_IF_DCMPG_LE:
1646
1647         case ICMD_IF_ACMPEQ:
1648         case ICMD_IF_ACMPNE:
1649                 SHOW_S1(iptr);
1650                 SHOW_S2(iptr);
1651                 SHOW_TARGET(iptr->dst);
1652                 break;
1653
1654         case ICMD_TABLESWITCH:
1655                 SHOW_S1(iptr);
1656                 break;
1657
1658         case ICMD_LOOKUPSWITCH:
1659                 SHOW_S1(iptr);
1660                 break;
1661
1662         case ICMD_ARETURN:
1663                 SHOW_S1(iptr);
1664                 break;
1665
1666         case ICMD_ATHROW:
1667                 SHOW_S1(iptr);
1668                 break;
1669
1670         case ICMD_DUP:
1671                 SHOW_S1(iptr);
1672                 SHOW_DST(iptr);
1673                 break;
1674
1675         case ICMD_DUP2:
1676                 if (stage >= SHOW_STACK) {
1677                         SHOW_STACKVAR(iptr->dst.dupslots[0]);
1678                         SHOW_STACKVAR(iptr->dst.dupslots[1]);
1679                         printf("=> ");
1680                         SHOW_STACKVAR(iptr->dst.dupslots[2+0]);
1681                         SHOW_STACKVAR(iptr->dst.dupslots[2+1]);
1682                 }
1683                 break;
1684
1685         case ICMD_DUP_X1:
1686                 if (stage >= SHOW_STACK) {
1687                         SHOW_STACKVAR(iptr->dst.dupslots[0]);
1688                         SHOW_STACKVAR(iptr->dst.dupslots[1]);
1689                         printf("=> ");
1690                         SHOW_STACKVAR(iptr->dst.dupslots[2+0]);
1691                         SHOW_STACKVAR(iptr->dst.dupslots[2+1]);
1692                         SHOW_STACKVAR(iptr->dst.dupslots[2+2]);
1693                 }
1694                 break;
1695
1696         case ICMD_DUP2_X1:
1697                 if (stage >= SHOW_STACK) {
1698                         SHOW_STACKVAR(iptr->dst.dupslots[0]);
1699                         SHOW_STACKVAR(iptr->dst.dupslots[1]);
1700                         SHOW_STACKVAR(iptr->dst.dupslots[2]);
1701                         printf("=> ");
1702                         SHOW_STACKVAR(iptr->dst.dupslots[3+0]);
1703                         SHOW_STACKVAR(iptr->dst.dupslots[3+1]);
1704                         SHOW_STACKVAR(iptr->dst.dupslots[3+2]);
1705                         SHOW_STACKVAR(iptr->dst.dupslots[3+3]);
1706                         SHOW_STACKVAR(iptr->dst.dupslots[3+4]);
1707                 }
1708                 break;
1709
1710         case ICMD_DUP_X2:
1711                 if (stage >= SHOW_STACK) {
1712                         SHOW_STACKVAR(iptr->dst.dupslots[0]);
1713                         SHOW_STACKVAR(iptr->dst.dupslots[1]);
1714                         SHOW_STACKVAR(iptr->dst.dupslots[2]);
1715                         printf("=> ");
1716                         SHOW_STACKVAR(iptr->dst.dupslots[3+0]);
1717                         SHOW_STACKVAR(iptr->dst.dupslots[3+1]);
1718                         SHOW_STACKVAR(iptr->dst.dupslots[3+2]);
1719                         SHOW_STACKVAR(iptr->dst.dupslots[3+3]);
1720                 }
1721                 break;
1722
1723         case ICMD_DUP2_X2:
1724                 if (stage >= SHOW_STACK) {
1725                         SHOW_STACKVAR(iptr->dst.dupslots[0]);
1726                         SHOW_STACKVAR(iptr->dst.dupslots[1]);
1727                         SHOW_STACKVAR(iptr->dst.dupslots[2]);
1728                         SHOW_STACKVAR(iptr->dst.dupslots[4]);
1729                         printf("=> ");
1730                         SHOW_STACKVAR(iptr->dst.dupslots[4+0]);
1731                         SHOW_STACKVAR(iptr->dst.dupslots[4+1]);
1732                         SHOW_STACKVAR(iptr->dst.dupslots[4+2]);
1733                         SHOW_STACKVAR(iptr->dst.dupslots[4+3]);
1734                         SHOW_STACKVAR(iptr->dst.dupslots[4+4]);
1735                         SHOW_STACKVAR(iptr->dst.dupslots[4+5]);
1736                 }
1737                 break;
1738
1739         case ICMD_SWAP:
1740                 if (stage >= SHOW_STACK) {
1741                         SHOW_STACKVAR(iptr->dst.dupslots[0]);
1742                         SHOW_STACKVAR(iptr->dst.dupslots[1]);
1743                         printf("=> ");
1744                         SHOW_STACKVAR(iptr->dst.dupslots[2+0]);
1745                         SHOW_STACKVAR(iptr->dst.dupslots[2+1]);
1746                 }
1747                 break;
1748
1749         }
1750 }
1751 #endif /* !defined(NDEBUG) */
1752
1753 #if !defined(NDEBUG)
1754 void show_icmd(instruction *iptr, bool deadcode)
1755 {
1756 #if 0
1757         u2                 opcode;
1758         u2                 condition;
1759 #endif
1760         int j;
1761         s4  *s4ptr;
1762         void **tptr = NULL;
1763         classinfo         *c;
1764         fieldinfo         *f;
1765         constant_classref *cr;
1766         unresolved_field  *uf;
1767
1768 #if 0
1769         /* get the opcode and the condition */
1770
1771         opcode    =  iptr->opc & ICMD_OPCODE_MASK;
1772         condition = (iptr->opc & ICMD_CONDITION_MASK) >> 8;
1773
1774         /* Print the condition for conditional instructions. */
1775
1776         if (condition != 0)
1777                 printf(" (condition: %s)", icmd_names[condition]);
1778 #endif
1779
1780         printf("%s", icmd_names[iptr->opc]);
1781
1782         switch (iptr->opc) {
1783         case ICMD_IADDCONST:
1784         case ICMD_ISUBCONST:
1785         case ICMD_IMULCONST:
1786         case ICMD_IMULPOW2:
1787         case ICMD_IDIVPOW2:
1788         case ICMD_IREMPOW2:
1789         case ICMD_IANDCONST:
1790         case ICMD_IORCONST:
1791         case ICMD_IXORCONST:
1792         case ICMD_ISHLCONST:
1793         case ICMD_ISHRCONST:
1794         case ICMD_IUSHRCONST:
1795         case ICMD_LSHLCONST:
1796         case ICMD_LSHRCONST:
1797         case ICMD_LUSHRCONST:
1798         case ICMD_ICONST:
1799         case ICMD_IASTORECONST:
1800         case ICMD_BASTORECONST:
1801         case ICMD_CASTORECONST:
1802         case ICMD_SASTORECONST:
1803                 printf(" %d (0x%08x)", iptr->val.i, iptr->val.i);
1804                 break;
1805
1806         case ICMD_LADDCONST:
1807         case ICMD_LSUBCONST:
1808         case ICMD_LMULCONST:
1809         case ICMD_LMULPOW2:
1810         case ICMD_LDIVPOW2:
1811         case ICMD_LREMPOW2:
1812         case ICMD_LANDCONST:
1813         case ICMD_LORCONST:
1814         case ICMD_LXORCONST:
1815         case ICMD_LCONST:
1816         case ICMD_LASTORECONST:
1817 #if SIZEOF_VOID_P == 4
1818                 printf(" %lld (0x%016llx)", iptr->val.l, iptr->val.l);
1819 #else
1820                 printf(" %ld (0x%016lx)", iptr->val.l, iptr->val.l);
1821 #endif
1822                 break;
1823
1824         case ICMD_FCONST:
1825                 printf(" %f (0x%08x)", iptr->val.f, iptr->val.i);
1826                 break;
1827
1828         case ICMD_DCONST:
1829 #if SIZEOF_VOID_P == 4
1830                 printf(" %g (0x%016llx)", iptr->val.d, iptr->val.l);
1831 #else
1832                 printf(" %g (0x%016lx)", iptr->val.d, iptr->val.l);
1833 #endif
1834                 break;
1835
1836         case ICMD_ACONST:
1837         case ICMD_AASTORECONST:
1838                 /* check if this is a constant string or a class reference */
1839
1840                 if (ICMD_ACONST_IS_CLASS(iptr)) {
1841                         if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
1842                                 printf(" (NOT RESOLVED) classref = ");
1843                                 class_classref_print(ICMD_ACONST_UNRESOLVED_CLASSREF(iptr));
1844                         }
1845                         else {
1846                                 printf(" class = ");
1847                                 class_print(ICMD_ACONST_RESOLVED_CLASSINFO(iptr));
1848                         }
1849                 }
1850                 else {
1851                         printf(" %p", iptr->val.a);
1852
1853                         if (iptr->val.a) {
1854                                 printf(", String = \"");
1855                                 utf_display_printable_ascii(javastring_toutf(iptr->val.a, false));
1856                                 printf("\"");
1857                         }
1858                 }
1859                 break;
1860
1861         case ICMD_GETFIELD:
1862         case ICMD_PUTFIELD:
1863                 if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
1864                         uf = INSTRUCTION_UNRESOLVED_FIELD(iptr);
1865                         printf(" (NOT RESOLVED) ");
1866
1867                         field_fieldref_print(uf->fieldref);
1868                 }
1869                 else {
1870                         f = INSTRUCTION_RESOLVED_FIELDINFO(iptr);
1871                         printf(" %d, ", f->offset);
1872
1873                         field_print(f);
1874                 }
1875                 break;
1876
1877         case ICMD_PUTSTATIC:
1878         case ICMD_GETSTATIC:
1879                 if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
1880                         uf = INSTRUCTION_UNRESOLVED_FIELD(iptr);
1881                         printf(" (NOT RESOLVED) ");
1882
1883                         field_fieldref_print(uf->fieldref);
1884                 }
1885                 else {
1886                         f = INSTRUCTION_RESOLVED_FIELDINFO(iptr);
1887                         if (!CLASS_IS_OR_ALMOST_INITIALIZED(f->class))
1888                                 printf(" (NOT INITIALIZED) ");
1889                         else
1890                                 printf(" ");
1891
1892                         field_print(f);
1893                 }
1894                 break;
1895
1896         case ICMD_PUTSTATICCONST:
1897         case ICMD_PUTFIELDCONST:
1898                 switch (iptr[1].op1) {
1899                 case TYPE_INT:
1900                         printf(" %d (0x%08x),", iptr->val.i, iptr->val.i);
1901                         break;
1902                 case TYPE_LNG:
1903 #if SIZEOF_VOID_P == 4
1904                         printf(" %lld (0x%016llx),", iptr->val.l, iptr->val.l);
1905 #else
1906                         printf(" %ld (0x%016lx),", iptr->val.l, iptr->val.l);
1907 #endif
1908                         break;
1909                 case TYPE_ADR:
1910                         printf(" %p,", iptr->val.a);
1911                         break;
1912                 case TYPE_FLT:
1913                         printf(" %g (0x%08x),", iptr->val.f, iptr->val.i);
1914                         break;
1915                 case TYPE_DBL:
1916 #if SIZEOF_VOID_P == 4
1917                         printf(" %g (0x%016llx),", iptr->val.d, iptr->val.l);
1918 #else
1919                         printf(" %g (0x%016lx),", iptr->val.d, iptr->val.l);
1920 #endif
1921                         break;
1922                 }
1923
1924                 if (INSTRUCTION_IS_UNRESOLVED(iptr + 1)) {
1925                         uf = INSTRUCTION_UNRESOLVED_FIELD(iptr + 1);
1926                         printf(" (NOT RESOLVED) ");
1927                         field_fieldref_print(uf->fieldref);
1928                 }
1929                 else {
1930                         f = INSTRUCTION_RESOLVED_FIELDINFO(iptr + 1);
1931                         if ((iptr->opc == ICMD_PUTSTATICCONST) &&
1932                                 !CLASS_IS_OR_ALMOST_INITIALIZED(f->class))
1933                                 printf(" (NOT INITIALIZED), ");
1934                         else
1935                                 printf(" %d, ", f->offset);
1936                         field_print(f);
1937                 }
1938                 break;
1939
1940         case ICMD_IINC:
1941                 printf(" %d + %d", iptr->op1, iptr->val.i);
1942                 break;
1943
1944         case ICMD_IASTORE:
1945         case ICMD_SASTORE:
1946         case ICMD_BASTORE:
1947         case ICMD_CASTORE:
1948         case ICMD_LASTORE:
1949         case ICMD_DASTORE:
1950         case ICMD_FASTORE:
1951         case ICMD_AASTORE:
1952
1953         case ICMD_IALOAD:
1954         case ICMD_SALOAD:
1955         case ICMD_BALOAD:
1956         case ICMD_CALOAD:
1957         case ICMD_LALOAD:
1958         case ICMD_DALOAD:
1959         case ICMD_FALOAD:
1960         case ICMD_AALOAD:
1961                 if (iptr->op1 != 0)
1962                         printf("(opt.)");
1963                 break;
1964
1965         case ICMD_RET:
1966         case ICMD_ILOAD:
1967         case ICMD_LLOAD:
1968         case ICMD_FLOAD:
1969         case ICMD_DLOAD:
1970         case ICMD_ALOAD:
1971         case ICMD_ISTORE:
1972         case ICMD_LSTORE:
1973         case ICMD_FSTORE:
1974         case ICMD_DSTORE:
1975         case ICMD_ASTORE:
1976                 printf(" %d", iptr->op1);
1977                 break;
1978
1979         case ICMD_NEW:
1980                 c = iptr->val.a;
1981                 printf(" ");
1982                 utf_display_printable_ascii_classname(c->name);
1983                 break;
1984
1985         case ICMD_NEWARRAY:
1986                 switch (iptr->op1) {
1987                 case 4:
1988                         printf(" boolean");
1989                         break;
1990                 case 5:
1991                         printf(" char");
1992                         break;
1993                 case 6:
1994                         printf(" float");
1995                         break;
1996                 case 7:
1997                         printf(" double");
1998                         break;
1999                 case 8:
2000                         printf(" byte");
2001                         break;
2002                 case 9:
2003                         printf(" short");
2004                         break;
2005                 case 10:
2006                         printf(" int");
2007                         break;
2008                 case 11:
2009                         printf(" long");
2010                         break;
2011                 }
2012                 break;
2013
2014         case ICMD_ANEWARRAY:
2015                 if (iptr->op1) {
2016                         c = iptr->val.a;
2017                         printf(" ");
2018                         utf_display_printable_ascii_classname(c->name);
2019                 }
2020                 break;
2021
2022         case ICMD_MULTIANEWARRAY:
2023                 c  = iptr->val.a;
2024                 cr = iptr->target;
2025
2026                 if (c == NULL) {
2027                         printf(" (NOT RESOLVED) %d ", iptr->op1);
2028                         utf_display_printable_ascii(cr->name);
2029                 } 
2030                 else {
2031                         printf(" %d ", iptr->op1);
2032                         utf_display_printable_ascii_classname(c->name);
2033                 }
2034                 break;
2035
2036         case ICMD_CHECKCAST:
2037         case ICMD_INSTANCEOF:
2038                 c  = iptr->val.a;
2039                 cr = iptr->target;
2040
2041                 if (c) {
2042                         if (c->flags & ACC_INTERFACE)
2043                                 printf(" (INTERFACE) ");
2044                         else
2045                                 printf(" (CLASS,%3d) ", c->vftbl->diffval);
2046                 } else
2047                         printf(" (NOT RESOLVED) ");
2048                 utf_display_printable_ascii_classname(cr->name);
2049                 break;
2050
2051         case ICMD_INLINE_START:
2052         case ICMD_INLINE_END:
2053                 {
2054                         insinfo_inline *insinfo = (insinfo_inline *) iptr->target;
2055                         printf(" ");
2056                         method_print(insinfo->method);
2057                 }
2058                 break;
2059
2060         case ICMD_BUILTIN:
2061                 printf(" %s", ((builtintable_entry *) iptr->val.a)->name);
2062                 break;
2063
2064         case ICMD_INVOKEVIRTUAL:
2065         case ICMD_INVOKESPECIAL:
2066         case ICMD_INVOKESTATIC:
2067         case ICMD_INVOKEINTERFACE:
2068                 {
2069                         constant_FMIref *mref;
2070                         
2071                         if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
2072                                 printf(" (NOT RESOLVED) ");
2073                                 mref = INSTRUCTION_UNRESOLVED_METHOD(iptr)->methodref;
2074                         }
2075                         else {
2076                                 printf(" ");
2077                                 mref = INSTRUCTION_RESOLVED_FMIREF(iptr);
2078                         }
2079                         method_methodref_print(mref);
2080                 }
2081                 break;
2082
2083         case ICMD_IFEQ:
2084         case ICMD_IFNE:
2085         case ICMD_IFLT:
2086         case ICMD_IFGE:
2087         case ICMD_IFGT:
2088         case ICMD_IFLE:
2089                 printf(" %d (0x%08x)", iptr->val.i, iptr->val.i);
2090
2091 /*              if ((iptr->opc & ICMD_CONDITION_MASK) == 0) { */
2092                         if (deadcode || !iptr->target)
2093                                 printf(" op1=%d", iptr->op1);
2094                         else
2095                                 printf(" L%03d (%p)", ((basicblock *) iptr->target)->debug_nr, iptr->target);
2096 /*              } */
2097                 break;
2098
2099         case ICMD_IF_LEQ:
2100         case ICMD_IF_LNE:
2101         case ICMD_IF_LLT:
2102         case ICMD_IF_LGE:
2103         case ICMD_IF_LGT:
2104         case ICMD_IF_LLE:
2105 #if SIZEOF_VOID_P == 4
2106                 printf(" %lld (%016llx)", iptr->val.l, iptr->val.l);
2107 #else
2108                 printf(" %ld (%016lx)", iptr->val.l, iptr->val.l);
2109 #endif
2110
2111 /*              if ((iptr->opc & ICMD_CONDITION_MASK) == 0) { */
2112                         if (deadcode || !iptr->target)
2113                                 printf(" op1=%d", iptr->op1);
2114                         else
2115                                 printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
2116 /*              } */
2117                 break;
2118
2119         case ICMD_JSR:
2120         case ICMD_GOTO:
2121         case ICMD_INLINE_GOTO:
2122                 if (deadcode || !iptr->target)
2123                         printf(" op1=%d", iptr->op1);
2124                 else
2125                         printf(" L%03d (%p)", ((basicblock *) iptr->target)->debug_nr,iptr->target);
2126                 break;
2127
2128         case ICMD_IFNULL:
2129         case ICMD_IFNONNULL:
2130         case ICMD_IF_ICMPEQ:
2131         case ICMD_IF_ICMPNE:
2132         case ICMD_IF_ICMPLT:
2133         case ICMD_IF_ICMPGE:
2134         case ICMD_IF_ICMPGT:
2135         case ICMD_IF_ICMPLE:
2136
2137         case ICMD_IF_LCMPEQ:
2138         case ICMD_IF_LCMPNE:
2139         case ICMD_IF_LCMPLT:
2140         case ICMD_IF_LCMPGE:
2141         case ICMD_IF_LCMPGT:
2142         case ICMD_IF_LCMPLE:
2143
2144         case ICMD_IF_FCMPEQ:
2145         case ICMD_IF_FCMPNE:
2146
2147         case ICMD_IF_FCMPL_LT:
2148         case ICMD_IF_FCMPL_GE:
2149         case ICMD_IF_FCMPL_GT:
2150         case ICMD_IF_FCMPL_LE:
2151
2152         case ICMD_IF_FCMPG_LT:
2153         case ICMD_IF_FCMPG_GE:
2154         case ICMD_IF_FCMPG_GT:
2155         case ICMD_IF_FCMPG_LE:
2156
2157         case ICMD_IF_DCMPEQ:
2158         case ICMD_IF_DCMPNE:
2159
2160         case ICMD_IF_DCMPL_LT:
2161         case ICMD_IF_DCMPL_GE:
2162         case ICMD_IF_DCMPL_GT:
2163         case ICMD_IF_DCMPL_LE:
2164
2165         case ICMD_IF_DCMPG_LT:
2166         case ICMD_IF_DCMPG_GE:
2167         case ICMD_IF_DCMPG_GT:
2168         case ICMD_IF_DCMPG_LE:
2169
2170         case ICMD_IF_ACMPEQ:
2171         case ICMD_IF_ACMPNE:
2172 /*              if (!(iptr->opc & ICMD_CONDITION_MASK)) { */
2173                         if (deadcode || !iptr->target)
2174                                 printf(" op1=%d", iptr->op1);
2175                         else
2176                                 printf(" L%03d (%p)", ((basicblock *) iptr->target)->debug_nr,iptr->target);
2177 /*              } */
2178                 break;
2179
2180         case ICMD_TABLESWITCH:
2181                 s4ptr = (s4*)iptr->val.a;
2182
2183                 if (deadcode || !iptr->target) {
2184                         printf(" %d;", *s4ptr);
2185                 }
2186                 else {
2187                         tptr = (void **) iptr->target;
2188                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr); 
2189                         tptr++;
2190                 }
2191
2192                 s4ptr++;         /* skip default */
2193                 j = *s4ptr++;                               /* low     */
2194                 j = *s4ptr++ - j;                           /* high    */
2195                 while (j >= 0) {
2196                         if (deadcode || !*tptr)
2197                                 printf(" %d", *s4ptr++);
2198                         else {
2199                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2200                                 tptr++;
2201                         }
2202                         j--;
2203                 }
2204                 break;
2205
2206         case ICMD_LOOKUPSWITCH:
2207                 s4ptr = (s4*)iptr->val.a;
2208
2209                 if (deadcode || !iptr->target) {
2210                         printf(" %d;", *s4ptr);
2211                 }
2212                 else {
2213                         tptr = (void **) iptr->target;
2214                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
2215                         tptr++;
2216                 }
2217                 s4ptr++;                                         /* default */
2218                 j = *s4ptr++;                                    /* count   */
2219
2220                 while (--j >= 0) {
2221                         if (deadcode || !*tptr) {
2222                                 s4ptr++; /* skip value */
2223                                 printf(" %d",*s4ptr++);
2224                         }
2225                         else {
2226                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2227                                 tptr++;
2228                         }
2229                 }
2230                 break;
2231
2232         case ICMD_ARETURN:
2233                 if (iptr->val.a) {
2234                         printf(" (NOT RESOLVED) Class = \"");
2235                         utf_display_printable_ascii(((unresolved_class *) iptr->val.a)->classref->name);
2236                         printf("\"");
2237                 }
2238         }
2239 }
2240 #endif /* !defined(NDEBUG) */
2241
2242 /*
2243  * These are local overrides for various environment variables in Emacs.
2244  * Please do not remove this and leave it at the end of the file, where
2245  * Emacs will automagically detect them.
2246  * ---------------------------------------------------------------------
2247  * Local variables:
2248  * mode: c
2249  * indent-tabs-mode: t
2250  * c-basic-offset: 4
2251  * tab-width: 4
2252  * End:
2253  * vim:noexpandtab:sw=4:ts=4:
2254  */