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