* src/vm/jit/Makefile.am [!WITH_BINUTILS_DISASSEMBLER]
[cacao.git] / src / vm / jit / show.c
1 /* src/vm/jit/show.c - showing the intermediate representation
2
3    Copyright (C) 1996-2005, 2006, 2007 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    $Id$
26
27 */
28
29
30 #include "config.h"
31
32 #include <assert.h>
33
34 #include "vm/types.h"
35
36 #include "mm/memory.h"
37
38 #if defined(ENABLE_THREADS)
39 # include "threads/native/lock.h"
40 #else
41 # include "threads/none/lock.h"
42 #endif
43
44 #include "vm/global.h"
45 #include "vm/builtin.h"
46 #include "vm/stringlocal.h"
47
48 #include "vm/jit/abi.h"
49 #include "vm/jit/jit.h"
50 #include "vm/jit/show.h"
51 #include "vm/jit/disass.h"
52 #include "vm/jit/stack.h"
53 #include "vm/jit/parse.h"
54
55 #include "vmcore/options.h"
56
57
58 /* global variables ***********************************************************/
59
60 #if defined(ENABLE_THREADS) && !defined(NDEBUG)
61 static java_objectheader *show_global_lock;
62 #endif
63
64
65 /* prototypes *****************************************************************/
66
67 #if !defined(NDEBUG)
68 static void show_variable_intern(jitdata *jd, s4 index, int stage);
69 #endif
70
71
72 /* show_init *******************************************************************
73
74    Initialized the show subsystem (called by jit_init).
75
76 *******************************************************************************/
77
78 #if !defined(NDEBUG)
79 bool show_init(void)
80 {
81 #if defined(ENABLE_THREADS)
82         /* initialize the show lock */
83
84         show_global_lock = NEW(java_objectheader);
85
86         lock_init_object_lock(show_global_lock);
87 #endif
88
89         /* everything's ok */
90
91         return true;
92 }
93 #endif
94
95
96 #if !defined(NDEBUG)
97 char *show_jit_type_names[] = {
98         "INT",
99         "LNG",
100         "FLT",
101         "DBL",
102         "ADR",
103         "??5",
104         "??6",
105         "??7",
106         "RET"
107 };
108 char show_jit_type_letters[] = {
109         'I',
110         'L',
111         'F',
112         'D',
113         'A',
114         '5',
115         '6',
116         '7',
117         'R'
118 };
119 #endif
120
121
122 /* show_method *****************************************************************
123
124    Print the intermediate representation of a method.
125
126    NOTE: Currently this function may only be called after register allocation!
127
128 *******************************************************************************/
129
130 #if !defined(NDEBUG)
131 void show_method(jitdata *jd, int stage)
132 {
133         methodinfo     *m;
134         codeinfo       *code;
135         codegendata    *cd;
136         registerdata   *rd;
137         basicblock     *bptr;
138         basicblock     *lastbptr;
139         exception_entry *ex;
140         s4              i, j;
141         int             irstage;
142 #if defined(ENABLE_DISASSEMBLER)
143         u1             *pc;
144 #endif
145
146         /* get required compiler data */
147
148         m    = jd->m;
149         code = jd->code;
150         cd   = jd->cd;
151         rd   = jd->rd;
152
153         /* We need to enter a lock here, since the binutils disassembler
154            is not reentrant-able and we could not read functions printed
155            at the same time. */
156
157         LOCK_MONITOR_ENTER(show_global_lock);
158
159 #if defined(ENABLE_INTRP)
160         if (opt_intrp)
161                 irstage = SHOW_PARSE;
162         else
163 #endif
164                 irstage = stage;
165
166         /* get the last basic block */
167
168         for (lastbptr = jd->basicblocks; lastbptr->next != NULL; lastbptr = lastbptr->next);
169
170         printf("\n");
171
172         method_println(m);
173
174         if (jd->isleafmethod)
175                 printf("LEAFMETHOD\n");
176
177         printf("\nBasic blocks: %d\n", jd->basicblockcount);
178         if (stage >= SHOW_CODE) {
179                 printf("Code length:  %d\n", (lastbptr->mpc - jd->basicblocks[0].mpc));
180                 printf("Data length:  %d\n", cd->dseglen);
181                 printf("Stub length:  %d\n", (s4) (code->mcodelength -
182                                                                                    ((ptrint) cd->dseglen + lastbptr->mpc)));
183         }
184         printf("Variables:       %d (%d used)\n", jd->varcount, jd->vartop);
185         if (stage >= SHOW_STACK)
186                 printf("Max interfaces:  %d\n", jd->maxinterfaces);
187         printf("Max locals:      %d\n", jd->maxlocals);
188         printf("Max stack:       %d\n", m->maxstack);
189         printf("Linenumbers:     %d\n", m->linenumbercount);
190         printf("Branch to entry: %s\n", (jd->branchtoentry) ? "yes" : "no");
191         printf("Branch to end:   %s\n", (jd->branchtoend) ? "yes" : "no");
192         if (stage >= SHOW_STACK) {
193                 printf("Number of RETURNs: %d", jd->returncount);
194                 if (jd->returncount == 1)
195                         printf(" (block L%03d)", jd->returnblock->nr);
196                 printf("\n");
197         }
198
199         if (stage >= SHOW_PARSE) {
200                 printf("Exceptions (Number: %d):\n", jd->exceptiontablelength);
201                 for (ex = jd->exceptiontable; ex != NULL; ex = ex->down) {
202                         printf("    L%03d ... ", ex->start->nr );
203                         printf("L%03d  = ", ex->end->nr);
204                         printf("L%03d", ex->handler->nr);
205                         printf("  (catchtype: ");
206                         if (ex->catchtype.any)
207                                 if (IS_CLASSREF(ex->catchtype))
208                                         class_classref_print(ex->catchtype.ref);
209                                 else
210                                         class_print(ex->catchtype.cls);
211                         else
212                                 printf("ANY");
213                         printf(")\n");
214                 }
215         }
216         
217         if (irstage >= SHOW_PARSE && rd && jd->localcount > 0) {
218                 printf("Local Table:\n");
219                 for (i = 0; i < jd->localcount; i++) {
220                         printf("   %3d: ", i);
221
222 #if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
223 # if defined(ENABLE_INTRP)
224                         if (!opt_intrp) {
225 # endif
226                                 printf("   (%s) ", show_jit_type_names[VAR(i)->type]);
227                                 if (irstage >= SHOW_REGS)
228                                         show_allocation(VAR(i)->type, VAR(i)->flags, VAR(i)->vv.regoff);
229                                 printf("\n");
230 # if defined(ENABLE_INTRP)
231                         }
232 # endif
233 #endif /* defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER) */
234                 }
235                 printf("\n");
236         }
237
238         if (jd->maxlocals > 0 && jd->local_map != NULL) {
239                 printf("Local Map:\n");
240                 printf("    index ");
241                 for (j = 0; j < jd->maxlocals; j++) {
242                         printf(" [%2d]", j);
243                 }
244                 printf("\n");
245                 for (i = 0; i < 5; i++) {
246                         printf("    %5s ",show_jit_type_names[i]);
247                         for (j = 0; j < jd->maxlocals; j++) {
248                                 if (jd->local_map[j*5+i] == UNUSED)
249                                         printf("  -- ");
250                                 else
251                                         printf("%4i ",jd->local_map[j*5+i]);
252                         }
253                         printf("\n");
254                 }
255                 printf("\n");
256         }
257
258         if (jd->maxinterfaces > 0 && jd->interface_map && irstage >= SHOW_STACK) {
259                 bool exist = false;
260                 interface_info *mapptr = jd->interface_map;
261                 
262                 /* look if there exist any INOUTS */
263                 for (i = 0; (i < (5 * jd->maxinterfaces)) && !exist; i++, mapptr++)
264                         exist = (mapptr->flags != UNUSED);
265
266                 if (exist) {
267                         printf("Interface Table: (In/Outvars)\n");
268                         printf("    depth ");
269                         for (j = 0; j < jd->maxinterfaces; j++) {
270                                 printf("      [%2d]", j);
271                         }
272                         printf("\n");
273
274                         for (i = 0; i < 5; i++) {
275                                 printf("    %5s      ",show_jit_type_names[i]);
276                                 for (j = 0; j < jd->maxinterfaces; j++) {
277                                         s4 flags  = jd->interface_map[j*5+i].flags;
278                                         s4 regoff = jd->interface_map[j*5+i].regoff;
279                                         if (flags == UNUSED)
280                                                 printf("  --      ");
281                                         else {
282                                                 int ch;
283
284                                                 if (irstage >= SHOW_REGS) {
285                                                         if (flags & SAVEDVAR) {
286                                                                 if (flags & INMEMORY)
287                                                                         ch = 'M';
288                                                                 else
289                                                                         ch = 'R';
290                                                         }
291                                                         else {
292                                                                 if (flags & INMEMORY)
293                                                                         ch = 'm';
294                                                                 else
295                                                                         ch = 'r';
296                                                         }
297                                                         printf("%c%03d(", ch, regoff);
298                                                         show_allocation(i, flags, regoff);
299                                                         printf(") ");
300                                                 }
301                                                 else {
302                                                         if (flags & SAVEDVAR)
303                                                                 printf("  I       ");
304                                                         else
305                                                                 printf("  i       ");
306                                                 }
307                                         }
308                                 }
309                                 printf("\n");
310                         }
311                         printf("\n");
312                 }
313         }
314
315         if (rd->memuse && irstage >= SHOW_REGS) {
316                 int max;
317
318                 max = rd->memuse;
319                 printf("Stack slots: (memuse=%d", rd->memuse);
320                 if (irstage >= SHOW_CODE) {
321                         printf(", stackframesize=%d", cd->stackframesize);
322                         max = cd->stackframesize;
323                 }
324                 printf(")\n");
325                 for (i = 0; i < max; ++i) {
326 #if defined(HAS_4BYTE_STACKSLOT)
327                         printf("    M%02d = 0x%02x(sp): ", i, i * 4);
328 #else
329                         printf("    M%02d = 0x%02x(sp): ", i, i * 8);
330 #endif
331                         for (j = 0; j < jd->vartop; ++j) {
332                                 varinfo *v = VAR(j);
333                                 if ((v->flags & INMEMORY) && (v->vv.regoff == i)) {
334                                         show_variable(jd, j, irstage);
335                                         putchar(' ');
336                                 }
337                         }
338
339                         printf("\n");
340
341                 }
342                 printf("\n");
343         }
344
345 #if defined(ENABLE_REPLACEMENT)
346         if (code->rplpoints) {
347                 printf("Replacement Points:\n");
348                 replace_show_replacement_points(code);
349                 printf("\n");
350         }
351 #endif /* defined(ENABLE_REPLACEMENT) */
352
353 #if defined(ENABLE_DISASSEMBLER)
354         /* show code before first basic block */
355
356         if ((stage >= SHOW_CODE) && JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
357                 pc = (u1 *) ((ptrint) code->mcode + cd->dseglen);
358
359                 for (; pc < (u1 *) ((ptrint) code->mcode + cd->dseglen + jd->basicblocks[0].mpc);)
360                         DISASSINSTR(pc);
361
362                 printf("\n");
363         }
364 #endif
365
366         /* show code of all basic blocks */
367
368         for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next)
369                 show_basicblock(jd, bptr, stage);
370
371 #if defined(ENABLE_DISASSEMBLER)
372         /* show stubs code */
373
374         if (stage >= SHOW_CODE && opt_showdisassemble && opt_showexceptionstubs) {
375                 printf("\nStubs code:\n");
376                 printf("Length: %d\n\n", (s4) (code->mcodelength -
377                                                                            ((ptrint) cd->dseglen + lastbptr->mpc)));
378
379                 pc = (u1 *) ((ptrint) code->mcode + cd->dseglen + lastbptr->mpc);
380
381                 for (; (ptrint) pc < ((ptrint) code->mcode + code->mcodelength);)
382                         DISASSINSTR(pc);
383
384                 printf("\n");
385         }
386 #endif
387
388         LOCK_MONITOR_EXIT(show_global_lock);
389
390         /* finally flush the output */
391
392         fflush(stdout);
393 }
394 #endif /* !defined(NDEBUG) */
395
396
397 #if !defined(NDEBUG) && defined(ENABLE_INLINING)
398 static void show_inline_info(jitdata *jd, insinfo_inline *ii, s4 opcode, s4 stage)
399 {
400         s4 *jl;
401         s4 n;
402
403         printf("(pt %d+%d+%d st ", 
404                         ii->throughcount - (ii->stackvarscount - ii->paramcount),
405                         ii->stackvarscount - ii->paramcount,
406                         ii->paramcount);
407         show_variable_array(jd, ii->stackvars, ii->stackvarscount, stage);
408
409         if (opcode == ICMD_INLINE_START || opcode == ICMD_INLINE_END) {
410                 printf(" jl ");
411                 jl = (opcode == ICMD_INLINE_START) ? ii->javalocals_start : ii->javalocals_end;
412                 n = (opcode == ICMD_INLINE_START) ? ii->method->maxlocals : ii->outer->maxlocals;
413                 show_javalocals_array(jd, jl, n, stage);
414         }
415
416         printf(") ");
417
418 #if 0
419         printf("(");
420         method_print(ii->outer);
421         printf(" ==> ");
422 #endif
423
424         method_print(ii->method);
425 }
426 #endif /* !defined(NDEBUG) && defined(ENABLE_INLINING) */
427
428
429 /* show_basicblock *************************************************************
430
431    Print the intermediate representation of a basic block.
432
433    NOTE: Currently this function may only be called after register allocation!
434
435 *******************************************************************************/
436
437 #if !defined(NDEBUG)
438 void show_basicblock(jitdata *jd, basicblock *bptr, int stage)
439 {
440         codeinfo    *code;
441         codegendata *cd;
442         s4           i;
443         bool         deadcode;
444         instruction *iptr;
445         int          irstage;
446 #if defined(ENABLE_DISASSEMBLER)
447         methodinfo  *m;                     /* this is only a dummy               */
448         u1          *pc;
449         s4           linenumber;
450         s4           currentlinenumber;
451 #endif
452
453         /* get required compiler data */
454
455         code = jd->code;
456         cd   = jd->cd;
457
458         if (bptr->flags != BBDELETED) {
459 #if defined(ENABLE_INTRP)
460                 if (opt_intrp) {
461                         deadcode = false;
462                         irstage = SHOW_PARSE;
463                 }
464                 else
465 #endif
466                 {
467                         deadcode = (bptr->flags < BBREACHED);
468                         irstage = stage;
469                 }
470
471                 printf("======== %sL%03d ======== %s(flags: %d, bitflags: %01x, next: %d, type: ",
472 #if defined(ENABLE_REPLACEMENT)
473                                 (bptr->bitflags & BBFLAG_REPLACEMENT) ? "<REPLACE> " : 
474 #endif
475                                                                                                                 "",
476                            bptr->nr, 
477                            (deadcode && stage >= SHOW_STACK) ? "DEADCODE! " : "",
478                            bptr->flags, bptr->bitflags, 
479                            (bptr->next) ? (bptr->next->nr) : -1);
480
481                 switch (bptr->type) {
482                 case BBTYPE_STD:
483                         printf("STD");
484                         break;
485                 case BBTYPE_EXH:
486                         printf("EXH");
487                         break;
488                 case BBTYPE_SBR:
489                         printf("SBR");
490                         break;
491                 }
492
493                 printf(", icount: %d", bptr->icount);
494
495                 if (irstage >= SHOW_CFG) {
496                         printf(", preds: %d [ ", bptr->predecessorcount);
497
498                         for (i = 0; i < bptr->predecessorcount; i++)
499                                 printf("%d ", bptr->predecessors[i]->nr);
500
501                         printf("]");
502                 }
503
504                 printf("):");
505
506                 if (bptr->original)
507                         printf(" (clone of L%03d)", bptr->original->nr);
508                 else {
509                         basicblock *b = bptr->copied_to;
510                         if (b) {
511                                 printf(" (copied to ");
512                                 for (; b; b = b->copied_to)
513                                         printf("L%03d ", b->nr);
514                                 printf(")");
515                         }
516                 }
517
518                 printf("\n");
519
520                 if (irstage >= SHOW_STACK) {
521                         printf("IN:  ");
522                         show_variable_array(jd, bptr->invars, bptr->indepth, irstage);
523                         printf(" javalocals: ");
524                         show_javalocals_array(jd, bptr->javalocals, bptr->method->maxlocals, irstage);
525                         printf("\n");
526                 }
527
528 #if defined(ENABLE_INLINING)
529                 if (bptr->inlineinfo) {
530                         printf("inlineinfo: ");
531                         show_inline_info(jd, bptr->inlineinfo, -1, irstage);
532                         printf("\n");
533                 }
534 #endif /* defined(ENABLE_INLINING) */
535
536                 iptr = bptr->iinstr;
537
538                 for (i = 0; i < bptr->icount; i++, iptr++) {
539                         printf("%4d:%4d:  ", iptr->line, iptr->flags.bits >> INS_FLAG_ID_SHIFT);
540
541                         show_icmd(jd, iptr, deadcode, irstage);
542                         printf("\n");
543                 }
544
545                 if (irstage >= SHOW_STACK) {
546                         printf("OUT: ");
547                         show_variable_array(jd, bptr->outvars, bptr->outdepth, irstage);
548                         printf("\n");
549                 }
550
551 #if defined(ENABLE_DISASSEMBLER)
552                 if ((stage >= SHOW_CODE) && JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd) &&
553                         (!deadcode)) 
554                 {
555                         printf("\n");
556                         pc         = (u1 *) (code->mcode + cd->dseglen + bptr->mpc);
557                         linenumber = 0;
558
559                         if (bptr->next != NULL) {
560                                 for (; pc < (u1 *) (code->mcode + cd->dseglen + bptr->next->mpc);) {
561                                         currentlinenumber =
562                                                 dseg_get_linenumber_from_pc(&m, code->entrypoint, pc);
563
564                                         if (currentlinenumber != linenumber) {
565                                                 linenumber = currentlinenumber;
566                                                 printf("%4d:\n", linenumber);
567                                         }
568
569                                         DISASSINSTR(pc);
570                                 }
571                         }
572                         else {
573                                 for (; pc < (u1 *) (code->mcode + code->mcodelength);) {
574                                         currentlinenumber =
575                                                 dseg_get_linenumber_from_pc(&m, code->entrypoint, pc);
576
577                                         if (currentlinenumber != linenumber) {
578                                                 linenumber = currentlinenumber;
579                                                 printf("%4d:\n", linenumber);
580                                         }
581
582                                         DISASSINSTR(pc);
583                                 }
584                         }
585                         printf("\n");
586                 }
587 #endif
588         }
589 }
590 #endif /* !defined(NDEBUG) */
591
592
593 /* show_icmd *******************************************************************
594
595    Print the intermediate representation of an instruction.
596
597    NOTE: Currently this function may only be called after register allocation!
598
599 *******************************************************************************/
600
601 #if !defined(NDEBUG)
602
603 #define SHOW_TARGET(target)                                          \
604         if (stage >= SHOW_STACK) {                                   \
605             printf("--> L%03d ", (target).block->nr);                \
606         }                                                            \
607         else if (stage >= SHOW_PARSE) {                              \
608             printf("--> insindex %d (L%03d) ", (target).insindex,    \
609                 jd->basicblocks[jd->basicblockindex[         \
610                 (target).insindex]].nr);                             \
611         }                                                            \
612         else {                                                       \
613             printf("--> insindex %d ", (target).insindex);           \
614         }
615
616 #define SHOW_INT_CONST(val)                                          \
617         if (stage >= SHOW_PARSE) {                                   \
618             printf("%d (0x%08x) ", (val), (val));                    \
619         }                                                            \
620         else {                                                       \
621             printf("iconst ");                                       \
622         }
623
624 #if SIZEOF_VOID_P == 4
625 #define SHOW_LNG_CONST(val)                                          \
626         if (stage >= SHOW_PARSE)                                     \
627             printf("%lld (0x%016llx) ", (val), (val));               \
628         else                                                         \
629             printf("lconst ");
630 #else
631 #define SHOW_LNG_CONST(val)                                          \
632         if (stage >= SHOW_PARSE)                                     \
633             printf("%ld (0x%016lx) ", (val), (val));                 \
634         else                                                         \
635             printf("lconst ");
636 #endif
637
638 #if SIZEOF_VOID_P == 4
639 #define SHOW_ADR_CONST(val)                                          \
640         if (stage >= SHOW_PARSE)                                     \
641             printf("0x%08x ", (ptrint) (val));                       \
642         else                                                         \
643             printf("aconst ");
644 #else
645 #define SHOW_ADR_CONST(val)                                          \
646         if (stage >= SHOW_PARSE)                                     \
647             printf("0x%016lx ", (ptrint) (val));                     \
648         else                                                         \
649             printf("aconst ");
650 #endif
651
652 #define SHOW_FLT_CONST(val)                                          \
653         if (stage >= SHOW_PARSE) {                                   \
654             imm_union v;                                             \
655             v.f = (val);                                             \
656             printf("%g (0x%08x) ", (val), v.i);                      \
657         }                                                            \
658         else {                                                       \
659             printf("fconst ");                                       \
660         }
661
662 #if SIZEOF_VOID_P == 4
663 #define SHOW_DBL_CONST(val)                                          \
664         if (stage >= SHOW_PARSE) {                                   \
665             imm_union v;                                             \
666             v.d = (val);                                             \
667             printf("%g (0x%016llx) ", (val), v.l);                   \
668         }                                                            \
669         else                                                         \
670             printf("dconst ");
671 #else
672 #define SHOW_DBL_CONST(val)                                          \
673         if (stage >= SHOW_PARSE) {                                   \
674             imm_union v;                                             \
675             v.d = (val);                                             \
676             printf("%g (0x%016lx) ", (val), v.l);                    \
677         }                                                            \
678         else                                                         \
679             printf("dconst ");
680 #endif
681
682 #define SHOW_INDEX(index)                                            \
683         if (stage >= SHOW_PARSE) {                                   \
684             printf("%d ", index);                                    \
685         }                                                            \
686         else {                                                       \
687             printf("index");                                         \
688         }
689
690 #define SHOW_STRING(val)                                             \
691         if (stage >= SHOW_PARSE) {                                   \
692             putchar('"');                                            \
693             utf_display_printable_ascii(                             \
694                javastring_toutf((java_objectheader *)(val), false)); \
695             printf("\" ");                                           \
696         }                                                            \
697         else {                                                       \
698             printf("string ");                                       \
699         }
700
701 #define SHOW_CLASSREF_OR_CLASSINFO(c)                                \
702         if (stage >= SHOW_PARSE) {                                   \
703             if (IS_CLASSREF(c))                                      \
704                 class_classref_print(c.ref);                         \
705             else                                                     \
706                 class_print(c.cls);                                  \
707             putchar(' ');                                            \
708         }                                                            \
709         else {                                                       \
710             printf("class ");                                        \
711         }
712
713 #define SHOW_FIELD(fmiref)                                           \
714         if (stage >= SHOW_PARSE) {                                   \
715             field_fieldref_print(fmiref);                            \
716             putchar(' ');                                            \
717         }                                                            \
718         else {                                                       \
719             printf("field ");                                        \
720         }
721
722 #define SHOW_VARIABLE(v)                                             \
723     show_variable(jd, (v), stage)
724
725 #define SHOW_S1(iptr)                                                \
726         if (stage >= SHOW_STACK) {                                   \
727             SHOW_VARIABLE(iptr->s1.varindex);                        \
728         }
729
730 #define SHOW_S2(iptr)                                                \
731         if (stage >= SHOW_STACK) {                                   \
732             SHOW_VARIABLE(iptr->sx.s23.s2.varindex);                 \
733         }
734
735 #define SHOW_S3(iptr)                                                \
736     if (stage >= SHOW_STACK) {                                       \
737         SHOW_VARIABLE(iptr->sx.s23.s3.varindex);                     \
738     }
739
740 #define SHOW_DST(iptr)                                               \
741     if (stage >= SHOW_STACK) {                                       \
742         printf("=> ");                                               \
743         SHOW_VARIABLE(iptr->dst.varindex);                           \
744     }
745
746 #define SHOW_S1_LOCAL(iptr)                                          \
747     if (stage >= SHOW_STACK) {                                       \
748         printf("L%d ", iptr->s1.varindex);                           \
749     }                                                                \
750     else {                                                           \
751         printf("JavaL%d ", iptr->s1.varindex);                       \
752     }
753
754 #define SHOW_DST_LOCAL(iptr)                                         \
755     if (stage >= SHOW_STACK) {                                       \
756         printf("=> L%d ", iptr->dst.varindex);                       \
757     }                                                                \
758     else {                                                           \
759         printf("=> JavaL%d ", iptr->dst.varindex);                   \
760     }
761
762 void show_allocation(s4 type, s4 flags, s4 regoff)
763 {
764         if (type == TYPE_RET) {
765                 printf("N/A");
766                 return;
767         }
768
769         if (flags & INMEMORY) {
770                 printf("M%02d", regoff);
771                 return;
772         }
773
774 #ifdef HAS_ADDRESS_REGISTER_FILE
775         if (type == TYPE_ADR) {
776                 printf("R%02d", regoff);
777                 return;
778         }
779 #endif
780
781         if (IS_FLT_DBL_TYPE(type)) {
782                 printf("F%02d", regoff);
783                 return;
784         }
785
786 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
787         if (IS_2_WORD_TYPE(type)) {
788 # if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
789 #  if defined(ENABLE_INTRP)
790                 if (opt_intrp)
791                         printf("%3d/%3d", GET_LOW_REG(regoff),
792                                         GET_HIGH_REG(regoff));
793                 else
794 #  endif
795                         printf("%3s/%3s", abi_registers_integer_name[GET_LOW_REG(regoff)],
796                                    abi_registers_integer_name[GET_HIGH_REG(regoff)]);
797 # else
798                 printf("%3d/%3d", GET_LOW_REG(regoff),
799                            GET_HIGH_REG(regoff));
800 # endif
801                 return;
802         } 
803 #endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */
804
805 #if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
806 # if defined(ENABLE_INTRP)
807         if (opt_intrp)
808                 printf("%3d", regoff);
809         else
810 # endif
811                 printf("%3s", abi_registers_integer_name[regoff]);
812 #else
813         printf("%3d", regoff);
814 #endif
815 }
816
817 void show_variable(jitdata *jd, s4 index, int stage)
818 {
819         show_variable_intern(jd, index, stage);
820         putchar(' ');
821 }
822
823 static void show_variable_intern(jitdata *jd, s4 index, int stage)
824 {
825         char type;
826         char kind;
827         varinfo *v;
828
829         if (index < 0 || index >= jd->vartop) {
830                 printf("<INVALID INDEX:%d>", index);
831                 return;
832         }
833
834         v = VAR(index);
835
836         switch (v->type) {
837                 case TYPE_INT: type = 'i'; break;
838                 case TYPE_LNG: type = 'l'; break;
839                 case TYPE_FLT: type = 'f'; break;
840                 case TYPE_DBL: type = 'd'; break;
841                 case TYPE_ADR: type = 'a'; break;
842                 case TYPE_RET: type = 'r'; break;
843                 default:       type = '?';
844         }
845
846         if (index < jd->localcount) {
847                 kind = 'L';
848                 if (v->flags & (PREALLOC | INOUT))
849                                 printf("<INVALID FLAGS!>");
850         }
851         else {
852                 if (v->flags & PREALLOC) {
853                         kind = 'A';
854                         if (v->flags & INOUT) {
855                                 /* PREALLOC is used to avoid allocation of TYPE_RET */
856                                 if (v->type == TYPE_RET)
857                                         kind = 'i';
858                                 else
859                                         printf("<INVALID FLAGS!>");
860                         }
861                 }
862                 else if (v->flags & INOUT)
863                         kind = 'I';
864                 else
865                         kind = 'T';
866         }
867
868         printf("%c%c%d", kind, type, index);
869
870         if (v->flags & SAVEDVAR)
871                 putchar('!');
872
873         if (stage >= SHOW_REGS || (v->flags & PREALLOC)) {
874                 putchar('(');
875                 show_allocation(v->type, v->flags, v->vv.regoff);
876                 putchar(')');
877         }
878
879         if (v->type == TYPE_RET && (v->flags & PREALLOC)) {
880                 printf("(L%03d)", v->vv.retaddr->nr);
881         }
882 }
883
884 static void show_variable_array_intern(jitdata *jd, s4 *vars, int n, int stage,
885                                                                            bool javalocals)
886 {
887         int i;
888         int nr;
889
890         if (vars == NULL) {
891                 printf("<null>");
892                 return;
893         }
894
895         printf("[");
896         for (i=0; i<n; ++i) {
897                 if (i)
898                         putchar(' ');
899                 if (vars[i] < 0) {
900                         if (vars[i] == UNUSED)
901                                 putchar('-');
902                         else if (javalocals) {
903                                 nr = (UNUSED - vars[i]) - 1;
904                                 printf("ret(L%03d)", nr);
905                         }
906                         else {
907                                 printf("<INVALID INDEX:%d>", vars[i]);
908                         }
909                 }
910                 else
911                         show_variable_intern(jd, vars[i], stage);
912         }
913         printf("]");
914 }
915
916 void show_variable_array(jitdata *jd, s4 *vars, int n, int stage)
917 {
918         show_variable_array_intern(jd, vars, n, stage, false);
919 }
920
921 void show_javalocals_array(jitdata *jd, s4 *vars, int n, int stage)
922 {
923         show_variable_array_intern(jd, vars, n, stage, true);
924 }
925
926 void show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage)
927 {
928         u2                 opcode;
929         branch_target_t   *table;
930         lookup_target_t   *lookup;
931         constant_FMIref   *fmiref;
932         s4                *argp;
933         s4                 i;
934
935         /* get the opcode and the condition */
936
937         opcode    =  iptr->opc;
938
939         printf("%s ", icmd_table[opcode].name);
940
941         if (stage < SHOW_PARSE)
942                 return;
943
944         if (deadcode)
945                 stage = SHOW_PARSE;
946
947         /* Print the condition for conditional instructions. */
948
949         /* XXX print condition from flags */
950
951         if (iptr->flags.bits & INS_FLAG_UNRESOLVED)
952                 printf("(UNRESOLVED) ");
953
954         switch (opcode) {
955
956         case ICMD_POP:
957         case ICMD_CHECKNULL:
958                 SHOW_S1(iptr);
959                 break;
960
961                 /* unary */
962         case ICMD_ARRAYLENGTH:
963         case ICMD_INEG:
964         case ICMD_LNEG:
965         case ICMD_FNEG:
966         case ICMD_DNEG:
967         case ICMD_I2L:
968         case ICMD_I2F:
969         case ICMD_I2D:
970         case ICMD_L2I:
971         case ICMD_L2F:
972         case ICMD_L2D:
973         case ICMD_F2I:
974         case ICMD_F2L:
975         case ICMD_F2D:
976         case ICMD_D2I:
977         case ICMD_D2L:
978         case ICMD_D2F:
979         case ICMD_INT2BYTE:
980         case ICMD_INT2CHAR:
981         case ICMD_INT2SHORT:
982                 SHOW_S1(iptr);
983                 SHOW_DST(iptr);
984                 break;
985
986                 /* binary */
987         case ICMD_IADD:
988         case ICMD_LADD:
989         case ICMD_FADD:
990         case ICMD_DADD:
991         case ICMD_ISUB:
992         case ICMD_LSUB:
993         case ICMD_FSUB:
994         case ICMD_DSUB:
995         case ICMD_IMUL:
996         case ICMD_LMUL:
997         case ICMD_FMUL:
998         case ICMD_DMUL:
999         case ICMD_IDIV:
1000         case ICMD_LDIV:
1001         case ICMD_FDIV:
1002         case ICMD_DDIV:
1003         case ICMD_IREM:
1004         case ICMD_LREM:
1005         case ICMD_FREM:
1006         case ICMD_DREM:
1007         case ICMD_ISHL:
1008         case ICMD_LSHL:
1009         case ICMD_ISHR:
1010         case ICMD_LSHR:
1011         case ICMD_IUSHR:
1012         case ICMD_LUSHR:
1013         case ICMD_IAND:
1014         case ICMD_LAND:
1015         case ICMD_IOR:
1016         case ICMD_LOR:
1017         case ICMD_IXOR:
1018         case ICMD_LXOR:
1019         case ICMD_LCMP:
1020         case ICMD_FCMPL:
1021         case ICMD_FCMPG:
1022         case ICMD_DCMPL:
1023         case ICMD_DCMPG:
1024                 SHOW_S1(iptr);
1025                 SHOW_S2(iptr);
1026                 SHOW_DST(iptr);
1027                 break;
1028
1029                 /* binary/const INT */
1030         case ICMD_IADDCONST:
1031         case ICMD_ISUBCONST:
1032         case ICMD_IMULCONST:
1033         case ICMD_IMULPOW2:
1034         case ICMD_IDIVPOW2:
1035         case ICMD_IREMPOW2:
1036         case ICMD_IANDCONST:
1037         case ICMD_IORCONST:
1038         case ICMD_IXORCONST:
1039         case ICMD_ISHLCONST:
1040         case ICMD_ISHRCONST:
1041         case ICMD_IUSHRCONST:
1042         case ICMD_LSHLCONST:
1043         case ICMD_LSHRCONST:
1044         case ICMD_LUSHRCONST:
1045                 SHOW_S1(iptr);
1046                 SHOW_INT_CONST(iptr->sx.val.i); 
1047                 SHOW_DST(iptr);
1048                 break;
1049
1050                 /* ?ASTORECONST (trinary/const INT) */
1051         case ICMD_IASTORECONST:
1052         case ICMD_BASTORECONST:
1053         case ICMD_CASTORECONST:
1054         case ICMD_SASTORECONST:
1055                 SHOW_S1(iptr);
1056                 SHOW_S2(iptr);
1057                 SHOW_INT_CONST(iptr->sx.s23.s3.constval);
1058                 break;
1059
1060                 /* const INT */
1061         case ICMD_ICONST:
1062                 SHOW_INT_CONST(iptr->sx.val.i); 
1063                 SHOW_DST(iptr);
1064                 break;
1065
1066                 /* binary/const LNG */
1067         case ICMD_LADDCONST:
1068         case ICMD_LSUBCONST:
1069         case ICMD_LMULCONST:
1070         case ICMD_LMULPOW2:
1071         case ICMD_LDIVPOW2:
1072         case ICMD_LREMPOW2:
1073         case ICMD_LANDCONST:
1074         case ICMD_LORCONST:
1075         case ICMD_LXORCONST:
1076                 SHOW_S1(iptr);
1077                 SHOW_LNG_CONST(iptr->sx.val.l);
1078                 SHOW_DST(iptr);
1079                 break;
1080
1081                 /* trinary/const LNG (<= pointer size) */
1082         case ICMD_LASTORECONST:
1083                 SHOW_S1(iptr);
1084                 SHOW_S2(iptr);
1085                 SHOW_ADR_CONST(iptr->sx.s23.s3.constval);
1086                 break;
1087
1088                 /* const LNG */
1089         case ICMD_LCONST:
1090                 SHOW_LNG_CONST(iptr->sx.val.l); 
1091                 SHOW_DST(iptr);
1092                 break;
1093
1094                 /* const FLT */
1095         case ICMD_FCONST:
1096                 SHOW_FLT_CONST(iptr->sx.val.f); 
1097                 SHOW_DST(iptr);
1098                 break;
1099
1100                 /* const DBL */
1101         case ICMD_DCONST:
1102                 SHOW_DBL_CONST(iptr->sx.val.d); 
1103                 SHOW_DST(iptr);
1104                 break;
1105
1106                 /* const ADR */
1107         case ICMD_ACONST:
1108                 if (iptr->flags.bits & INS_FLAG_CLASS) {
1109                         SHOW_ADR_CONST(iptr->sx.val.anyptr);
1110                         SHOW_CLASSREF_OR_CLASSINFO(iptr->sx.val.c);
1111                 }
1112                 else if (iptr->sx.val.anyptr == NULL) {
1113                         printf("NULL ");
1114                 }
1115                 else {
1116                         SHOW_ADR_CONST(iptr->sx.val.anyptr);
1117                         SHOW_STRING(iptr->sx.val.stringconst);
1118                 }
1119                 SHOW_DST(iptr);
1120                 break;
1121
1122         case ICMD_AASTORECONST:
1123                 SHOW_S1(iptr);
1124                 SHOW_S2(iptr);
1125                 printf("%p ", (void*) iptr->sx.s23.s3.constval);
1126                 break;
1127
1128         case ICMD_GETFIELD:        /* 1 -> 1 */
1129         case ICMD_PUTFIELD:        /* 2 -> 0 */
1130         case ICMD_PUTSTATIC:       /* 1 -> 0 */
1131         case ICMD_GETSTATIC:       /* 0 -> 1 */
1132         case ICMD_PUTSTATICCONST:  /* 0 -> 0 */
1133         case ICMD_PUTFIELDCONST:   /* 1 -> 0 */
1134                 if (opcode != ICMD_GETSTATIC && opcode != ICMD_PUTSTATICCONST) {
1135                         SHOW_S1(iptr);
1136                         if (opcode == ICMD_PUTFIELD) {
1137                                 SHOW_S2(iptr);
1138                         }
1139                 }
1140                 INSTRUCTION_GET_FIELDREF(iptr, fmiref);
1141                 SHOW_FIELD(fmiref);
1142
1143                 if (opcode == ICMD_GETSTATIC || opcode == ICMD_GETFIELD) {
1144                         SHOW_DST(iptr);
1145                 }
1146                 break;
1147
1148         case ICMD_IINC:
1149                 SHOW_S1_LOCAL(iptr);
1150                 SHOW_INT_CONST(iptr->sx.val.i);
1151                 SHOW_DST_LOCAL(iptr);
1152                 break;
1153
1154         case ICMD_IASTORE:
1155         case ICMD_SASTORE:
1156         case ICMD_BASTORE:
1157         case ICMD_CASTORE:
1158         case ICMD_LASTORE:
1159         case ICMD_DASTORE:
1160         case ICMD_FASTORE:
1161         case ICMD_AASTORE:
1162                 SHOW_S1(iptr);
1163                 SHOW_S2(iptr);
1164                 SHOW_S3(iptr);
1165                 break;
1166
1167         case ICMD_IALOAD:
1168         case ICMD_SALOAD:
1169         case ICMD_BALOAD:
1170         case ICMD_CALOAD:
1171         case ICMD_LALOAD:
1172         case ICMD_DALOAD:
1173         case ICMD_FALOAD:
1174         case ICMD_AALOAD:
1175                 SHOW_S1(iptr);
1176                 SHOW_S2(iptr);
1177                 SHOW_DST(iptr);
1178                 break;
1179
1180         case ICMD_RET:
1181                 SHOW_S1_LOCAL(iptr);
1182                 if (stage >= SHOW_STACK) {
1183                         printf(" ---> L%03d", iptr->dst.block->nr);
1184                 }
1185                 break;
1186
1187         case ICMD_ILOAD:
1188         case ICMD_LLOAD:
1189         case ICMD_FLOAD:
1190         case ICMD_DLOAD:
1191         case ICMD_ALOAD:
1192                 SHOW_S1_LOCAL(iptr);
1193                 SHOW_DST(iptr);
1194                 break;
1195
1196         case ICMD_ISTORE:
1197         case ICMD_LSTORE:
1198         case ICMD_FSTORE:
1199         case ICMD_DSTORE:
1200         case ICMD_ASTORE:
1201                 SHOW_S1(iptr);
1202                 SHOW_DST_LOCAL(iptr);
1203                 if (stage >= SHOW_STACK && iptr->sx.s23.s3.javaindex != UNUSED)
1204                         printf(" (javaindex %d)", iptr->sx.s23.s3.javaindex);
1205                 if (iptr->flags.bits & INS_FLAG_RETADDR) {
1206                         printf(" (retaddr L%03d)", (UNUSED - iptr->sx.s23.s2.retaddrnr) - 1);
1207                 }
1208                 break;
1209
1210         case ICMD_NEW:
1211                 SHOW_DST(iptr);
1212                 break;
1213
1214         case ICMD_NEWARRAY:
1215                 SHOW_DST(iptr);
1216                 break;
1217
1218         case ICMD_ANEWARRAY:
1219                 SHOW_DST(iptr);
1220                 break;
1221
1222         case ICMD_MULTIANEWARRAY:
1223                 if (stage >= SHOW_STACK) {
1224                         argp = iptr->sx.s23.s2.args;
1225                         i = iptr->s1.argcount;
1226                         while (i--) {
1227                                 SHOW_VARIABLE(*(argp++));
1228                         }
1229                 }
1230                 else {
1231                         printf("argcount=%d ", iptr->s1.argcount);
1232                 }
1233                 SHOW_DST(iptr);
1234                 break;
1235
1236         case ICMD_CHECKCAST:
1237                 SHOW_S1(iptr);
1238                 putchar(' ');
1239                 class_classref_or_classinfo_print(iptr->sx.s23.s3.c);
1240                 SHOW_DST(iptr);
1241                 break;
1242
1243         case ICMD_INSTANCEOF:
1244                 SHOW_S1(iptr);
1245                 SHOW_DST(iptr);
1246                 break;
1247
1248         case ICMD_INLINE_START:
1249         case ICMD_INLINE_END:
1250         case ICMD_INLINE_BODY:
1251 #if defined(ENABLE_INLINING)
1252                 {
1253                         insinfo_inline *ii = iptr->sx.s23.s3.inlineinfo;
1254                         show_inline_info(jd, ii, opcode, stage);
1255                 }
1256 #endif
1257                 break;
1258
1259         case ICMD_BUILTIN:
1260                 if (stage >= SHOW_STACK) {
1261                         argp = iptr->sx.s23.s2.args;
1262                         i = iptr->s1.argcount;
1263                         while (i--) {
1264                                 if ((iptr->s1.argcount - 1 - i) == iptr->sx.s23.s3.bte->md->paramcount)
1265                                         printf(" pass-through: ");
1266                                 SHOW_VARIABLE(*(argp++));
1267                         }
1268                 }
1269                 printf("%s ", iptr->sx.s23.s3.bte->cname);
1270                 if (iptr->sx.s23.s3.bte->md->returntype.type != TYPE_VOID) {
1271                         SHOW_DST(iptr);
1272                 }
1273                 break;
1274
1275         case ICMD_INVOKEVIRTUAL:
1276         case ICMD_INVOKESPECIAL:
1277         case ICMD_INVOKESTATIC:
1278         case ICMD_INVOKEINTERFACE:
1279                 if (stage >= SHOW_STACK) {
1280                         methoddesc *md;
1281                         INSTRUCTION_GET_METHODDESC(iptr, md);
1282                         argp = iptr->sx.s23.s2.args;
1283                         i = iptr->s1.argcount;
1284                         while (i--) {
1285                                 if ((iptr->s1.argcount - 1 - i) == md->paramcount)
1286                                         printf(" pass-through: ");
1287                                 SHOW_VARIABLE(*(argp++));
1288                         }
1289                 }
1290                 INSTRUCTION_GET_METHODREF(iptr, fmiref);
1291                 method_methodref_print(fmiref);
1292                 if (fmiref->parseddesc.md->returntype.type != TYPE_VOID) {
1293                         putchar(' ');
1294                         SHOW_DST(iptr);
1295                 }
1296                 break;
1297
1298         case ICMD_IFEQ:
1299         case ICMD_IFNE:
1300         case ICMD_IFLT:
1301         case ICMD_IFGE:
1302         case ICMD_IFGT:
1303         case ICMD_IFLE:
1304                 SHOW_S1(iptr);
1305                 SHOW_INT_CONST(iptr->sx.val.i); 
1306                 SHOW_TARGET(iptr->dst);
1307                 break;
1308
1309         case ICMD_IF_LEQ:
1310         case ICMD_IF_LNE:
1311         case ICMD_IF_LLT:
1312         case ICMD_IF_LGE:
1313         case ICMD_IF_LGT:
1314         case ICMD_IF_LLE:
1315                 SHOW_S1(iptr);
1316                 SHOW_LNG_CONST(iptr->sx.val.l); 
1317                 SHOW_TARGET(iptr->dst);
1318                 break;
1319
1320         case ICMD_GOTO:
1321                 SHOW_TARGET(iptr->dst);
1322                 break;
1323
1324         case ICMD_JSR:
1325                 SHOW_TARGET(iptr->sx.s23.s3.jsrtarget);
1326                 SHOW_DST(iptr);
1327                 break;
1328
1329         case ICMD_IFNULL:
1330         case ICMD_IFNONNULL:
1331                 SHOW_S1(iptr);
1332                 SHOW_TARGET(iptr->dst);
1333                 break;
1334
1335         case ICMD_IF_ICMPEQ:
1336         case ICMD_IF_ICMPNE:
1337         case ICMD_IF_ICMPLT:
1338         case ICMD_IF_ICMPGE:
1339         case ICMD_IF_ICMPGT:
1340         case ICMD_IF_ICMPLE:
1341
1342         case ICMD_IF_LCMPEQ:
1343         case ICMD_IF_LCMPNE:
1344         case ICMD_IF_LCMPLT:
1345         case ICMD_IF_LCMPGE:
1346         case ICMD_IF_LCMPGT:
1347         case ICMD_IF_LCMPLE:
1348
1349         case ICMD_IF_FCMPEQ:
1350         case ICMD_IF_FCMPNE:
1351
1352         case ICMD_IF_FCMPL_LT:
1353         case ICMD_IF_FCMPL_GE:
1354         case ICMD_IF_FCMPL_GT:
1355         case ICMD_IF_FCMPL_LE:
1356
1357         case ICMD_IF_FCMPG_LT:
1358         case ICMD_IF_FCMPG_GE:
1359         case ICMD_IF_FCMPG_GT:
1360         case ICMD_IF_FCMPG_LE:
1361
1362         case ICMD_IF_DCMPEQ:
1363         case ICMD_IF_DCMPNE:
1364
1365         case ICMD_IF_DCMPL_LT:
1366         case ICMD_IF_DCMPL_GE:
1367         case ICMD_IF_DCMPL_GT:
1368         case ICMD_IF_DCMPL_LE:
1369
1370         case ICMD_IF_DCMPG_LT:
1371         case ICMD_IF_DCMPG_GE:
1372         case ICMD_IF_DCMPG_GT:
1373         case ICMD_IF_DCMPG_LE:
1374
1375         case ICMD_IF_ACMPEQ:
1376         case ICMD_IF_ACMPNE:
1377                 SHOW_S1(iptr);
1378                 SHOW_S2(iptr);
1379                 SHOW_TARGET(iptr->dst);
1380                 break;
1381
1382         case ICMD_TABLESWITCH:
1383                 SHOW_S1(iptr);
1384                 table = iptr->dst.table;
1385
1386                 i = iptr->sx.s23.s3.tablehigh - iptr->sx.s23.s2.tablelow + 1;
1387
1388                 printf("high=%d low=%d count=%d\n", iptr->sx.s23.s3.tablehigh, iptr->sx.s23.s2.tablelow, i);
1389                 while (--i >= 0) {
1390                         printf("\t\t%d --> ", (int) (table - iptr->dst.table));
1391                         if (stage >= SHOW_STACK) {
1392                                 printf("L%03d\n", table->block->nr);
1393                         }
1394                         else {
1395                                 printf("insindex %d (L%03d)\n", table->insindex, BLOCK_OF(table->insindex)->nr);
1396                         }
1397                         table++;
1398                 }
1399
1400                 break;
1401
1402         case ICMD_LOOKUPSWITCH:
1403                 SHOW_S1(iptr);
1404
1405                 printf("count=%d, default=", iptr->sx.s23.s2.lookupcount);
1406                 if (stage >= SHOW_STACK) {
1407                         printf("L%03d\n", iptr->sx.s23.s3.lookupdefault.block->nr);
1408                 }
1409                 else {
1410                         printf("insindex %d (L%03d)\n", iptr->sx.s23.s3.lookupdefault.insindex, BLOCK_OF(iptr->sx.s23.s3.lookupdefault.insindex)->nr);
1411                 }
1412
1413                 lookup = iptr->dst.lookup;
1414                 i = iptr->sx.s23.s2.lookupcount;
1415                 while (--i >= 0) {
1416                         printf("\t\t%d --> ", lookup->value);
1417                         if (stage >= SHOW_STACK) {
1418                                 printf("L%03d\n", lookup->target.block->nr);
1419                         }
1420                         else {
1421                                 printf("insindex %d (L%03d)\n", lookup->target.insindex, BLOCK_OF(lookup->target.insindex)->nr);
1422                         }
1423                         lookup++;
1424                 }
1425                 break;
1426
1427         case ICMD_FRETURN:
1428         case ICMD_IRETURN:
1429         case ICMD_DRETURN:
1430         case ICMD_LRETURN:
1431                 SHOW_S1(iptr);
1432                 break;
1433
1434         case ICMD_ARETURN:
1435         case ICMD_ATHROW:
1436                 SHOW_S1(iptr);
1437                 if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
1438                         /* XXX this needs more work */
1439 #if 0
1440                         unresolved_class_debug_dump(iptr->sx.s23.s2.uc, stdout);
1441 #endif
1442                 }
1443                 break;
1444
1445         case ICMD_COPY:
1446         case ICMD_MOVE:
1447                 SHOW_S1(iptr);
1448                 SHOW_DST(iptr);
1449                 break;
1450         }
1451         fflush(stdout);
1452 }
1453 #endif /* !defined(NDEBUG) */
1454
1455
1456 /*
1457  * These are local overrides for various environment variables in Emacs.
1458  * Please do not remove this and leave it at the end of the file, where
1459  * Emacs will automagically detect them.
1460  * ---------------------------------------------------------------------
1461  * Local variables:
1462  * mode: c
1463  * indent-tabs-mode: t
1464  * c-basic-offset: 4
1465  * tab-width: 4
1466  * End:
1467  * vim:noexpandtab:sw=4:ts=4:
1468  */