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