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