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