* src/vm/jit/show.c (new_show_method): Fix display of local table.
[cacao.git] / src / vm / jit / show.c
index 0dab461f9103ca078773794c0cd837abd7823b01..1489a462a394d244b98b102bac1e5c920fc0ba4a 100644 (file)
@@ -55,6 +55,7 @@
 #include "vm/jit/jit.h"
 #include "vm/jit/show.h"
 #include "vm/jit/disass.h"
+#include "vm/jit/stack.h"
 
 
 /* global variables ***********************************************************/
@@ -67,7 +68,9 @@ static java_objectheader *show_global_lock;
 /* forward declarations *******************************************************/
 
 #if !defined(NDEBUG)
-static void new_show_variable_array(jitdata *jd, stackptr *vars, int n, int stage);
+static void new_show_variable_array(jitdata *jd, s4 *vars, int n, int stage);
+static void show_allocation(s4 type, s4 flags, s4 regoff);
+static void show_variable(jitdata *jd, s4 index, int stage);
 #endif
 
 
@@ -97,11 +100,11 @@ bool show_init(void)
 
 #if !defined(NDEBUG)
 static char *jit_type[] = {
-       "int",
-       "lng",
-       "flt",
-       "dbl",
-       "adr"
+       "INT",
+       "LNG",
+       "FLT",
+       "DBL",
+       "ADR"
 };
 #endif
 
@@ -149,6 +152,8 @@ void new_show_method(jitdata *jd, int stage)
        method_println(m);
 
        printf("\n(NEW INSTRUCTION FORMAT)\n");
+       if (jd->isleafmethod)
+               printf("LEAFMETHOD\n");
        printf("\nBasic blocks: %d\n", jd->new_basicblockcount);
        if (stage >= SHOW_CODE) {
                printf("Code length:  %d\n", (lastbptr->mpc - jd->new_basicblocks[0].mpc));
@@ -178,134 +183,120 @@ void new_show_method(jitdata *jd, int stage)
                }
        }
        
