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