Changes: Edwin Steiner
Christian Thalinger
- $Id: stack.c 2541 2005-05-31 16:02:14Z twisti $
+ $Id: stack.c 2568 2005-06-06 15:28:11Z twisti $
*/
methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd)
{
- int b_count;
- int b_index;
- int stackdepth;
- stackptr curstack;
- stackptr new;
- stackptr copy;
- int opcode, i, len, loops;
- int superblockend, repeat, deadcode;
- instruction *iptr;
- basicblock *bptr;
- basicblock *tbptr;
- s4 *s4ptr;
- void* *tptr;
- s4 *argren;
-
- s4 call_argcount;
- s4 call_returntype;
+ int b_count;
+ int b_index;
+ int stackdepth;
+ stackptr curstack;
+ stackptr new;
+ stackptr copy;
+ int opcode, i, len, loops;
+ int superblockend, repeat, deadcode;
+ instruction *iptr;
+ basicblock *bptr;
+ basicblock *tbptr;
+ s4 *s4ptr;
+ void **tptr;
+ s4 *argren;
+
+ builtintable_entry *bte;
+ unresolved_method *um;
+ methoddesc *md;
#ifdef LSRA
m->maxlifetimes = 0;
repeat = false;
STACKRESET;
deadcode = true;
- /*printf("Block count :%d\n",b_count);*/
while (--b_count >= 0) {
if (bptr->flags == BBDELETED) {
/* do nothing */
- /*log_text("BBDELETED");*/
} else if (superblockend && (bptr->flags < BBREACHED)) {
repeat = true;
/* XXX TWISTI: why is this set to NULL here? */
/* iptr->target = NULL; */
-/* dolog("p: %04d op: %s stack: %p", iptr - instr, icmd_names[opcode], curstack); */
-
#if defined(USEBUILTINTABLE)
- {
-#if 0
- stdopdescriptor *breplace;
- breplace = find_builtin(opcode);
-
- if (breplace && opcode == breplace->opcode) {
- iptr[0].opc = breplace->icmd;
- iptr[0].op1 = breplace->type_d;
- iptr[0].val.fp = breplace->builtin;
- m->isleafmethod = false;
- switch (breplace->icmd) {
- case ICMD_BUILTIN1:
- goto builtin1;
- case ICMD_BUILTIN2:
- goto builtin2;
- }
- }
-#endif
- builtin_descriptor *breplace;
- breplace = find_builtin(opcode);
-
- if (breplace && opcode == breplace->opcode) {
- iptr[0].opc = breplace->icmd;
- iptr[0].op1 = breplace->type_d;
- iptr[0].val.fp = breplace->builtin;
- m->isleafmethod = false;
- switch (breplace->icmd) {
- case ICMD_BUILTIN1:
- goto builtin1;
- case ICMD_BUILTIN2:
- goto builtin2;
- }
- }
+ bte = builtintable_get_automatic(opcode);
+
+ if (bte && bte->opcode == opcode) {
+ iptr->opc = ICMD_BUILTIN;
+ iptr->op1 = bte->md->paramcount;
+ iptr->val.a = bte;
+ m->isleafmethod = false;
+ goto builtin;
}
#endif /* defined(USEBUILTINTABLE) */
#if SUPPORT_CONST_STORE
if (len > 0 && iptr->val.a == 0) {
switch (iptr[1].opc) {
- case ICMD_BUILTIN3:
+ case ICMD_BUILTIN:
if (iptr[1].val.fp != BUILTIN_aastore) {
PUSHCONST(TYPE_ADR);
break;
case ICMD_PUTSTATIC:
case ICMD_PUTFIELD:
switch (iptr[1].opc) {
- case ICMD_BUILTIN3:
+ case ICMD_BUILTIN:
iptr[0].opc = ICMD_AASTORECONST;
OPTT2_0(TYPE_INT, TYPE_ADR);
break;
case ICMD_IDIV:
#if !SUPPORT_DIVISION
- iptr[0].opc = ICMD_BUILTIN2;
- iptr[0].op1 = TYPE_INT;
- iptr[0].val.fp = BUILTIN_idiv;
+ bte = builtintable_get_internal(BUILTIN_idiv);
+ iptr->opc = ICMD_BUILTIN;
+ iptr->op1 = bte->md->paramcount;
+ iptr->val.a = bte;
m->isleafmethod = false;
- goto builtin2;
+ goto builtin;
#endif
case ICMD_IREM:
#if !SUPPORT_DIVISION
- /*log_text("ICMD_IREM: !SUPPORT_DIVISION");*/
- iptr[0].opc = ICMD_BUILTIN2;
- iptr[0].op1 = TYPE_INT;
- iptr[0].val.fp = BUILTIN_irem;
+ bte = builtintable_get_internal(BUILTIN_irem);
+ iptr->opc = ICMD_BUILTIN;
+ iptr->op1 = bte->md->paramcount;
+ iptr->val.a = bte;
m->isleafmethod = false;
- goto builtin2;
+ goto builtin;
#endif
- /*log_text("ICMD_IREM: SUPPORT_DIVISION");*/
case ICMD_ISHL:
case ICMD_ISHR:
case ICMD_LDIV:
#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
- iptr[0].opc = ICMD_BUILTIN2;
- iptr[0].op1 = TYPE_LNG;
- iptr[0].val.fp = BUILTIN_ldiv;
+ bte = builtintable_get_internal(BUILTIN_ldiv);
+ iptr->opc = ICMD_BUILTIN;
+ iptr->op1 = bte->md->paramcount;
+ iptr->val.a = bte;
m->isleafmethod = false;
- goto builtin2;
+ goto builtin;
#endif
case ICMD_LREM:
#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
- iptr[0].opc = ICMD_BUILTIN2;
- iptr[0].op1 = TYPE_LNG;
- iptr[0].val.fp = BUILTIN_lrem;
+ bte = builtintable_get_internal(BUILTIN_lrem);
+ iptr->opc = ICMD_BUILTIN;
+ iptr->op1 = bte->md->paramcount;
+ iptr->val.a = bte;
m->isleafmethod = false;
- goto builtin2;
+ goto builtin;
#endif
case ICMD_LMUL:
OP1_0ANY;
break;
- /* pop many push any */
- case ICMD_BUILTIN3:
- call_argcount = 3;
- call_returntype = iptr->op1;
- goto _callhandling;
- case ICMD_BUILTIN2:
-#if defined(USEBUILTINTABLE) || !SUPPORT_DIVISION
- /* Just prevent a compiler warning... */
- builtin2:
-#endif
- call_argcount = 2;
- call_returntype = iptr->op1;
- goto _callhandling;
- case ICMD_BUILTIN1:
+ /* pop many push any */
+
+ case ICMD_BUILTIN:
#if defined(USEBUILTINTABLE)
/* Just prevent a compiler warning... */
- builtin1:
-#endif
- call_argcount = 1;
- call_returntype = iptr->op1;
+ builtin:
+#endif
+ bte = (builtintable_entry *) iptr->val.a;
+ md = bte->md;
goto _callhandling;
- case ICMD_INVOKEVIRTUAL:
+ case ICMD_INVOKESTATIC:
case ICMD_INVOKESPECIAL:
+ case ICMD_INVOKEVIRTUAL:
case ICMD_INVOKEINTERFACE:
- case ICMD_INVOKESTATIC:
COUNT(count_pcmd_met);
- {
- unresolved_method *um = iptr->target;
+ um = iptr->target;
+ md = um->methodref->parseddesc.md;
/* if (lm->flags & ACC_STATIC) */
/* {COUNT(count_check_null);} */
- call_argcount = iptr->op1;
- call_returntype = um->methodref->parseddesc.md->returntype.type;
-
- _callhandling:
- i = call_argcount;
-
- if (i > rd->arguments_num)
- rd->arguments_num = i;
- REQUIRE(i);
+ _callhandling:
+ i = iptr->op1;
- /* Macro in codegen.h */
- SET_ARG_STACKSLOTS;
+ if (i > rd->arguments_num)
+ rd->arguments_num = i;
+ REQUIRE(i);
- while (copy) {
- copy->flags |= SAVEDVAR;
- copy = copy->prev;
+ copy = curstack;
+ for (i-- ; i >= 0; i--) {
+ if (!(copy->flags & SAVEDVAR)) {
+ copy->varkind = ARGVAR;
+ copy->varnum = i;
+ if (md->params[i].inmemory) {
+ copy->flags = INMEMORY;
+ copy->regoff = md->params[i].regoff;
+ } else {
+ copy->flags = 0;
+ if (IS_FLT_DBL_TYPE(copy->type))
+ copy->regoff = rd->argfltregs[md->params[i].regoff];
+ else
+ copy->regoff = rd->argintregs[md->params[i].regoff];
+ }
}
- i = call_argcount;
+ copy = copy->prev;
+ }
- POPMANY(i);
- if (call_returntype != TYPE_VOID)
- OP0_1(call_returntype);
- break;
+ while (copy) {
+ copy->flags |= SAVEDVAR;
+ copy = copy->prev;
}
+ i = iptr->op1;
+ POPMANY(i);
+ if (md->returntype.type != TYPE_VOID)
+ OP0_1(md->returntype.type);
+ break;
+
case ICMD_INLINE_START:
case ICMD_INLINE_END:
SETDST;
i = iptr->op1;
REQUIRE(i);
-#ifdef SPECIALMEMUSE
- if (rd->ifmemuse < (i + rd->intreg_argnum + 6))
- rd->ifmemuse = i + rd->intreg_argnum + 6;
+#if defined(SPECIALMEMUSE)
+# if defined(__DARWIN__)
+ if (rd->ifmemuse < (i + INT_ARG_CNT + LA_WORD_SIZE))
+ rd->ifmemuse = i + LA_WORD_SIZE + INT_ARG_CNT;
+# else
+ if (rd->ifmemuse < (i + LA_WORD_SIZE + 3))
+ rd->ifmemuse = i + LA_WORD_SIZE + 3;
+# endif
#else
# if defined(__I386__)
if (rd->ifmemuse < i + 3)
if (!(copy->flags & SAVEDVAR)) {
copy->varkind = ARGVAR;
copy->varnum = i + INT_ARG_CNT;
- copy->flags|=INMEMORY;
+ copy->flags |= INMEMORY;
#if defined(SPECIALMEMUSE)
- copy->regoff = i + rd->intreg_argnum + 6;
+# if defined(__DARWIN__)
+ copy->regoff = i + LA_WORD_SIZE + INT_ARG_CNT;
+# else
+ copy->regoff = i + LA_WORD_SIZE + 3;
+# endif
#else
# if defined(__I386__)
copy->regoff = i + 3;
#endif
-char *icmd_builtin_name(functionptr bptr)
-{
- builtin_descriptor *bdesc = builtin_desc;
- while ((bdesc->opcode != 0) && (bdesc->builtin != bptr))
- bdesc++;
- return (bdesc->opcode) ? bdesc->name : "<NOT IN TABLE>";
-}
-
-
static char *jit_type[] = {
"int",
"lng",
printf(" %g,", iptr->val.d);
break;
}
-#if defined(__X86_64__) || defined(__I386__) || defined(__ALPHA__) || defined(__MIPS__)
if (iptr->opc == ICMD_PUTFIELDCONST)
printf(" NOT RESOLVED,");
printf(" ");
printf(" (type ");
utf_display(((unresolved_field *) iptr[1].target)->fieldref->descriptor);
printf(")");
-#else
- if (iptr->opc == ICMD_PUTFIELDCONST)
- printf(" %d,", ((fieldinfo *) iptr[1].val.a)->offset);
- printf(" ");
- utf_display_classname(((fieldinfo *) iptr[1].val.a)->class->name);
- printf(".");
- utf_display(((fieldinfo *) iptr[1].val.a)->name);
- printf(" (type ");
- utf_display(((fieldinfo *) iptr[1].val.a)->descriptor);
- printf(")");
-#endif
break;
case ICMD_IINC:
case ICMD_INLINE_END:
break;
- case ICMD_BUILTIN3:
- case ICMD_BUILTIN2:
- case ICMD_BUILTIN1:
- printf(" %s", icmd_builtin_name((functionptr) iptr->val.fp));
+ case ICMD_BUILTIN:
+ printf(" %s", ((builtintable_entry *) iptr->val.a)->name);
break;
case ICMD_INVOKEVIRTUAL: