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