#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;
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;
/* 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)
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("\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");
}
+ */
}