projects
/
cacao.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
basic block struct changed
[cacao.git]
/
ncomp
/
nstack.c
diff --git
a/ncomp/nstack.c
b/ncomp/nstack.c
index b10d60ba22ead004402916d568ab371dbc712b42..f3869050822bb452d0eabd1bd8694dc0cdef1547 100644
(file)
--- a/
ncomp/nstack.c
+++ b/
ncomp/nstack.c
@@
-191,8
+191,8
@@
static void analyse_stack()
b_count = block_count;
bptr = block;
while (--b_count >= 0) {
b_count = block_count;
bptr = block;
while (--b_count >= 0) {
- if (bptr
[1].ipc > bptr[0].ipc
) {
- iptr =
instr + bptr[1].ipc
- 1;
+ if (bptr
->icount != 0
) {
+ iptr =
bptr->iinstr + bptr->icount
- 1;
switch (iptr->opc) {
case ICMD_RET:
case ICMD_RETURN:
switch (iptr->opc) {
case ICMD_RET:
case ICMD_RETURN:
@@
-288,9
+288,8
@@
static void analyse_stack()
deadcode = false;
superblockend = false;
bptr->flags = BBFINISHED;
deadcode = false;
superblockend = false;
bptr->flags = BBFINISHED;
- i = bptr[0].ipc;
- len = bptr[1].ipc - i;
- iptr = &instr[i];
+ len = bptr->icount;
+ iptr = bptr->iinstr;
b_index = bptr - block;
while (--len >= 0) {
opcode = iptr->opc;
b_index = bptr - block;
while (--len >= 0) {
opcode = iptr->opc;
@@
-471,7
+470,9
@@
icmd_iconst_tail:
iptr[0].opc = ICMD_IFEQ;
icmd_if_icmp_tail:
iptr[0].op1 = iptr[1].op1;
iptr[0].opc = ICMD_IFEQ;
icmd_if_icmp_tail:
iptr[0].op1 = iptr[1].op1;
- iptr[1].opc = ICMD_NOP;
+ bptr->icount--;
+ len--;
+ /* iptr[1].opc = ICMD_NOP; */
OP1_0(TYPE_INT);
tbptr = block + block_index[iptr->op1];
MARKREACHED(tbptr, copy);
OP1_0(TYPE_INT);
tbptr = block + block_index[iptr->op1];
MARKREACHED(tbptr, copy);
@@
-652,8
+653,10
@@
icmd_lconst_tail:
iptr[0].opc = ICMD_IF_LEQ;
icmd_lconst_lcmp_tail:
iptr[0].op1 = iptr[2].op1;
iptr[0].opc = ICMD_IF_LEQ;
icmd_lconst_lcmp_tail:
iptr[0].op1 = iptr[2].op1;
- iptr[1].opc = ICMD_NOP;
- iptr[2].opc = ICMD_NOP;
+ bptr->icount -= 2;
+ len -= 2;
+ /* iptr[1].opc = ICMD_NOP;
+ iptr[2].opc = ICMD_NOP; */
OP1_0(TYPE_LNG);
tbptr = block + block_index[iptr->op1];
MARKREACHED(tbptr, copy);
OP1_0(TYPE_LNG);
tbptr = block + block_index[iptr->op1];
MARKREACHED(tbptr, copy);
@@
-907,16
+910,19
@@
icmd_lconst_lcmp_tail:
iptr[3].opc = ICMD_NOP;
tbptr[1].flags = BBDELETED;
tbptr[2].flags = BBDELETED;
iptr[3].opc = ICMD_NOP;
tbptr[1].flags = BBDELETED;
tbptr[2].flags = BBDELETED;
- len += 3;
+ tbptr[1].icount = 0;
+ tbptr[2].icount = 0;
if (tbptr[3].pre_count == 2) {
if (tbptr[3].pre_count == 2) {
+ len += tbptr[3].icount + 3;
+ bptr->icount += tbptr[3].icount + 3;
tbptr[3].flags = BBDELETED;
tbptr[3].flags = BBDELETED;
- len += tbptr[4].ipc - tbptr[3].ipc;
- tbptr[3].ipc = tbptr[4].ipc;
- b_index ++;
+ tbptr[3].icount = 0;
+ b_index++;
+ }
+ else {
+ bptr->icount++;
+ len ++;
}
}
- tbptr[1].ipc = tbptr[3].ipc;
- tbptr[2].ipc = tbptr[3].ipc;
- bptr[1].ipc = tbptr[3].ipc;
b_index += 2;
break;
}
b_index += 2;
break;
}
@@
-1193,7
+1199,9
@@
icmd_lconst_lcmp_tail:
iptr[0].opc = ICMD_IF_LCMPEQ;
icmd_lcmp_if_tail:
iptr[0].op1 = iptr[1].op1;
iptr[0].opc = ICMD_IF_LCMPEQ;
icmd_lcmp_if_tail:
iptr[0].op1 = iptr[1].op1;
- iptr[1].opc = ICMD_NOP;
+ len--;
+ bptr->icount--;
+ /* iptr[1].opc = ICMD_NOP; */
OP2_0(TYPE_LNG);
tbptr = block + block_index[iptr->op1];
MARKREACHED(tbptr, copy);
OP2_0(TYPE_LNG);
tbptr = block + block_index[iptr->op1];
MARKREACHED(tbptr, copy);
@@
-1445,9
+1453,9
@@
builtin2:
if (block_count > count_max_basic_blocks)
count_max_basic_blocks = block_count;
count_basic_blocks += block_count;
if (block_count > count_max_basic_blocks)
count_max_basic_blocks = block_count;
count_basic_blocks += block_count;
- if (
block[block_count].ipc
> count_max_javainstr)
- count_max_javainstr = block[block_count].i
pc
;
- count_javainstr += block[block_count].i
pc
;
+ if (
(block[block_count].iinstr - instr)
> count_max_javainstr)
+ count_max_javainstr = block[block_count].i
instr - instr
;
+ count_javainstr += block[block_count].i
instr - instr
;
if (stack_count > count_upper_bound_new_stack)
count_upper_bound_new_stack = stack_count;
if ((new - stack) > count_max_new_stack)
if (stack_count > count_upper_bound_new_stack)
count_upper_bound_new_stack = stack_count;
if ((new - stack) > count_max_new_stack)
@@
-1461,7
+1469,7
@@
builtin2:
count_block_stack[10]++;
else
count_block_stack[bptr->indepth]++;
count_block_stack[10]++;
else
count_block_stack[bptr->indepth]++;
- len = bptr
[1].ipc - bptr[0].ipc
;
+ len = bptr
->icount
;
if (len <= 10)
count_block_size_distribution[len - 1]++;
else if (len <= 12)
if (len <= 10)
count_block_size_distribution[len - 1]++;
else if (len <= 12)
@@
-1638,9
+1646,10
@@
static char *builtin_name(functionptr bptr)
static void show_icmd_method()
{
static void show_icmd_method()
{
- int b, i, j;
+ int b, i, j
, last
;
int deadcode;
s4 *s4ptr;
int deadcode;
s4 *s4ptr;
+ instruction *iptr;
printf("\n");
unicode_fprint(stdout, class->name);
printf("\n");
unicode_fprint(stdout, class->name);
@@
-1716,16
+1725,18
@@
static void show_icmd_method()
else
print_stack(block[b].instack);
printf("] L%03d(%d):\n", b, block[b].pre_count);
else
print_stack(block[b].instack);
printf("] L%03d(%d):\n", b, block[b].pre_count);
- for (i = block[b].ipc; i < block[b + 1].ipc; i++) {
+ iptr = block[b].iinstr;
+ i = iptr - instr;
+ for (last = i + block[b].icount; i < last; i++, iptr++) {
printf("[");
if (deadcode) {
for (j = maxstack; j > 0; j--)
printf(" ? ");
}
else
printf("[");
if (deadcode) {
for (j = maxstack; j > 0; j--)
printf(" ? ");
}
else
- print_stack(i
nstr[i].
dst);
- printf("] %4d %s", i, icmd_names[i
nstr[i].
opc]);
- switch ((int) i
nstr[i].
opc) {
+ print_stack(i
ptr->
dst);
+ printf("] %4d %s", i, icmd_names[i
ptr->
opc]);
+ switch ((int) i
ptr->
opc) {
case ICMD_IADDCONST:
case ICMD_ISUBCONST:
case ICMD_IMULCONST:
case ICMD_IADDCONST:
case ICMD_ISUBCONST:
case ICMD_IMULCONST:
@@
-1746,7
+1757,7
@@
static void show_icmd_method()
case ICMD_IFGE_ICONST:
case ICMD_IFGT_ICONST:
case ICMD_IFLE_ICONST:
case ICMD_IFGE_ICONST:
case ICMD_IFGT_ICONST:
case ICMD_IFLE_ICONST:
- printf(" %d", i
nstr[i].
val.i);
+ printf(" %d", i
ptr->
val.i);
break;
case ICMD_LADDCONST:
case ICMD_LSUBCONST:
break;
case ICMD_LADDCONST:
case ICMD_LSUBCONST:
@@
-1760,28
+1771,28
@@
static void show_icmd_method()
case ICMD_LSHRCONST:
case ICMD_LUSHRCONST:
case ICMD_LCONST:
case ICMD_LSHRCONST:
case ICMD_LUSHRCONST:
case ICMD_LCONST:
- printf(" %ld", i
nstr[i].
val.l);
+ printf(" %ld", i
ptr->
val.l);
break;
case ICMD_FCONST:
break;
case ICMD_FCONST:
- printf(" %f", i
nstr[i].
val.f);
+ printf(" %f", i
ptr->
val.f);
break;
case ICMD_DCONST:
break;
case ICMD_DCONST:
- printf(" %f", i
nstr[i].
val.d);
+ printf(" %f", i
ptr->
val.d);
break;
case ICMD_ACONST:
break;
case ICMD_ACONST:
- printf(" %p", i
nstr[i].
val.a);
+ printf(" %p", i
ptr->
val.a);
break;
case ICMD_GETFIELD:
case ICMD_PUTFIELD:
break;
case ICMD_GETFIELD:
case ICMD_PUTFIELD:
- printf(" %d,", ((fieldinfo *) i
nstr[i].
val.a)->offset);
+ printf(" %d,", ((fieldinfo *) i
ptr->
val.a)->offset);
case ICMD_PUTSTATIC:
case ICMD_GETSTATIC:
printf(" ");
unicode_fprint(stdout,
case ICMD_PUTSTATIC:
case ICMD_GETSTATIC:
printf(" ");
unicode_fprint(stdout,
- ((fieldinfo *) i
nstr[i].
val.a)->name);
+ ((fieldinfo *) i
ptr->
val.a)->name);
break;
case ICMD_IINC:
break;
case ICMD_IINC:
- printf(" %d + %d", i
nstr[i].op1, instr[i].
val.i);
+ printf(" %d + %d", i
ptr->op1, iptr->
val.i);
break;
case ICMD_RET:
case ICMD_ILOAD:
break;
case ICMD_RET:
case ICMD_ILOAD:
@@
-1794,15
+1805,15
@@
static void show_icmd_method()
case ICMD_FSTORE:
case ICMD_DSTORE:
case ICMD_ASTORE:
case ICMD_FSTORE:
case ICMD_DSTORE:
case ICMD_ASTORE:
- printf(" %d", i
nstr[i].
op1);
+ printf(" %d", i
ptr->
op1);
break;
case ICMD_NEW:
printf(" ");
unicode_fprint(stdout,
break;
case ICMD_NEW:
printf(" ");
unicode_fprint(stdout,
- ((classinfo *) i
nstr[i].
val.a)->name);
+ ((classinfo *) i
ptr->
val.a)->name);
break;
case ICMD_NEWARRAY:
break;
case ICMD_NEWARRAY:
- switch (i
nstr[i].
op1) {
+ switch (i
ptr->
op1) {
case 4:
printf(" boolean");
break;
case 4:
printf(" boolean");
break;
@@
-1830,16
+1841,16
@@
static void show_icmd_method()
}
break;
case ICMD_ANEWARRAY:
}
break;
case ICMD_ANEWARRAY:
- if (i
nstr[i].
op1) {
+ if (i
ptr->
op1) {
printf(" ");
unicode_fprint(stdout,
printf(" ");
unicode_fprint(stdout,
- ((classinfo *) i
nstr[i].
val.a)->name);
+ ((classinfo *) i
ptr->
val.a)->name);
}
break;
case ICMD_CHECKCAST:
case ICMD_INSTANCEOF:
}
break;
case ICMD_CHECKCAST:
case ICMD_INSTANCEOF:
- if (i
nstr[i].
op1) {
- classinfo *c = i
nstr[i].
val.a;
+ if (i
ptr->
op1) {
+ classinfo *c = i
ptr->
val.a;
if (c->flags & ACC_INTERFACE)
printf(" (INTERFACE) ");
else
if (c->flags & ACC_INTERFACE)
printf(" (INTERFACE) ");
else
@@
-1850,7
+1861,7
@@
static void show_icmd_method()
case ICMD_BUILTIN3:
case ICMD_BUILTIN2:
case ICMD_BUILTIN1:
case ICMD_BUILTIN3:
case ICMD_BUILTIN2:
case ICMD_BUILTIN1:
- printf(" %s", builtin_name((functionptr) i
nstr[i].
val.a));
+ printf(" %s", builtin_name((functionptr) i
ptr->
val.a));
break;
case ICMD_INVOKEVIRTUAL:
case ICMD_INVOKESPECIAL:
break;
case ICMD_INVOKEVIRTUAL:
case ICMD_INVOKESPECIAL:
@@
-1858,10
+1869,10
@@
static void show_icmd_method()
case ICMD_INVOKEINTERFACE:
printf(" ");
unicode_fprint(stdout,
case ICMD_INVOKEINTERFACE:
printf(" ");
unicode_fprint(stdout,
- ((methodinfo *) i
nstr[i].
val.a)->class->name);
+ ((methodinfo *) i
ptr->
val.a)->class->name);
printf(".");
unicode_fprint(stdout,
printf(".");
unicode_fprint(stdout,
- ((methodinfo *) i
nstr[i].
val.a)->name);
+ ((methodinfo *) i
ptr->
val.a)->name);
break;
case ICMD_IFEQ:
case ICMD_IFNE:
break;
case ICMD_IFEQ:
case ICMD_IFNE:
@@
-1875,7
+1886,7
@@
static void show_icmd_method()
case ICMD_IF_LGE:
case ICMD_IF_LGT:
case ICMD_IF_LLE:
case ICMD_IF_LGE:
case ICMD_IF_LGT:
case ICMD_IF_LLE:
- printf("(%d) L%03d", i
nstr[i].val.i, block_index[instr[i].
op1]);
+ printf("(%d) L%03d", i
ptr->val.i, block_index[iptr->
op1]);
break;
case ICMD_JSR:
case ICMD_GOTO:
break;
case ICMD_JSR:
case ICMD_GOTO:
@@
-1895,10
+1906,10
@@
static void show_icmd_method()
case ICMD_IF_LCMPLE:
case ICMD_IF_ACMPEQ:
case ICMD_IF_ACMPNE:
case ICMD_IF_LCMPLE:
case ICMD_IF_ACMPEQ:
case ICMD_IF_ACMPNE:
- printf(" L%03d", block_index[i
nstr[i].
op1]);
+ printf(" L%03d", block_index[i
ptr->
op1]);
break;
case ICMD_TABLESWITCH:
break;
case ICMD_TABLESWITCH:
- s4ptr = i
nstr[i].
val.a;
+ s4ptr = i
ptr->
val.a;
printf(" L%03d;", block_index[*s4ptr++]); /* default */
j = *s4ptr++; /* low */
j = *s4ptr++ - j; /* high */
printf(" L%03d;", block_index[*s4ptr++]); /* default */
j = *s4ptr++; /* low */
j = *s4ptr++ - j; /* high */
@@
-1908,7
+1919,7
@@
static void show_icmd_method()
}
break;
case ICMD_LOOKUPSWITCH:
}
break;
case ICMD_LOOKUPSWITCH:
- s4ptr = i
nstr[i].
val.a;
+ s4ptr = i
ptr->
val.a;
printf(" L%d", block_index[*s4ptr++]); /* default */
j = *s4ptr++; /* count */
while (--j >= 0) {
printf(" L%d", block_index[*s4ptr++]); /* default */
j = *s4ptr++; /* count */
while (--j >= 0) {