* src/vm/jit/show.c (new_show_stackvar): Show varkind and varnum for
[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         switch (opcode) {
1244
1245         case ICMD_POP:
1246         case ICMD_CHECKNULL:
1247         case ICMD_CHECKNULL_POP:
1248                 SHOW_S1(iptr);
1249                 break;
1250
1251                 /* unary */
1252         case ICMD_ARRAYLENGTH:
1253         case ICMD_INEG:
1254         case ICMD_LNEG:
1255         case ICMD_FNEG:
1256         case ICMD_DNEG:
1257         case ICMD_I2L:
1258         case ICMD_I2F:
1259         case ICMD_I2D:
1260         case ICMD_L2I:
1261         case ICMD_L2F:
1262         case ICMD_L2D:
1263         case ICMD_F2I:
1264         case ICMD_F2L:
1265         case ICMD_F2D:
1266         case ICMD_D2I:
1267         case ICMD_D2L:
1268         case ICMD_D2F:
1269         case ICMD_INT2BYTE:
1270         case ICMD_INT2CHAR:
1271         case ICMD_INT2SHORT:
1272                 SHOW_S1(iptr);
1273                 SHOW_DST(iptr);
1274                 break;
1275
1276                 /* binary */
1277         case ICMD_IADD:
1278         case ICMD_LADD:
1279         case ICMD_FADD:
1280         case ICMD_DADD:
1281         case ICMD_ISUB:
1282         case ICMD_LSUB:
1283         case ICMD_FSUB:
1284         case ICMD_DSUB:
1285         case ICMD_IMUL:
1286         case ICMD_LMUL:
1287         case ICMD_FMUL:
1288         case ICMD_DMUL:
1289         case ICMD_IDIV:
1290         case ICMD_LDIV:
1291         case ICMD_FDIV:
1292         case ICMD_DDIV:
1293         case ICMD_IREM:
1294         case ICMD_LREM:
1295         case ICMD_FREM:
1296         case ICMD_DREM:
1297         case ICMD_ISHL:
1298         case ICMD_LSHL:
1299         case ICMD_ISHR:
1300         case ICMD_LSHR:
1301         case ICMD_IUSHR:
1302         case ICMD_LUSHR:
1303         case ICMD_IAND:
1304         case ICMD_LAND:
1305         case ICMD_IOR:
1306         case ICMD_LOR:
1307         case ICMD_IXOR:
1308         case ICMD_LXOR:
1309         case ICMD_LCMP:
1310         case ICMD_FCMPL:
1311         case ICMD_FCMPG:
1312         case ICMD_DCMPL:
1313         case ICMD_DCMPG:
1314                 SHOW_S1(iptr);
1315                 SHOW_S2(iptr);
1316                 SHOW_DST(iptr);
1317                 break;
1318
1319                 /* binary/const INT */
1320         case ICMD_IADDCONST:
1321         case ICMD_ISUBCONST:
1322         case ICMD_IMULCONST:
1323         case ICMD_IMULPOW2:
1324         case ICMD_IDIVPOW2:
1325         case ICMD_IREMPOW2:
1326         case ICMD_IANDCONST:
1327         case ICMD_IORCONST:
1328         case ICMD_IXORCONST:
1329         case ICMD_ISHLCONST:
1330         case ICMD_ISHRCONST:
1331         case ICMD_IUSHRCONST:
1332         case ICMD_LSHLCONST:
1333         case ICMD_LSHRCONST:
1334         case ICMD_LUSHRCONST:
1335                 SHOW_S1(iptr);
1336                 SHOW_INT_CONST(iptr->sx.val.i); 
1337                 SHOW_DST(iptr);
1338                 break;
1339
1340                 /* ?ASTORECONST */
1341         case ICMD_IASTORECONST:
1342         case ICMD_BASTORECONST:
1343         case ICMD_CASTORECONST:
1344         case ICMD_SASTORECONST:
1345                 SHOW_S1(iptr);
1346                 SHOW_S2(iptr);
1347                 SHOW_INT_CONST(iptr->sx.s23.s3.constval);
1348                 break;
1349
1350                 /* const INT */
1351         case ICMD_ICONST:
1352                 SHOW_INT_CONST(iptr->sx.val.i); 
1353                 SHOW_DST(iptr);
1354                 break;
1355
1356         case ICMD_IFEQ_ICONST:
1357         case ICMD_IFNE_ICONST:
1358         case ICMD_IFLT_ICONST:
1359         case ICMD_IFGE_ICONST:
1360         case ICMD_IFGT_ICONST:
1361         case ICMD_IFLE_ICONST:
1362                 break;
1363
1364         case ICMD_ELSE_ICONST:
1365                 break;
1366
1367                 /* binary/const LNG */
1368         case ICMD_LADDCONST:
1369         case ICMD_LSUBCONST:
1370         case ICMD_LMULCONST:
1371         case ICMD_LMULPOW2:
1372         case ICMD_LDIVPOW2:
1373         case ICMD_LREMPOW2:
1374         case ICMD_LANDCONST:
1375         case ICMD_LORCONST:
1376         case ICMD_LXORCONST:
1377         case ICMD_LASTORECONST:
1378                 SHOW_S1(iptr);
1379                 SHOW_LNG_CONST(iptr->sx.val.l); 
1380                 SHOW_DST(iptr);
1381                 break;
1382
1383                 /* const LNG */
1384         case ICMD_LCONST:
1385                 SHOW_LNG_CONST(iptr->sx.val.l); 
1386                 SHOW_DST(iptr);
1387                 break;
1388
1389                 /* const FLT */
1390         case ICMD_FCONST:
1391                 SHOW_FLT_CONST(iptr->sx.val.f); 
1392                 SHOW_DST(iptr);
1393                 break;
1394
1395                 /* const DBL */
1396         case ICMD_DCONST:
1397                 SHOW_DBL_CONST(iptr->sx.val.d); 
1398                 SHOW_DST(iptr);
1399                 break;
1400
1401                 /* const ADR */
1402         case ICMD_ACONST:
1403                 if (iptr->flags.bits & INS_FLAG_CLASS) {
1404                         SHOW_CLASSREF_OR_CLASSINFO(iptr->sx.val.c);
1405                 }
1406                 else if (iptr->sx.val.anyptr == NULL) {
1407                         printf("NULL ");
1408                 }
1409                 else {
1410                         SHOW_STRING(iptr->sx.val.stringconst);
1411                 }
1412                 SHOW_DST(iptr);
1413                 break;
1414
1415         case ICMD_AASTORECONST:
1416                 SHOW_S1(iptr);
1417                 SHOW_S2(iptr);
1418                 printf("%p ", (void*) iptr->sx.s23.s3.constval);
1419                 break;
1420
1421         case ICMD_GETFIELD:        /* 1 -> 1 */
1422         case ICMD_PUTFIELD:        /* 2 -> 0 */
1423         case ICMD_PUTSTATIC:       /* 1 -> 0 */
1424         case ICMD_GETSTATIC:       /* 0 -> 1 */
1425         case ICMD_PUTSTATICCONST:  /* 0 -> 0 */
1426         case ICMD_PUTFIELDCONST:   /* 1 -> 0 */
1427                 if (opcode != ICMD_GETSTATIC && opcode != ICMD_PUTSTATICCONST) {
1428                         SHOW_S1(iptr);
1429                         if (opcode == ICMD_PUTFIELD) {
1430                                 SHOW_S2(iptr);
1431                         }
1432                 }
1433                 if (iptr->flags.bits & INS_FLAG_UNRESOLVED)
1434                         printf("(UNRESOLVED) ");
1435                 NEW_INSTRUCTION_GET_FIELDREF(iptr, fmiref);
1436                 SHOW_FIELD(fmiref);
1437
1438                 if (opcode == ICMD_GETSTATIC || opcode == ICMD_GETFIELD) {
1439                         SHOW_DST(iptr);
1440                 }
1441                 break;
1442
1443         case ICMD_IINC:
1444                 SHOW_S1_LOCAL(iptr);
1445                 SHOW_INT_CONST(iptr->sx.val.i);
1446                 SHOW_DST_LOCAL(iptr);
1447                 break;
1448
1449         case ICMD_IASTORE:
1450         case ICMD_SASTORE:
1451         case ICMD_BASTORE:
1452         case ICMD_CASTORE:
1453         case ICMD_LASTORE:
1454         case ICMD_DASTORE:
1455         case ICMD_FASTORE:
1456         case ICMD_AASTORE:
1457                 SHOW_S1(iptr);
1458                 SHOW_S2(iptr);
1459                 SHOW_S3(iptr);
1460                 break;
1461
1462         case ICMD_IALOAD:
1463         case ICMD_SALOAD:
1464         case ICMD_BALOAD:
1465         case ICMD_CALOAD:
1466         case ICMD_LALOAD:
1467         case ICMD_DALOAD:
1468         case ICMD_FALOAD:
1469         case ICMD_AALOAD:
1470                 SHOW_S1(iptr);
1471                 SHOW_S2(iptr);
1472                 SHOW_DST(iptr);
1473                 break;
1474
1475         case ICMD_RET:
1476                 SHOW_S1_LOCAL(iptr);
1477                 break;
1478
1479         case ICMD_ILOAD:
1480         case ICMD_LLOAD:
1481         case ICMD_FLOAD:
1482         case ICMD_DLOAD:
1483         case ICMD_ALOAD:
1484                 SHOW_S1_LOCAL(iptr);
1485                 SHOW_DST(iptr);
1486                 break;
1487
1488         case ICMD_ISTORE:
1489         case ICMD_LSTORE:
1490         case ICMD_FSTORE:
1491         case ICMD_DSTORE:
1492         case ICMD_ASTORE:
1493                 SHOW_S1(iptr);
1494                 SHOW_DST_LOCAL(iptr);
1495                 break;
1496
1497         case ICMD_NEW:
1498                 SHOW_DST(iptr);
1499                 break;
1500
1501         case ICMD_NEWARRAY:
1502                 SHOW_DST(iptr);
1503                 break;
1504
1505         case ICMD_ANEWARRAY:
1506                 SHOW_DST(iptr);
1507                 break;
1508
1509         case ICMD_MULTIANEWARRAY:
1510                 if (stage >= SHOW_STACK) {
1511                         argp = iptr->sx.s23.s2.args;
1512                         i = iptr->s1.argcount;
1513                         while (i--) {
1514                                 SHOW_STACKVAR(*(argp++));
1515                         }
1516                 }
1517                 else {
1518                         printf("argcount=%d ", iptr->s1.argcount);
1519                 }
1520                 SHOW_DST(iptr);
1521                 break;
1522
1523         case ICMD_CHECKCAST:
1524                 SHOW_S1(iptr);
1525                 SHOW_DST(iptr);
1526                 break;
1527
1528         case ICMD_INSTANCEOF:
1529                 SHOW_S1(iptr);
1530                 SHOW_DST(iptr);
1531                 break;
1532
1533         case ICMD_INLINE_START:
1534         case ICMD_INLINE_END:
1535                 break;
1536
1537         case ICMD_BUILTIN:
1538                 if (stage >= SHOW_STACK) {
1539                         argp = iptr->sx.s23.s2.args;
1540                         i = iptr->s1.argcount;
1541                         while (i--) {
1542                                 SHOW_STACKVAR(*(argp++));
1543                         }
1544                 }
1545                 printf("%s ", iptr->sx.s23.s3.bte->name);
1546                 if (iptr->sx.s23.s3.bte->md->returntype.type != TYPE_VOID) {
1547                         SHOW_DST(iptr);
1548                 }
1549                 break;
1550
1551         case ICMD_INVOKEVIRTUAL:
1552         case ICMD_INVOKESPECIAL:
1553         case ICMD_INVOKESTATIC:
1554         case ICMD_INVOKEINTERFACE:
1555                 if (stage >= SHOW_STACK) {
1556                         argp = iptr->sx.s23.s2.args;
1557                         i = iptr->s1.argcount;
1558                         while (i--) {
1559                                 SHOW_STACKVAR(*(argp++));
1560                         }
1561                 }
1562                 if (iptr->flags.bits & INS_FLAG_UNRESOLVED) {
1563                         printf("(UNRESOLVED) ");
1564                 }
1565                 NEW_INSTRUCTION_GET_METHODREF(iptr, fmiref);
1566                 method_methodref_print(fmiref);
1567                 if (fmiref->parseddesc.md->returntype.type != TYPE_VOID) {
1568                         SHOW_DST(iptr);
1569                 }
1570                 break;
1571
1572         case ICMD_IFEQ:
1573         case ICMD_IFNE:
1574         case ICMD_IFLT:
1575         case ICMD_IFGE:
1576         case ICMD_IFGT:
1577         case ICMD_IFLE:
1578                 SHOW_S1(iptr);
1579                 SHOW_TARGET(iptr->dst);
1580                 break;
1581
1582         case ICMD_IF_LEQ:
1583         case ICMD_IF_LNE:
1584         case ICMD_IF_LLT:
1585         case ICMD_IF_LGE:
1586         case ICMD_IF_LGT:
1587         case ICMD_IF_LLE:
1588                 SHOW_S1(iptr);
1589                 SHOW_TARGET(iptr->dst);
1590                 break;
1591
1592         case ICMD_GOTO:
1593         case ICMD_INLINE_GOTO:
1594                 SHOW_TARGET(iptr->dst);
1595                 break;
1596
1597         case ICMD_JSR:
1598                 SHOW_TARGET(iptr->sx.s23.s3.jsrtarget);
1599                 SHOW_DST(iptr);
1600                 break;
1601
1602         case ICMD_IFNULL:
1603         case ICMD_IFNONNULL:
1604                 SHOW_S1(iptr);
1605                 SHOW_TARGET(iptr->dst);
1606                 break;
1607
1608         case ICMD_IF_ICMPEQ:
1609         case ICMD_IF_ICMPNE:
1610         case ICMD_IF_ICMPLT:
1611         case ICMD_IF_ICMPGE:
1612         case ICMD_IF_ICMPGT:
1613         case ICMD_IF_ICMPLE:
1614
1615         case ICMD_IF_LCMPEQ:
1616         case ICMD_IF_LCMPNE:
1617         case ICMD_IF_LCMPLT:
1618         case ICMD_IF_LCMPGE:
1619         case ICMD_IF_LCMPGT:
1620         case ICMD_IF_LCMPLE:
1621
1622         case ICMD_IF_FCMPEQ:
1623         case ICMD_IF_FCMPNE:
1624
1625         case ICMD_IF_FCMPL_LT:
1626         case ICMD_IF_FCMPL_GE:
1627         case ICMD_IF_FCMPL_GT:
1628         case ICMD_IF_FCMPL_LE:
1629
1630         case ICMD_IF_FCMPG_LT:
1631         case ICMD_IF_FCMPG_GE:
1632         case ICMD_IF_FCMPG_GT:
1633         case ICMD_IF_FCMPG_LE:
1634
1635         case ICMD_IF_DCMPEQ:
1636         case ICMD_IF_DCMPNE:
1637
1638         case ICMD_IF_DCMPL_LT:
1639         case ICMD_IF_DCMPL_GE:
1640         case ICMD_IF_DCMPL_GT:
1641         case ICMD_IF_DCMPL_LE:
1642
1643         case ICMD_IF_DCMPG_LT:
1644         case ICMD_IF_DCMPG_GE:
1645         case ICMD_IF_DCMPG_GT:
1646         case ICMD_IF_DCMPG_LE:
1647
1648         case ICMD_IF_ACMPEQ:
1649         case ICMD_IF_ACMPNE:
1650                 SHOW_S1(iptr);
1651                 SHOW_S2(iptr);
1652                 SHOW_TARGET(iptr->dst);
1653                 break;
1654
1655         case ICMD_TABLESWITCH:
1656                 SHOW_S1(iptr);
1657                 break;
1658
1659         case ICMD_LOOKUPSWITCH:
1660                 SHOW_S1(iptr);
1661                 break;
1662
1663         case ICMD_ARETURN:
1664                 SHOW_S1(iptr);
1665                 break;
1666
1667         case ICMD_ATHROW:
1668                 SHOW_S1(iptr);
1669                 break;
1670
1671         case ICMD_DUP:
1672                 SHOW_S1(iptr);
1673                 SHOW_DST(iptr);
1674                 break;
1675
1676         case ICMD_DUP2:
1677                 if (stage >= SHOW_STACK) {
1678                         SHOW_STACKVAR(iptr->dst.dupslots[0]);
1679                         SHOW_STACKVAR(iptr->dst.dupslots[1]);
1680                         printf("=> ");
1681                         SHOW_STACKVAR(iptr->dst.dupslots[2+0]);
1682                         SHOW_STACKVAR(iptr->dst.dupslots[2+1]);
1683                 }
1684                 break;
1685
1686         case ICMD_DUP_X1:
1687                 if (stage >= SHOW_STACK) {
1688                         SHOW_STACKVAR(iptr->dst.dupslots[0]);
1689                         SHOW_STACKVAR(iptr->dst.dupslots[1]);
1690                         printf("=> ");
1691                         SHOW_STACKVAR(iptr->dst.dupslots[2+0]);
1692                         SHOW_STACKVAR(iptr->dst.dupslots[2+1]);
1693                         SHOW_STACKVAR(iptr->dst.dupslots[2+2]);
1694                 }
1695                 break;
1696
1697         case ICMD_DUP2_X1:
1698                 if (stage >= SHOW_STACK) {
1699                         SHOW_STACKVAR(iptr->dst.dupslots[0]);
1700                         SHOW_STACKVAR(iptr->dst.dupslots[1]);
1701                         SHOW_STACKVAR(iptr->dst.dupslots[2]);
1702                         printf("=> ");
1703                         SHOW_STACKVAR(iptr->dst.dupslots[3+0]);
1704                         SHOW_STACKVAR(iptr->dst.dupslots[3+1]);
1705                         SHOW_STACKVAR(iptr->dst.dupslots[3+2]);
1706                         SHOW_STACKVAR(iptr->dst.dupslots[3+3]);
1707                         SHOW_STACKVAR(iptr->dst.dupslots[3+4]);
1708                 }
1709                 break;
1710
1711         case ICMD_DUP_X2:
1712                 if (stage >= SHOW_STACK) {
1713                         SHOW_STACKVAR(iptr->dst.dupslots[0]);
1714                         SHOW_STACKVAR(iptr->dst.dupslots[1]);
1715                         SHOW_STACKVAR(iptr->dst.dupslots[2]);
1716                         printf("=> ");
1717                         SHOW_STACKVAR(iptr->dst.dupslots[3+0]);
1718                         SHOW_STACKVAR(iptr->dst.dupslots[3+1]);
1719                         SHOW_STACKVAR(iptr->dst.dupslots[3+2]);
1720                         SHOW_STACKVAR(iptr->dst.dupslots[3+3]);
1721                 }
1722                 break;
1723
1724         case ICMD_DUP2_X2:
1725                 if (stage >= SHOW_STACK) {
1726                         SHOW_STACKVAR(iptr->dst.dupslots[0]);
1727                         SHOW_STACKVAR(iptr->dst.dupslots[1]);
1728                         SHOW_STACKVAR(iptr->dst.dupslots[2]);
1729                         SHOW_STACKVAR(iptr->dst.dupslots[4]);
1730                         printf("=> ");
1731                         SHOW_STACKVAR(iptr->dst.dupslots[4+0]);
1732                         SHOW_STACKVAR(iptr->dst.dupslots[4+1]);
1733                         SHOW_STACKVAR(iptr->dst.dupslots[4+2]);
1734                         SHOW_STACKVAR(iptr->dst.dupslots[4+3]);
1735                         SHOW_STACKVAR(iptr->dst.dupslots[4+4]);
1736                         SHOW_STACKVAR(iptr->dst.dupslots[4+5]);
1737                 }
1738                 break;
1739
1740         case ICMD_SWAP:
1741                 if (stage >= SHOW_STACK) {
1742                         SHOW_STACKVAR(iptr->dst.dupslots[0]);
1743                         SHOW_STACKVAR(iptr->dst.dupslots[1]);
1744                         printf("=> ");
1745                         SHOW_STACKVAR(iptr->dst.dupslots[2+0]);
1746                         SHOW_STACKVAR(iptr->dst.dupslots[2+1]);
1747                 }
1748                 break;
1749
1750         }
1751 }
1752 #endif /* !defined(NDEBUG) */
1753
1754 #if !defined(NDEBUG)
1755 void show_icmd(instruction *iptr, bool deadcode)
1756 {
1757 #if 0
1758         u2                 opcode;
1759         u2                 condition;
1760 #endif
1761         int j;
1762         s4  *s4ptr;
1763         void **tptr = NULL;
1764         classinfo         *c;
1765         fieldinfo         *f;
1766         constant_classref *cr;
1767         unresolved_field  *uf;
1768
1769 #if 0
1770         /* get the opcode and the condition */
1771
1772         opcode    =  iptr->opc & ICMD_OPCODE_MASK;
1773         condition = (iptr->opc & ICMD_CONDITION_MASK) >> 8;
1774
1775         /* Print the condition for conditional instructions. */
1776
1777         if (condition != 0)
1778                 printf(" (condition: %s)", icmd_names[condition]);
1779 #endif
1780
1781         printf("%s", icmd_names[iptr->opc]);
1782
1783         switch (iptr->opc) {
1784         case ICMD_IADDCONST:
1785         case ICMD_ISUBCONST:
1786         case ICMD_IMULCONST:
1787         case ICMD_IMULPOW2:
1788         case ICMD_IDIVPOW2:
1789         case ICMD_IREMPOW2:
1790         case ICMD_IANDCONST:
1791         case ICMD_IORCONST:
1792         case ICMD_IXORCONST:
1793         case ICMD_ISHLCONST:
1794         case ICMD_ISHRCONST:
1795         case ICMD_IUSHRCONST:
1796         case ICMD_LSHLCONST:
1797         case ICMD_LSHRCONST:
1798         case ICMD_LUSHRCONST:
1799         case ICMD_ICONST:
1800         case ICMD_IASTORECONST:
1801         case ICMD_BASTORECONST:
1802         case ICMD_CASTORECONST:
1803         case ICMD_SASTORECONST:
1804                 printf(" %d (0x%08x)", iptr->val.i, iptr->val.i);
1805                 break;
1806
1807         case ICMD_IFEQ_ICONST:
1808         case ICMD_IFNE_ICONST:
1809         case ICMD_IFLT_ICONST:
1810         case ICMD_IFGE_ICONST:
1811         case ICMD_IFGT_ICONST:
1812         case ICMD_IFLE_ICONST:
1813                 printf(" %d, %d (0x%08x)", iptr[1].op1, iptr->val.i, iptr->val.i);
1814                 break;
1815
1816         case ICMD_ELSE_ICONST:
1817                 printf("    %d (0x%08x)", iptr->val.i, iptr->val.i);
1818                 break;
1819
1820         case ICMD_LADDCONST:
1821         case ICMD_LSUBCONST:
1822         case ICMD_LMULCONST:
1823         case ICMD_LMULPOW2:
1824         case ICMD_LDIVPOW2:
1825         case ICMD_LREMPOW2:
1826         case ICMD_LANDCONST:
1827         case ICMD_LORCONST:
1828         case ICMD_LXORCONST:
1829         case ICMD_LCONST:
1830         case ICMD_LASTORECONST:
1831 #if SIZEOF_VOID_P == 4
1832                 printf(" %lld (0x%016llx)", iptr->val.l, iptr->val.l);
1833 #else
1834                 printf(" %ld (0x%016lx)", iptr->val.l, iptr->val.l);
1835 #endif
1836                 break;
1837
1838         case ICMD_FCONST:
1839                 printf(" %f (0x%08x)", iptr->val.f, iptr->val.i);
1840                 break;
1841
1842         case ICMD_DCONST:
1843 #if SIZEOF_VOID_P == 4
1844                 printf(" %g (0x%016llx)", iptr->val.d, iptr->val.l);
1845 #else
1846                 printf(" %g (0x%016lx)", iptr->val.d, iptr->val.l);
1847 #endif
1848                 break;
1849
1850         case ICMD_ACONST:
1851         case ICMD_AASTORECONST:
1852                 /* check if this is a constant string or a class reference */
1853
1854                 if (ICMD_ACONST_IS_CLASS(iptr)) {
1855                         if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
1856                                 printf(" (NOT RESOLVED) classref = ");
1857                                 class_classref_print(ICMD_ACONST_UNRESOLVED_CLASSREF(iptr));
1858                         }
1859                         else {
1860                                 printf(" class = ");
1861                                 class_print(ICMD_ACONST_RESOLVED_CLASSINFO(iptr));
1862                         }
1863                 }
1864                 else {
1865                         printf(" %p", iptr->val.a);
1866
1867                         if (iptr->val.a) {
1868                                 printf(", String = \"");
1869                                 utf_display_printable_ascii(javastring_toutf(iptr->val.a, false));
1870                                 printf("\"");
1871                         }
1872                 }
1873                 break;
1874
1875         case ICMD_GETFIELD:
1876         case ICMD_PUTFIELD:
1877                 if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
1878                         uf = INSTRUCTION_UNRESOLVED_FIELD(iptr);
1879                         printf(" (NOT RESOLVED) ");
1880
1881                         field_fieldref_print(uf->fieldref);
1882                 }
1883                 else {
1884                         f = INSTRUCTION_RESOLVED_FIELDINFO(iptr);
1885                         printf(" %d, ", f->offset);
1886
1887                         field_print(f);
1888                 }
1889                 break;
1890
1891         case ICMD_PUTSTATIC:
1892         case ICMD_GETSTATIC:
1893                 if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
1894                         uf = INSTRUCTION_UNRESOLVED_FIELD(iptr);
1895                         printf(" (NOT RESOLVED) ");
1896
1897                         field_fieldref_print(uf->fieldref);
1898                 }
1899                 else {
1900                         f = INSTRUCTION_RESOLVED_FIELDINFO(iptr);
1901                         if (!CLASS_IS_OR_ALMOST_INITIALIZED(f->class))
1902                                 printf(" (NOT INITIALIZED) ");
1903                         else
1904                                 printf(" ");
1905
1906                         field_print(f);
1907                 }
1908                 break;
1909
1910         case ICMD_PUTSTATICCONST:
1911         case ICMD_PUTFIELDCONST:
1912                 switch (iptr[1].op1) {
1913                 case TYPE_INT:
1914                         printf(" %d (0x%08x),", iptr->val.i, iptr->val.i);
1915                         break;
1916                 case TYPE_LNG:
1917 #if SIZEOF_VOID_P == 4
1918                         printf(" %lld (0x%016llx),", iptr->val.l, iptr->val.l);
1919 #else
1920                         printf(" %ld (0x%016lx),", iptr->val.l, iptr->val.l);
1921 #endif
1922                         break;
1923                 case TYPE_ADR:
1924                         printf(" %p,", iptr->val.a);
1925                         break;
1926                 case TYPE_FLT:
1927                         printf(" %g (0x%08x),", iptr->val.f, iptr->val.i);
1928                         break;
1929                 case TYPE_DBL:
1930 #if SIZEOF_VOID_P == 4
1931                         printf(" %g (0x%016llx),", iptr->val.d, iptr->val.l);
1932 #else
1933                         printf(" %g (0x%016lx),", iptr->val.d, iptr->val.l);
1934 #endif
1935                         break;
1936                 }
1937
1938                 if (INSTRUCTION_IS_UNRESOLVED(iptr + 1)) {
1939                         uf = INSTRUCTION_UNRESOLVED_FIELD(iptr + 1);
1940                         printf(" (NOT RESOLVED) ");
1941                         field_fieldref_print(uf->fieldref);
1942                 }
1943                 else {
1944                         f = INSTRUCTION_RESOLVED_FIELDINFO(iptr + 1);
1945                         if ((iptr->opc == ICMD_PUTSTATICCONST) &&
1946                                 !CLASS_IS_OR_ALMOST_INITIALIZED(f->class))
1947                                 printf(" (NOT INITIALIZED), ");
1948                         else
1949                                 printf(" %d, ", f->offset);
1950                         field_print(f);
1951                 }
1952                 break;
1953
1954         case ICMD_IINC:
1955                 printf(" %d + %d", iptr->op1, iptr->val.i);
1956                 break;
1957
1958         case ICMD_IASTORE:
1959         case ICMD_SASTORE:
1960         case ICMD_BASTORE:
1961         case ICMD_CASTORE:
1962         case ICMD_LASTORE:
1963         case ICMD_DASTORE:
1964         case ICMD_FASTORE:
1965         case ICMD_AASTORE:
1966
1967         case ICMD_IALOAD:
1968         case ICMD_SALOAD:
1969         case ICMD_BALOAD:
1970         case ICMD_CALOAD:
1971         case ICMD_LALOAD:
1972         case ICMD_DALOAD:
1973         case ICMD_FALOAD:
1974         case ICMD_AALOAD:
1975                 if (iptr->op1 != 0)
1976                         printf("(opt.)");
1977                 break;
1978
1979         case ICMD_RET:
1980         case ICMD_ILOAD:
1981         case ICMD_LLOAD:
1982         case ICMD_FLOAD:
1983         case ICMD_DLOAD:
1984         case ICMD_ALOAD:
1985         case ICMD_ISTORE:
1986         case ICMD_LSTORE:
1987         case ICMD_FSTORE:
1988         case ICMD_DSTORE:
1989         case ICMD_ASTORE:
1990                 printf(" %d", iptr->op1);
1991                 break;
1992
1993         case ICMD_NEW:
1994                 c = iptr->val.a;
1995                 printf(" ");
1996                 utf_display_printable_ascii_classname(c->name);
1997                 break;
1998
1999         case ICMD_NEWARRAY:
2000                 switch (iptr->op1) {
2001                 case 4:
2002                         printf(" boolean");
2003                         break;
2004                 case 5:
2005                         printf(" char");
2006                         break;
2007                 case 6:
2008                         printf(" float");
2009                         break;
2010                 case 7:
2011                         printf(" double");
2012                         break;
2013                 case 8:
2014                         printf(" byte");
2015                         break;
2016                 case 9:
2017                         printf(" short");
2018                         break;
2019                 case 10:
2020                         printf(" int");
2021                         break;
2022                 case 11:
2023                         printf(" long");
2024                         break;
2025                 }
2026                 break;
2027
2028         case ICMD_ANEWARRAY:
2029                 if (iptr->op1) {
2030                         c = iptr->val.a;
2031                         printf(" ");
2032                         utf_display_printable_ascii_classname(c->name);
2033                 }
2034                 break;
2035
2036         case ICMD_MULTIANEWARRAY:
2037                 c  = iptr->val.a;
2038                 cr = iptr->target;
2039
2040                 if (c == NULL) {
2041                         printf(" (NOT RESOLVED) %d ", iptr->op1);
2042                         utf_display_printable_ascii(cr->name);
2043                 } 
2044                 else {
2045                         printf(" %d ", iptr->op1);
2046                         utf_display_printable_ascii_classname(c->name);
2047                 }
2048                 break;
2049
2050         case ICMD_CHECKCAST:
2051         case ICMD_INSTANCEOF:
2052                 c  = iptr->val.a;
2053                 cr = iptr->target;
2054
2055                 if (c) {
2056                         if (c->flags & ACC_INTERFACE)
2057                                 printf(" (INTERFACE) ");
2058                         else
2059                                 printf(" (CLASS,%3d) ", c->vftbl->diffval);
2060                 } else
2061                         printf(" (NOT RESOLVED) ");
2062                 utf_display_printable_ascii_classname(cr->name);
2063                 break;
2064
2065         case ICMD_INLINE_START:
2066         case ICMD_INLINE_END:
2067                 {
2068                         insinfo_inline *insinfo = (insinfo_inline *) iptr->target;
2069                         printf(" ");
2070                         method_print(insinfo->method);
2071                 }
2072                 break;
2073
2074         case ICMD_BUILTIN:
2075                 printf(" %s", ((builtintable_entry *) iptr->val.a)->name);
2076                 break;
2077
2078         case ICMD_INVOKEVIRTUAL:
2079         case ICMD_INVOKESPECIAL:
2080         case ICMD_INVOKESTATIC:
2081         case ICMD_INVOKEINTERFACE:
2082                 {
2083                         constant_FMIref *mref;
2084                         
2085                         if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
2086                                 printf(" (NOT RESOLVED) ");
2087                                 mref = INSTRUCTION_UNRESOLVED_METHOD(iptr)->methodref;
2088                         }
2089                         else {
2090                                 printf(" ");
2091                                 mref = INSTRUCTION_RESOLVED_FMIREF(iptr);
2092                         }
2093                         method_methodref_print(mref);
2094                 }
2095                 break;
2096
2097         case ICMD_IFEQ:
2098         case ICMD_IFNE:
2099         case ICMD_IFLT:
2100         case ICMD_IFGE:
2101         case ICMD_IFGT:
2102         case ICMD_IFLE:
2103                 printf(" %d (0x%08x)", iptr->val.i, iptr->val.i);
2104
2105 /*              if ((iptr->opc & ICMD_CONDITION_MASK) == 0) { */
2106                         if (deadcode || !iptr->target)
2107                                 printf(" op1=%d", iptr->op1);
2108                         else
2109                                 printf(" L%03d (%p)", ((basicblock *) iptr->target)->debug_nr, iptr->target);
2110 /*              } */
2111                 break;
2112
2113         case ICMD_IF_LEQ:
2114         case ICMD_IF_LNE:
2115         case ICMD_IF_LLT:
2116         case ICMD_IF_LGE:
2117         case ICMD_IF_LGT:
2118         case ICMD_IF_LLE:
2119 #if SIZEOF_VOID_P == 4
2120                 printf(" %lld (%016llx)", iptr->val.l, iptr->val.l);
2121 #else
2122                 printf(" %ld (%016lx)", iptr->val.l, iptr->val.l);
2123 #endif
2124
2125 /*              if ((iptr->opc & ICMD_CONDITION_MASK) == 0) { */
2126                         if (deadcode || !iptr->target)
2127                                 printf(" op1=%d", iptr->op1);
2128                         else
2129                                 printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
2130 /*              } */
2131                 break;
2132
2133         case ICMD_JSR:
2134         case ICMD_GOTO:
2135         case ICMD_INLINE_GOTO:
2136                 if (deadcode || !iptr->target)
2137                         printf(" op1=%d", iptr->op1);
2138                 else
2139                         printf(" L%03d (%p)", ((basicblock *) iptr->target)->debug_nr,iptr->target);
2140                 break;
2141
2142         case ICMD_IFNULL:
2143         case ICMD_IFNONNULL:
2144         case ICMD_IF_ICMPEQ:
2145         case ICMD_IF_ICMPNE:
2146         case ICMD_IF_ICMPLT:
2147         case ICMD_IF_ICMPGE:
2148         case ICMD_IF_ICMPGT:
2149         case ICMD_IF_ICMPLE:
2150
2151         case ICMD_IF_LCMPEQ:
2152         case ICMD_IF_LCMPNE:
2153         case ICMD_IF_LCMPLT:
2154         case ICMD_IF_LCMPGE:
2155         case ICMD_IF_LCMPGT:
2156         case ICMD_IF_LCMPLE:
2157
2158         case ICMD_IF_FCMPEQ:
2159         case ICMD_IF_FCMPNE:
2160
2161         case ICMD_IF_FCMPL_LT:
2162         case ICMD_IF_FCMPL_GE:
2163         case ICMD_IF_FCMPL_GT:
2164         case ICMD_IF_FCMPL_LE:
2165
2166         case ICMD_IF_FCMPG_LT:
2167         case ICMD_IF_FCMPG_GE:
2168         case ICMD_IF_FCMPG_GT:
2169         case ICMD_IF_FCMPG_LE:
2170
2171         case ICMD_IF_DCMPEQ:
2172         case ICMD_IF_DCMPNE:
2173
2174         case ICMD_IF_DCMPL_LT:
2175         case ICMD_IF_DCMPL_GE:
2176         case ICMD_IF_DCMPL_GT:
2177         case ICMD_IF_DCMPL_LE:
2178
2179         case ICMD_IF_DCMPG_LT:
2180         case ICMD_IF_DCMPG_GE:
2181         case ICMD_IF_DCMPG_GT:
2182         case ICMD_IF_DCMPG_LE:
2183
2184         case ICMD_IF_ACMPEQ:
2185         case ICMD_IF_ACMPNE:
2186 /*              if (!(iptr->opc & ICMD_CONDITION_MASK)) { */
2187                         if (deadcode || !iptr->target)
2188                                 printf(" op1=%d", iptr->op1);
2189                         else
2190                                 printf(" L%03d (%p)", ((basicblock *) iptr->target)->debug_nr,iptr->target);
2191 /*              } */
2192                 break;
2193
2194         case ICMD_TABLESWITCH:
2195                 s4ptr = (s4*)iptr->val.a;
2196
2197                 if (deadcode || !iptr->target) {
2198                         printf(" %d;", *s4ptr);
2199                 }
2200                 else {
2201                         tptr = (void **) iptr->target;
2202                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr); 
2203                         tptr++;
2204                 }
2205
2206                 s4ptr++;         /* skip default */
2207                 j = *s4ptr++;                               /* low     */
2208                 j = *s4ptr++ - j;                           /* high    */
2209                 while (j >= 0) {
2210                         if (deadcode || !*tptr)
2211                                 printf(" %d", *s4ptr++);
2212                         else {
2213                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2214                                 tptr++;
2215                         }
2216                         j--;
2217                 }
2218                 break;
2219
2220         case ICMD_LOOKUPSWITCH:
2221                 s4ptr = (s4*)iptr->val.a;
2222
2223                 if (deadcode || !iptr->target) {
2224                         printf(" %d;", *s4ptr);
2225                 }
2226                 else {
2227                         tptr = (void **) iptr->target;
2228                         printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
2229                         tptr++;
2230                 }
2231                 s4ptr++;                                         /* default */
2232                 j = *s4ptr++;                                    /* count   */
2233
2234                 while (--j >= 0) {
2235                         if (deadcode || !*tptr) {
2236                                 s4ptr++; /* skip value */
2237                                 printf(" %d",*s4ptr++);
2238                         }
2239                         else {
2240                                 printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
2241                                 tptr++;
2242                         }
2243                 }
2244                 break;
2245
2246         case ICMD_ARETURN:
2247                 if (iptr->val.a) {
2248                         printf(" (NOT RESOLVED) Class = \"");
2249                         utf_display_printable_ascii(((unresolved_class *) iptr->val.a)->classref->name);
2250                         printf("\"");
2251                 }
2252         }
2253 }
2254 #endif /* !defined(NDEBUG) */
2255
2256 /*
2257  * These are local overrides for various environment variables in Emacs.
2258  * Please do not remove this and leave it at the end of the file, where
2259  * Emacs will automagically detect them.
2260  * ---------------------------------------------------------------------
2261  * Local variables:
2262  * mode: c
2263  * indent-tabs-mode: t
2264  * c-basic-offset: 4
2265  * tab-width: 4
2266  * End:
2267  * vim:noexpandtab:sw=4:ts=4:
2268  */