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