*******************************************************************************/
-#define CONDITIONAL_LOADCONST
-
#ifdef STATISTICS
#define COUNT(cnt) cnt++
#else
#define COUNT(cnt)
#endif
-
+
#define STACKRESET {curstack=0;stackdepth=0;}
#define TYPEPANIC {show_icmd_method();panic("Stack type mismatch");}
int superblockend, repeat, deadcode;
instruction *iptr = instr;
basicblock *bptr, *tbptr;
- s4 *s4ptr;
+ s4 *s4ptr;
+ void* *tptr;
+ xtable *ex;
arguments_num = 0;
new = stack;
b_index = bptr - block;
while (--len >= 0) {
opcode = iptr->opc;
+ iptr->target = NULL;
switch (opcode) {
/* pop 0 push 0 */
/* iptr[1].opc = ICMD_NOP; */
OP1_0(TYPE_INT);
tbptr = block + block_index[iptr->op1];
+
+ iptr[0].target = (void *) tbptr;
+
MARKREACHED(tbptr, copy);
COUNT(count_pcmd_bra);
break;
goto icmd_lconst_tail;
case ICMD_LDIV:
if (iptr[0].val.l == 0x00000002)
- iptr[0].val.l = 1;
+ iptr[0].val.i = 1;
else if (iptr[0].val.l == 0x00000004)
- iptr[0].val.l = 2;
+ iptr[0].val.i = 2;
else if (iptr[0].val.l == 0x00000008)
- iptr[0].val.l = 3;
+ iptr[0].val.i = 3;
else if (iptr[0].val.l == 0x00000010)
- iptr[0].val.l = 4;
+ iptr[0].val.i = 4;
else if (iptr[0].val.l == 0x00000020)
- iptr[0].val.l = 5;
+ iptr[0].val.i = 5;
else if (iptr[0].val.l == 0x00000040)
- iptr[0].val.l = 6;
+ iptr[0].val.i = 6;
else if (iptr[0].val.l == 0x00000080)
- iptr[0].val.l = 7;
+ iptr[0].val.i = 7;
else if (iptr[0].val.l == 0x00000100)
- iptr[0].val.l = 8;
+ iptr[0].val.i = 8;
else if (iptr[0].val.l == 0x00000200)
- iptr[0].val.l = 9;
+ iptr[0].val.i = 9;
else if (iptr[0].val.l == 0x00000400)
- iptr[0].val.l = 10;
+ iptr[0].val.i = 10;
else if (iptr[0].val.l == 0x00000800)
- iptr[0].val.l = 11;
+ iptr[0].val.i = 11;
else if (iptr[0].val.l == 0x00001000)
- iptr[0].val.l = 12;
+ iptr[0].val.i = 12;
else if (iptr[0].val.l == 0x00002000)
- iptr[0].val.l = 13;
+ iptr[0].val.i = 13;
else if (iptr[0].val.l == 0x00004000)
- iptr[0].val.l = 14;
+ iptr[0].val.i = 14;
else if (iptr[0].val.l == 0x00008000)
- iptr[0].val.l = 15;
+ iptr[0].val.i = 15;
else if (iptr[0].val.l == 0x00010000)
- iptr[0].val.l = 16;
+ iptr[0].val.i = 16;
else if (iptr[0].val.l == 0x00020000)
- iptr[0].val.l = 17;
+ iptr[0].val.i = 17;
else if (iptr[0].val.l == 0x00040000)
- iptr[0].val.l = 18;
+ iptr[0].val.i = 18;
else if (iptr[0].val.l == 0x00080000)
- iptr[0].val.l = 19;
+ iptr[0].val.i = 19;
else if (iptr[0].val.l == 0x00100000)
- iptr[0].val.l = 20;
+ iptr[0].val.i = 20;
else if (iptr[0].val.l == 0x00200000)
- iptr[0].val.l = 21;
+ iptr[0].val.i = 21;
else if (iptr[0].val.l == 0x00400000)
- iptr[0].val.l = 22;
+ iptr[0].val.i = 22;
else if (iptr[0].val.l == 0x00800000)
- iptr[0].val.l = 23;
+ iptr[0].val.i = 23;
else if (iptr[0].val.l == 0x01000000)
- iptr[0].val.l = 24;
+ iptr[0].val.i = 24;
else if (iptr[0].val.l == 0x02000000)
- iptr[0].val.l = 25;
+ iptr[0].val.i = 25;
else if (iptr[0].val.l == 0x04000000)
- iptr[0].val.l = 26;
+ iptr[0].val.i = 26;
else if (iptr[0].val.l == 0x08000000)
- iptr[0].val.l = 27;
+ iptr[0].val.i = 27;
else if (iptr[0].val.l == 0x10000000)
- iptr[0].val.l = 28;
+ iptr[0].val.i = 28;
else if (iptr[0].val.l == 0x20000000)
- iptr[0].val.l = 29;
+ iptr[0].val.i = 29;
else if (iptr[0].val.l == 0x40000000)
- iptr[0].val.l = 30;
+ iptr[0].val.i = 30;
else if (iptr[0].val.l == 0x80000000)
- iptr[0].val.l = 31;
+ iptr[0].val.i = 31;
else {
PUSHCONST(TYPE_LNG);
break;
iptr[2].opc = ICMD_NOP; */
OP1_0(TYPE_LNG);
tbptr = block + block_index[iptr->op1];
+
+ iptr[0].target = (void *) tbptr;
+
MARKREACHED(tbptr, copy);
COUNT(count_pcmd_bra);
COUNT(count_pcmd_op);
COUNT(count_pcmd_bra);
OP1_0(TYPE_ADR);
tbptr = block + block_index[iptr->op1];
+
+ iptr[0].target = (void *) tbptr;
+
MARKREACHED(tbptr, copy);
break;
#endif
OP1_0(TYPE_INT);
tbptr = block + block_index[iptr->op1];
+
+ iptr[0].target = (void *) tbptr;
+
MARKREACHED(tbptr, copy);
break;
case ICMD_GOTO:
COUNT(count_pcmd_bra);
tbptr = block + block_index[iptr->op1];
+
+ iptr[0].target = (void *) tbptr;
+
MARKREACHED(tbptr, copy);
SETDST;
superblockend = true;
MARKREACHED(tbptr, copy);
i = *s4ptr++; /* low */
i = *s4ptr++ - i + 1; /* high */
+
+ tptr = DMNEW(void*, i+1);
+ iptr->target = (void *) tptr;
+
+ tptr[0] = (void *) tbptr;
+ tptr++;
+
while (--i >= 0) {
tbptr = block + block_index[*s4ptr++];
+
+ tptr[0] = (void *) tbptr;
+ tptr++;
+
MARKREACHED(tbptr, copy);
}
SETDST;
tbptr = block + block_index[*s4ptr++]; /* default */
MARKREACHED(tbptr, copy);
i = *s4ptr++; /* count */
+
+ tptr = DMNEW(void*, i+1);
+ iptr->target = (void *) tptr;
+
+ tptr[0] = (void *) tbptr;
+ tptr++;
+
while (--i >= 0) {
tbptr = block + block_index[s4ptr[1]];
+
+ tptr[0] = (void *) tbptr;
+ tptr++;
+
MARKREACHED(tbptr, copy);
s4ptr += 2;
}
COUNT(count_pcmd_bra);
OP2_0(TYPE_INT);
tbptr = block + block_index[iptr->op1];
+
+ iptr[0].target = (void *) tbptr;
+
MARKREACHED(tbptr, copy);
break;
COUNT(count_pcmd_bra);
OP2_0(TYPE_ADR);
tbptr = block + block_index[iptr->op1];
+
+ iptr[0].target = (void *) tbptr;
+
MARKREACHED(tbptr, copy);
break;
}
else {
copy = curstack;
- NEWSTACK(copy[-1].type, copy[-1].varkind,
- copy[-1].varnum);
- NEWSTACK(copy[ 0].type, copy[ 0].varkind,
- copy[ 0].varnum);
+ NEWSTACK(copy->prev->type, copy->prev->varkind,
+ copy->prev->varnum);
+ NEWSTACK(copy->type, copy->varkind,
+ copy->varnum);
SETDST;
stackdepth+=2;
}
/* iptr[1].opc = ICMD_NOP; */
OP2_0(TYPE_LNG);
tbptr = block + block_index[iptr->op1];
+
+ iptr[0].target = (void *) tbptr;
+
MARKREACHED(tbptr, copy);
COUNT(count_pcmd_bra);
break;
case ICMD_JSR:
OP0_1(TYPE_ADR);
tbptr = block + block_index[iptr->op1];
+
+ iptr[0].target = (void *) tbptr;
+
tbptr->type=BBTYPE_SBR;
MARKREACHED(tbptr, copy);
OP1_0ANY;
else
count_block_stack[bptr->indepth]++;
len = bptr->icount;
- if (len <= 10)
- count_block_size_distribution[len - 1]++;
+ if (len < 10)
+ count_block_size_distribution[len]++;
else if (len <= 12)
count_block_size_distribution[10]++;
else if (len <= 14)
switch (s->varkind) {
case TEMPVAR:
if (s->flags & INMEMORY)
- printf(" m%02d", s->regoff);
+ printf(" M%02d", s->regoff);
+ else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
+ printf(" F%02d", s->regoff);
else
- printf(" r%02d", s->regoff);
+ printf(" %3s", regs[s->regoff]);
break;
case STACKVAR:
- printf(" s%02d", s->varnum);
+ printf(" I%02d", s->varnum);
break;
case LOCALVAR:
- printf(" l%02d", s->varnum);
+ printf(" L%02d", s->varnum);
break;
case ARGVAR:
- printf(" a%02d", s->varnum);
+ printf(" A%02d", s->varnum);
break;
default:
printf(" !%02d", j);
switch (s->varkind) {
case TEMPVAR:
if (s->flags & INMEMORY)
- printf(" M%02d", s->regoff);
+ printf(" m%02d", s->regoff);
+ else if ((s->type == TYPE_FLT) || (s->type == TYPE_DBL))
+ printf(" f%02d", s->regoff);
else
- printf(" R%02d", s->regoff);
+ printf(" %3s", regs[s->regoff]);
break;
case STACKVAR:
- printf(" S%02d", s->varnum);
+ printf(" i%02d", s->varnum);
break;
case LOCALVAR:
- printf(" L%02d", s->varnum);
+ printf(" l%02d", s->varnum);
break;
case ARGVAR:
- printf(" A%02d", s->varnum);
+ printf(" a%02d", s->varnum);
break;
default:
printf(" ?%02d", j);
}
+#if 0
static void print_reg(stackptr s) {
if (s) {
if (s->flags & SAVEDVAR)
printf(" ");
}
+#endif
static char *builtin_name(functionptr bptr)
}
+static char *jit_type[] = {
+ "int",
+ "lng",
+ "flt",
+ "dbl",
+ "adr"
+};
+
+
static void show_icmd_method()
{
- int b, i, j, last;
+ int i, j, last;
int deadcode;
s4 *s4ptr;
instruction *iptr;
-
+ basicblock *bptr;
+ void **tptr;
+ xtable *ex;
+
printf("\n");
unicode_fprint(stdout, class->name);
printf(".");
printf ("\n\nMax locals: %d\n", (int) maxlocals);
printf ("Max stack: %d\n", (int) maxstack);
- printf ("Exceptions:\n");
- for (i = 0; i < exceptiontablelength; i++) {
- printf(" L%03d ... ", block_index[extable[i].startpc]);
- printf("L%03d = ", block_index[extable[i].endpc]);
- printf("L%03d\n", block_index[extable[i].handlerpc]);
+ printf ("Exceptions (Number: %d):\n", exceptiontablelength);
+ for (ex = extable; ex != NULL; ex = ex->down) {
+ printf(" L%03d ... ", ex->start->debug_nr );
+ printf("L%03d = ", ex->end->debug_nr);
+ printf("L%03d\n", ex->handler->debug_nr);
}
printf ("Local Table:\n");
printf(" %3d: ", i);
for (j = TYPE_INT; j <= TYPE_ADR; j++)
if (locals[i][j].type >= 0) {
- printf(" (%d) ", j);
- if (locals[i][j].flags)
- printf("m");
+ printf(" (%s) ", jit_type[j]);
+ if (locals[i][j].flags & INMEMORY)
+ printf("m%2d", locals[i][j].regoff);
+ else if ((j == TYPE_FLT) || (j == TYPE_DBL))
+ printf("f%02d", locals[i][j].regoff);
else
- printf("r");
- printf("%2d", locals[i][j].regoff);
+ printf("%3s", regs[locals[i][j].regoff]);
}
printf("\n");
}
printf(" %3d: ", i);
for (j = TYPE_INT; j <= TYPE_ADR; j++)
if (interfaces[i][j].type >= 0) {
- printf(" (%d) ", j);
- if (interfaces[i][j].flags & SAVEDVAR)
- printf("s");
- else
- printf("t");
- if (interfaces[i][j].flags & INMEMORY)
- printf("m");
- else
- printf("r");
- printf("%2d", interfaces[i][j].regoff);
+ printf(" (%s) ", jit_type[j]);
+ if (interfaces[i][j].flags & SAVEDVAR) {
+ if (interfaces[i][j].flags & INMEMORY)
+ printf("M%2d", interfaces[i][j].regoff);
+ else if ((j == TYPE_FLT) || (j == TYPE_DBL))
+ printf("F%02d", interfaces[i][j].regoff);
+ else
+ printf("%3s", regs[interfaces[i][j].regoff]);
+ }
+ else {
+ if (interfaces[i][j].flags & INMEMORY)
+ printf("m%2d", interfaces[i][j].regoff);
+ else if ((j == TYPE_FLT) || (j == TYPE_DBL))
+ printf("f%02d", interfaces[i][j].regoff);
+ else
+ printf("%3s", regs[interfaces[i][j].regoff]);
+ }
}
printf("\n");
}
printf("\n");
}
- for (b = 0; b < block_count; b++)
- if (block[b].flags != BBDELETED) {
- deadcode = block[b].flags <= BBREACHED;
+
+ for (bptr = block; bptr != NULL; bptr = bptr->next)
+ if (bptr->flags != BBDELETED) {
+ deadcode = bptr->flags <= BBREACHED;
printf("[");
if (deadcode)
for (j = maxstack; j > 0; j--)
printf(" ? ");
else
- print_stack(block[b].instack);
- printf("] L%03d(%d):\n", b, block[b].pre_count);
- iptr = block[b].iinstr;
- i = iptr - instr;
- for (last = i + block[b].icount; i < last; i++, iptr++) {
+ print_stack(bptr->instack);
+ printf("] L%03d(%d - %d):\n", bptr->debug_nr, bptr->icount, bptr->pre_count);
+ iptr = bptr->iinstr;
+
+ for (i=0; i < bptr->icount; i++, iptr++) {
printf("[");
if (deadcode) {
for (j = maxstack; j > 0; j--)
case ICMD_IINC:
printf(" %d + %d", iptr->op1, iptr->val.i);
break;
+
+ case ICMD_IASTORE:
+ case ICMD_SASTORE:
+ case ICMD_BASTORE:
+ case ICMD_CASTORE:
+ case ICMD_LASTORE:
+ case ICMD_DASTORE:
+ case ICMD_FASTORE:
+ case ICMD_AASTORE:
+
+ case ICMD_IALOAD:
+ case ICMD_SALOAD:
+ case ICMD_BALOAD:
+ case ICMD_CALOAD:
+ case ICMD_LALOAD:
+ case ICMD_DALOAD:
+ case ICMD_FALOAD:
+ case ICMD_AALOAD:
+ if (iptr->op1 != 0)
+ printf("(opt.)");
+ break;
+
case ICMD_RET:
case ICMD_ILOAD:
case ICMD_LLOAD:
case ICMD_IF_LGE:
case ICMD_IF_LGT:
case ICMD_IF_LLE:
- printf("(%d) L%03d", iptr->val.i, block_index[iptr->op1]);
+ printf("(%d) L%03d", iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
break;
case ICMD_JSR:
case ICMD_GOTO:
case ICMD_IF_LCMPLE:
case ICMD_IF_ACMPEQ:
case ICMD_IF_ACMPNE:
- printf(" L%03d", block_index[iptr->op1]);
+ printf(" L%03d", ((basicblock *) iptr->target)->debug_nr);
break;
case ICMD_TABLESWITCH:
+
s4ptr = iptr->val.a;
- printf(" L%03d;", block_index[*s4ptr++]); /* default */
+ tptr = (void **) iptr->target;
+
+ printf(" L%03d;", ((basicblock *) *tptr)->debug_nr);
+ /* default */
+
+ s4ptr++;
+ tptr++;
+
j = *s4ptr++; /* low */
j = *s4ptr++ - j; /* high */
while (j >= 0) {
- printf(" L%03d", block_index[*s4ptr++]);
+ printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
+ tptr++;
j--;
}
break;
case ICMD_LOOKUPSWITCH:
s4ptr = iptr->val.a;
- printf(" L%d", block_index[*s4ptr++]); /* default */
- j = *s4ptr++; /* count */
+ tptr = (void **) iptr->target;
+
+ printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
+ s4ptr++; /* default */
+ j = *s4ptr; /* count */
+ tptr++;
+
while (--j >= 0) {
- printf(" L%03d", block_index[s4ptr[1]]);
- s4ptr += 2;
+ printf(" L%03d", ((basicblock *) *tptr)->debug_nr);
+ tptr++;
}
break;
}
if (showdisassemble && (!deadcode)) {
printf("\n");
- i = block[b].mpc;
+ i = bptr->mpc;
s4ptr = (s4 *) (method->mcode + dseglen + i);
- for (; i < block[b + 1].mpc; i += 4, s4ptr++) {
- disassinstr(*s4ptr, i);
- }
- printf("\n");
- }
+
+ if (bptr->next != NULL) {
+ for (; i < bptr->next->mpc; i += 4, s4ptr++) {
+ disassinstr(*s4ptr, i);
+ }
+ printf("\n");
+ }
+ else {
+ for (; s4ptr < (s4 *) (method->mcode + method->mcodelength); i += 4, s4ptr++) {
+ disassinstr(*s4ptr, i);
+ }
+ printf("\n");
+ }
+ }
}
- i = block[b].mpc;
+
+ /*
+ i = bptr->mpc;
s4ptr = (s4 *) (method->mcode + dseglen + i);
if (showdisassemble && (s4ptr < (s4 *) (method->mcode + method->mcodelength))) {
printf("\n");
}
printf("\n");
}
+ */
}