-       if (stage >= SHOW_PARSE && rd) {
-       printf("Local Table:\n");
-       for (i = 0; i < cd->maxlocals; i++) {
-               printf("   %3d: ", i);
+       if (stage >= SHOW_PARSE && rd && jd->localcount > 0) {
+               printf("Local Table:\n");
+               for (i = 0; i < jd->localcount; i++) {
+                       printf("   %3d: ", i);
 
 #if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
-               for (j = TYPE_INT; j <= TYPE_ADR; j++) {
 # if defined(ENABLE_INTRP)
                        if (!opt_intrp) {
 # endif
-                               if (rd->locals[i][j].type >= 0) {
-                                       printf("   (%s) ", jit_type[j]);
-                                       if (stage >= SHOW_REGS) {
-                                               if (rd->locals[i][j].flags & INMEMORY)
-                                                       printf("m%2d", rd->locals[i][j].regoff);
-# ifdef HAS_ADDRESS_REGISTER_FILE
-                                               else if (j == TYPE_ADR)
-                                                       printf("r%02d", rd->locals[i][j].regoff);
-# endif
-                                               else if ((j == TYPE_FLT) || (j == TYPE_DBL))
-                                                       printf("f%02d", rd->locals[i][j].regoff);
-                                               else {
-# if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
-                                                       if (IS_2_WORD_TYPE(j))
-                                                               printf(" %3s/%3s",
-                                                                          regs[GET_LOW_REG(rd->locals[i][j].regoff)],
-                                                                          regs[GET_HIGH_REG(rd->locals[i][j].regoff)]);
-                                                       else
-# endif
-                                                               printf("%3s", regs[rd->locals[i][j].regoff]);
-                                               }
-                                       }
-                               }
+                               printf("   (%s) ", jit_type[jd->var[i].type]);
+                               show_allocation(jd->var[i].type, jd->var[i].flags, jd->var[i].regoff);
+                               printf("\n");
 # if defined(ENABLE_INTRP)
                        }
 # endif
-               }
 #endif /* defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER) */
-
+               }
                printf("\n");
        }
-       printf("\n");
+
+       if (cd->maxlocals > 0) {
+               printf("Local Map:\n");
+               printf("    index ");
+               for (j = 0; j < cd->maxlocals; j++) {
+                       printf(" [%2d]", j);
+               }
+               printf("\n");
+               for (i = 0; i < 5; i++) {
+                       printf("    %5s ",jit_type[i]);
+                       for (j = 0; j < cd->maxlocals; j++) {
+                               if (jd->local_map[j*5+i] == UNUSED)
+                                       printf("  -- ");
+                               else
+                                       printf("%4i ",jd->local_map[j*5+i]);
+                       }
+                       printf("\n");
+               }
+               printf("\n");
        }
 
-       if (stage >= SHOW_STACK && rd) {
-#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
-       if (!opt_lsra) {
-#endif
-#if defined(ENABLE_INTRP)
-               if (!opt_intrp) {
-#endif
-       printf("Interface Table:\n");
-       for (i = 0; i < cd->maxstack; i++) {
-               if ((rd->interfaces[i][0].type >= 0) ||
-                       (rd->interfaces[i][1].type >= 0) ||
-                   (rd->interfaces[i][2].type >= 0) ||
-                       (rd->interfaces[i][3].type >= 0) ||
-                   (rd->interfaces[i][4].type >= 0)) {
-                       printf("   %3d: ", i);
+       if (cd->maxstack > 0 && jd->interface_map && stage >= SHOW_STACK) {
+               bool exist = false;
+               interface_info *mapptr = jd->interface_map;
+               
+               /* look if there exist any IN/OUTVARS */
+               for (i = 0; (i < (5 * cd->maxstack)) && !exist; i++, mapptr++)
+                       exist = (mapptr->flags != UNUSED);
+
+               if (exist) {
+                       printf("Interface Table: (In/Outvars)\n");
+                       printf("    depth ");
+                       for (j = 0; j < cd->maxstack; j++) {
+                               printf("      [%2d]", j);
+                       }
+                       printf("\n");
+
+                       for (i = 0; i < 5; i++) {
+                               printf("    %5s      ",jit_type[i]);
+                               for (j = 0; j < cd->maxstack; j++) {
+                                       s4 flags  = jd->interface_map[j*5+i].flags;
+                                       s4 regoff = jd->interface_map[j*5+i].regoff;
+                                       if (flags == UNUSED)
+                                               printf("  --      ");
+                                       else {
+                                               int ch;
 
-#if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
-# if defined(ENABLE_INTRP)
-                       if (!opt_intrp) {
-# endif
-                               for (j = TYPE_INT; j <= TYPE_ADR; j++) {
-                                       if (rd->interfaces[i][j].type >= 0) {
-                                               printf("   (%s) ", jit_type[j]);
                                                if (stage >= SHOW_REGS) {
-                                                       if (rd->interfaces[i][j].flags & SAVEDVAR) {
-                                                               if (rd->interfaces[i][j].flags & INMEMORY)
-                                                                       printf("M%2d", rd->interfaces[i][j].regoff);
-#ifdef HAS_ADDRESS_REGISTER_FILE
-                                                               else if (j == TYPE_ADR)
-                                                                       printf("R%02d", rd->interfaces[i][j].regoff);
-#endif
-                                                               else if ((j == TYPE_FLT) || (j == TYPE_DBL))
-                                                                       printf("F%02d", rd->interfaces[i][j].regoff);
-                                                               else {
-#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
-                                                                       if (IS_2_WORD_TYPE(j))
-                                                                               printf(" %3s/%3s",
-                                                                                          regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
-                                                                                          regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
-                                                                       else
-#endif
-                                                                               printf("%3s",regs[rd->interfaces[i][j].regoff]);
-                                                               }
+                                                       if (flags & SAVEDVAR) {
+                                                               if (flags & INMEMORY)
+                                                                       ch = 'M';
+                                                               else
+                                                                       ch = 'R';
                                                        }
                                                        else {
-                                                               if (rd->interfaces[i][j].flags & INMEMORY)
-                                                                       printf("m%2d", rd->interfaces[i][j].regoff);
-#ifdef HAS_ADDRESS_REGISTER_FILE
-                                                               else if (j == TYPE_ADR)
-                                                                       printf("r%02d", rd->interfaces[i][j].regoff);
-#endif
-                                                               else if ((j == TYPE_FLT) || (j == TYPE_DBL))
-                                                                       printf("f%02d", rd->interfaces[i][j].regoff);
-                                                               else {
-#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
-                                                                       if (IS_2_WORD_TYPE(j))
-                                                                               printf(" %3s/%3s",
-                                                                                          regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
-                                                                                          regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
-                                                                       else
-#endif
-                                                                               printf("%3s",regs[rd->interfaces[i][j].regoff]);
-                                                               }
+                                                               if (flags & INMEMORY)
+                                                                       ch = 'm';
+                                                               else
+                                                                       ch = 'r';
                                                        }
+                                                       printf("%c%03d(", ch, regoff);
+                                                       show_allocation(i, flags, regoff);
+                                                       printf(") ");
+                                               }
+                                               else {
+                                                       if (flags & SAVEDVAR)
+                                                               printf("  I       ");
+                                                       else
+                                                               printf("  i       ");
                                                }
                                        }
                                }
                                printf("\n");
-# if defined(ENABLE_INTRP)
                        }
-# endif
-#endif /* defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER) */
-
+                       printf("\n");
                }
        }
-       printf("\n");
 
-#if defined(ENABLE_INTRP)
+       if (rd->memuse && stage >= SHOW_REGS) {
+               printf("Stack slots: (memuse=%d)\n", rd->memuse);
+               for (i=0; i<rd->memuse; ++i) {
+                       printf("    M%02d: ", i);
+                       for (j=0; j<jd->varcount; ++j) {
+                               varinfo *v = jd->var + j;
+                               if ((v->flags & INMEMORY) && (v->regoff == i)) {
+                                       show_variable(jd, j, stage);
+                                       putchar(' ');
+                               }
+                       }
+
+                       printf("\n");
+
                }
-#endif
-#if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
-       }
-#endif
-       } /* if >= SHOW_STACK */
+               printf("\n");
+       }
 
        if (code->rplpoints) {
                printf("Replacement Points:\n");
@@ -550,190 +541,139 @@ void new_show_basicblock(jitdata *jd, basicblock *bptr, int stage)
             printf("field ");                                        \
         }
 
-#define SHOW_STACKVAR(sp)                                            \
-        new_show_stackvar(jd, (sp), stage)
+#define SHOW_VARIABLE(v)                                             \
+    show_variable(jd, (v), stage)
 
 #define SHOW_S1(iptr)                                                \
         if (stage >= SHOW_STACK) {                                   \
-            SHOW_STACKVAR(iptr->s1.var);                             \
+            SHOW_VARIABLE(iptr->s1.varindex);                        \
         }
 
 #define SHOW_S2(iptr)                                                \
         if (stage >= SHOW_STACK) {                                   \
-            SHOW_STACKVAR(iptr->sx.s23.s2.var);                      \
+            SHOW_VARIABLE(iptr->sx.s23.s2.varindex);                 \
         }
 
 #define SHOW_S3(iptr)                                                \
-        if (stage >= SHOW_STACK) {                                   \
-            SHOW_STACKVAR(iptr->sx.s23.s3.var);                      \
-        }
+    if (stage >= SHOW_STACK) {                                       \
+        SHOW_VARIABLE(iptr->sx.s23.s3.varindex);                     \
+    }
 
 #define SHOW_DST(iptr)                                               \
-        if (stage >= SHOW_STACK) {                                   \
-            printf("=> ");                                           \
-            SHOW_STACKVAR(iptr->dst.var);                            \
-        }
+    if (stage >= SHOW_STACK) {                                       \
+        printf("=> ");                                               \
+        SHOW_VARIABLE(iptr->dst.varindex);                           \
+    }
 
 #define SHOW_S1_LOCAL(iptr)                                          \
-        if (stage >= SHOW_STACK) {                                   \
-            printf("L%d ", iptr->s1.localindex);                     \
-        }
+    if (stage >= SHOW_STACK) {                                       \
+        printf("L%d ", iptr->s1.varindex);                           \
+    }
 
 #define SHOW_DST_LOCAL(iptr)                                         \
-        if (stage >= SHOW_STACK) {                                   \
-            printf("=> L%d ", iptr->dst.localindex);                 \
-        }
+    if (stage >= SHOW_STACK) {                                       \
+        printf("=> L%d ", iptr->dst.varindex);                       \
+    }
 
-static void new_show_stackvar(jitdata *jd, stackptr sp, int stage)
+static void show_allocation(s4 type, s4 flags, s4 regoff)
 {
-       char type;
-
-       switch (sp->type) {
-               case TYPE_INT: type = 'i'; break;
-               case TYPE_LNG: type = 'l'; break;
-               case TYPE_FLT: type = 'f'; break;
-               case TYPE_DBL: type = 'd'; break;
-               case TYPE_ADR: type = 'a'; break;
-               default:       type = '?';
+       if (flags & INMEMORY) {
+               printf("M%02d", regoff);
+               return;
        }
-       printf("S%c%d", type, (int) (sp - jd->new_stack));
 
-       if (stage >= SHOW_REGS) {
-               putchar('(');
-
-               if (sp->flags & SAVEDVAR) {
-                       switch (sp->varkind) {
-                       case TEMPVAR:
-                               if (sp->flags & INMEMORY)
-                                       printf("M%02d", sp->regoff);
 #ifdef HAS_ADDRESS_REGISTER_FILE
-                               else if (sp->type == TYPE_ADR)
-                                       printf("R%02d", sp->regoff);
-#endif
-                               else if (IS_FLT_DBL_TYPE(sp->type))
-                                       printf("F%02d", sp->regoff);
-                               else {
-#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
-                                       if (IS_2_WORD_TYPE(sp->type)) {
-# if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
-#  if defined(ENABLE_INTRP)
-                                               if (opt_intrp)
-                                                       printf("%3d/%3d", GET_LOW_REG(sp->regoff),
-                                                                  GET_HIGH_REG(sp->regoff));
-                                               else
-#  endif
-                                                       printf("%3s/%3s", regs[GET_LOW_REG(sp->regoff)],
-                                                                  regs[GET_HIGH_REG(sp->regoff)]);
-# else
-                                               printf("%3d/%3d", GET_LOW_REG(sp->regoff),
-                                                          GET_HIGH_REG(sp->regoff));
-# endif
-                                       } 
-                                       else 
-#endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */
-                                               {
-#if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
-# if defined(ENABLE_INTRP)
-                                                       if (opt_intrp)
-                                                               printf("%3d", sp->regoff);
-                                                       else
-# endif
-                                                               printf("%3s", regs[sp->regoff]);
-#else
-                                                       printf("%3d", sp->regoff);
-#endif
-                                               }
-                               }
-                               break;
-                       case STACKVAR:
-                               printf("I%02d", sp->varnum);
-                               break;
-                       case LOCALVAR:
-                               printf("L%02d", sp->varnum);
-                               break;
-                       case ARGVAR:
-                               if (sp->varnum == -1) {
-                                       /* Return Value                                  */
-                                       /* varkind ARGVAR "misused for this special case */
-                                       printf(" V0");
-                               } 
-                               else /* "normal" Argvar */
-                                       printf("A%02d", sp->varnum);
-                               break;
-                       default:
-                               printf("!xx {kind=%d, num=%d}", sp->varkind, sp->varnum);
-                       }
-               }
-               else { /* not SAVEDVAR */
-                       switch (sp->varkind) {
-                       case TEMPVAR:
-                               if (sp->flags & INMEMORY)
-                                       printf("m%02d", sp->regoff);
-#ifdef HAS_ADDRESS_REGISTER_FILE
-                               else if (sp->type == TYPE_ADR)
-                                       printf("r%02d", sp->regoff);
+       if (type == TYPE_ADR) {
+               printf("R%02d", regoff);
+               return;
+       }
 #endif
-                               else if (IS_FLT_DBL_TYPE(sp->type))
-                                       printf("f%02d", sp->regoff);
-                               else {
+
+       if (IS_FLT_DBL_TYPE(type)) {
+               printf("F%02d", regoff);
+               return;
+       }
+
 #if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
-                                       if (IS_2_WORD_TYPE(sp->type)) {
+       if (IS_2_WORD_TYPE(type)) {
 # if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
 #  if defined(ENABLE_INTRP)
-                                               if (opt_intrp)
-                                                       printf("%3d/%3d", GET_LOW_REG(sp->regoff),
-                                                                  GET_HIGH_REG(sp->regoff));
-                                               else
+               if (opt_intrp)
+                       printf("%3d/%3d", GET_LOW_REG(regoff),
+                                       GET_HIGH_REG(regoff));
+               else
 #  endif
-                                                       printf("%3s/%3s", regs[GET_LOW_REG(sp->regoff)],
-                                                                  regs[GET_HIGH_REG(sp->regoff)]);
+                       printf("%3s/%3s", regs[GET_LOW_REG(regoff)],
+                                       regs[GET_HIGH_REG(regoff)]);
 # else
-                                               printf("%3d/%3d", GET_LOW_REG(sp->regoff),
-                                                          GET_HIGH_REG(sp->regoff));
+               printf("%3d/%3d", GET_LOW_REG(regoff),
+                               GET_HIGH_REG(regoff));
 # endif
-                                       } 
-                                       else
+               return;
+       } 
 #endif /* defined(SUPPORT_COMBINE_INTEGER_REGISTERS) */
-                                               {
+
 #if defined(ENABLE_JIT) && defined(ENABLE_DISASSEMBLER)
 # if defined(ENABLE_INTRP)
-                                                       if (opt_intrp)
-                                                               printf("%3d", sp->regoff);
-                                                       else
+       if (opt_intrp)
+               printf("%3d", regoff);
+       else
 # endif
-                                                               printf("%3s", regs[sp->regoff]);
+               printf("%3s", regs[regoff]);
 #else
-                                                       printf("%3d", sp->regoff);
+       printf("%3d", regoff);
 #endif
-                                               }
-                               }
-                               break;
-                       case STACKVAR:
-                               printf("i%02d", sp->varnum);
-                               break;
-                       case LOCALVAR:
-                               printf("l%02d", sp->varnum);
-                               break;
-                       case ARGVAR:
-                               if (sp->varnum == -1) {
-                                       /* Return Value                                  */
-                                       /* varkind ARGVAR "misused for this special case */
-                                       printf(" v0");
-                               } 
-                               else /* "normal" Argvar */
-                               printf("a%02d", sp->varnum);
-                               break;
-                       default:
-                               printf("?xx {kind=%d, num=%d}", sp->varkind, sp->varnum);
-                       }
+}
+
+static void show_variable(jitdata *jd, s4 index, int stage)
+{
+       char type;
+       char kind;
+       varinfo *v;
+
+       v = &(jd->var[index]);
+
+       switch (v->type) {
+               case TYPE_INT: type = 'i'; break;
+               case TYPE_LNG: type = 'l'; break;
+               case TYPE_FLT: type = 'f'; break;
+               case TYPE_DBL: type = 'd'; break;
+               case TYPE_ADR: type = 'a'; break;
+               default:       type = '?';
+       }
+
+       if (index < jd->localcount) {
+               kind = 'L';
+               if (v->flags & (PREALLOC | OUTVAR))
+                               printf("<INVALID FLAGS!>");
+       }
+       else {
+               if (v->flags & PREALLOC) {
+                       kind = 'A';
+                       if (v->flags & OUTVAR)
+                               printf("<INVALID FLAGS!>");
                }
+               else if (v->flags & OUTVAR)
+                       kind = 'I';
+               else
+                       kind = 'T';
+       }
+
+       printf("%c%c%d", kind, type, index);
 
+       if (v->flags & SAVEDVAR)
+               putchar('!');
+
+       if (stage >= SHOW_REGS) {
+               putchar('(');
+               show_allocation(v->type, v->flags, v->regoff);
                putchar(')');
        }
        putchar(' ');
+       fflush(stdout);
 }
 
-static void new_show_variable_array(jitdata *jd, stackptr *vars, int n, int stage)
+static void new_show_variable_array(jitdata *jd, s4 *vars, int n, int stage)
 {
        int i;
 
@@ -741,7 +681,7 @@ static void new_show_variable_array(jitdata *jd, stackptr *vars, int n, int stag
        for (i=0; i<n; ++i) {
                if (i)
                        printf(" ");
-               new_show_stackvar(jd, vars[i], stage);
+               show_variable(jd, vars[i], stage);
        }
        printf("]");
 }
@@ -752,7 +692,7 @@ void new_show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage)
        branch_target_t   *table;
        lookup_target_t   *lookup;
        constant_FMIref   *fmiref;
-       stackptr          *argp;
+       s4          *argp;
        s4                 i;
 
        /* get the opcode and the condition */
@@ -1038,7 +978,7 @@ void new_show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage)
                        argp = iptr->sx.s23.s2.args;
                        i = iptr->s1.argcount;
                        while (i--) {
-                               SHOW_STACKVAR(*(argp++));
+                               SHOW_VARIABLE(*(argp++));
                        }
                }
                else {
@@ -1066,7 +1006,9 @@ void new_show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage)
                        argp = iptr->sx.s23.s2.args;
                        i = iptr->s1.argcount;
                        while (i--) {
-                               SHOW_STACKVAR(*(argp++));
+                               if ((iptr->s1.argcount - 1 - i) == iptr->sx.s23.s3.bte->md->paramcount)
+                                       printf(" pass-through: ");
+                               SHOW_VARIABLE(*(argp++));
                        }
                }
                printf("%s ", iptr->sx.s23.s3.bte->cname);
@@ -1080,15 +1022,20 @@ void new_show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage)
        case ICMD_INVOKESTATIC:
        case ICMD_INVOKEINTERFACE:
                if (stage >= SHOW_STACK) {
+                       methoddesc *md;
+                       INSTRUCTION_GET_METHODDESC(iptr, md);
                        argp = iptr->sx.s23.s2.args;
                        i = iptr->s1.argcount;
                        while (i--) {
-                               SHOW_STACKVAR(*(argp++));
+                               if ((iptr->s1.argcount - 1 - i) == md->paramcount)
+                                       printf(" pass-through: ");
+                               SHOW_VARIABLE(*(argp++));
                        }
                }
                INSTRUCTION_GET_METHODREF(iptr, fmiref);
                method_methodref_print(fmiref);
                if (fmiref->parseddesc.md->returntype.type != TYPE_VOID) {
+                       putchar(' ');
                        SHOW_DST(iptr);
                }
                break;
@@ -1178,10 +1125,48 @@ void new_show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage)
 
        case ICMD_TABLESWITCH:
                SHOW_S1(iptr);
+               table = iptr->dst.table;
+
+               i = iptr->sx.s23.s3.tablehigh
+                       - iptr->sx.s23.s2.tablelow + 1;
+
+               printf("high=%d low=%d count=%d\n", iptr->sx.s23.s3.tablehigh, iptr->sx.s23.s2.tablelow, i);
+               while (--i >= 0) {
+                       printf("\t\t%d --> ", table - iptr->dst.table);
+                       if (stage >= SHOW_STACK) {
+                               printf("L%03d\n", table->block->nr);
+                       }
+                       else {
+                               printf("insindex %d (L%03d)\n", table->insindex, BLOCK_OF(table->insindex)->nr);
+                       }
+                       table++;
+               }
+
                break;
 
        case ICMD_LOOKUPSWITCH:
                SHOW_S1(iptr);
+
+               printf("count=%d, default=", iptr->sx.s23.s2.lookupcount);
+               if (stage >= SHOW_STACK) {
+                       printf("L%03d\n", iptr->sx.s23.s3.lookupdefault.block->nr);
+               }
+               else {
+                       printf("insindex %d (L%03d)\n", iptr->sx.s23.s3.lookupdefault.insindex, BLOCK_OF(iptr->sx.s23.s3.lookupdefault.insindex)->nr);
+               }
+
+               lookup = iptr->dst.lookup;
+               i = iptr->sx.s23.s2.lookupcount;
+               while (--i >= 0) {
+                       printf("\t\t%d --> ", lookup->value);
+                       if (stage >= SHOW_STACK) {
+                               printf("L%03d\n", lookup->target.block->nr);
+                       }
+                       else {
+                               printf("insindex %d (L%03d)\n", lookup->target.insindex, BLOCK_OF(lookup->target.insindex)->nr);
+                       }
+                       lookup++;
+               }
                break;
 
        case ICMD_ARETURN:
@@ -1193,85 +1178,88 @@ void new_show_icmd(jitdata *jd, instruction *iptr, bool deadcode, int stage)
                break;
 
        case ICMD_DUP:
+       case ICMD_COPY:
+       case ICMD_MOVE:
                SHOW_S1(iptr);
                SHOW_DST(iptr);
                break;
 
        case ICMD_DUP2:
                if (stage >= SHOW_STACK) {
-                       SHOW_STACKVAR(iptr->dst.dupslots[0]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[1]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[0]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[1]);
                        printf("=> ");
-                       SHOW_STACKVAR(iptr->dst.dupslots[2+0]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[2+1]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[2+0]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[2+1]);
                }
                break;
 
        case ICMD_DUP_X1:
                if (stage >= SHOW_STACK) {
-                       SHOW_STACKVAR(iptr->dst.dupslots[0]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[1]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[0]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[1]);
                        printf("=> ");
-                       SHOW_STACKVAR(iptr->dst.dupslots[2+0]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[2+1]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[2+2]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[2+0]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[2+1]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[2+2]);
                }
                break;
 
        case ICMD_DUP2_X1:
                if (stage >= SHOW_STACK) {
-                       SHOW_STACKVAR(iptr->dst.dupslots[0]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[1]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[2]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[0]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[1]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[2]);
                        printf("=> ");
-                       SHOW_STACKVAR(iptr->dst.dupslots[3+0]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[3+1]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[3+2]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[3+3]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[3+4]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[3+0]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[3+1]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[3+2]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[3+3]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[3+4]);
                }
                break;
 
        case ICMD_DUP_X2:
                if (stage >= SHOW_STACK) {
-                       SHOW_STACKVAR(iptr->dst.dupslots[0]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[1]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[2]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[0]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[1]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[2]);
                        printf("=> ");
-                       SHOW_STACKVAR(iptr->dst.dupslots[3+0]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[3+1]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[3+2]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[3+3]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[3+0]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[3+1]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[3+2]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[3+3]);
                }
                break;
 
        case ICMD_DUP2_X2:
                if (stage >= SHOW_STACK) {
-                       SHOW_STACKVAR(iptr->dst.dupslots[0]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[1]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[2]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[4]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[0]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[1]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[2]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[4]);
                        printf("=> ");
-                       SHOW_STACKVAR(iptr->dst.dupslots[4+0]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[4+1]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[4+2]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[4+3]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[4+4]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[4+5]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[4+0]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[4+1]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[4+2]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[4+3]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[4+4]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[4+5]);
                }
                break;
 
        case ICMD_SWAP:
                if (stage >= SHOW_STACK) {
-                       SHOW_STACKVAR(iptr->dst.dupslots[0]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[1]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[0]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[1]);
                        printf("=> ");
-                       SHOW_STACKVAR(iptr->dst.dupslots[2+0]);
-                       SHOW_STACKVAR(iptr->dst.dupslots[2+1]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[2+0]);
+                       SHOW_VARIABLE(iptr->dst.dupslots[2+1]);
                }
                break;
 
        }
+       fflush(stdout);
 }
 #endif /* !defined(NDEBUG) */