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