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