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