Changes: Edwin Steiner
Christian Thalinger
+ Christian Ullrich
- $Id: stack.c 2709 2005-06-15 13:57:07Z christian $
+ $Id: stack.c 3218 2005-09-19 13:25:47Z twisti $
*/
#include <stdio.h>
#include <string.h>
-#include "disass.h"
-#include "types.h"
+#include "vm/types.h"
+
+#include "arch.h"
#include "md-abi.h"
-#include "codegen.h"
#include "mm/memory.h"
#include "native/native.h"
#include "vm/stringlocal.h"
#include "vm/tables.h"
#include "vm/jit/codegen.inc.h"
+#include "vm/jit/disass.h"
#include "vm/jit/jit.h"
#include "vm/jit/reg.h"
#include "vm/jit/stack.h"
#include "vm/jit/lsra.h"
+/* global variables ***********************************************************/
+
+#if defined(USE_THREADS)
+static java_objectheader show_icmd_lock;
+#endif
+
+
+/* stack_init ******************************************************************
+
+ Initialized the stack analysis subsystem (called by jit_init).
+
+*******************************************************************************/
+
+bool stack_init(void)
+{
+#if defined(USE_THREADS)
+ /* initialize the show lock */
+
+ show_icmd_lock.monitorPtr = get_dummyLR();
+#endif
+
+ /* everything's ok */
+
+ return true;
+}
+
+
/**********************************************************************/
/* analyse_stack */
/**********************************************************************/
for (i = 0; i < cd->maxlocals; i++)
argren[i] = i;
- rd->arguments_num = 0;
new = m->stack;
loops = 0;
m->basicblocks[0].flags = BBREACHED;
/* iptr->target = NULL; */
#if defined(USEBUILTINTABLE)
- 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;
+# if defined(ENABLE_INTRP)
+ if (!opt_intrp) {
+# endif
+ 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;
+ }
+# if defined(ENABLE_INTRP)
}
+# endif
#endif /* defined(USEBUILTINTABLE) */
switch (opcode) {
break;
case ICMD_RET:
- rd->locals[iptr->op1][TYPE_ADR].type = TYPE_ADR;
+#if defined(ENABLE_INTRP)
+ if (!opt_intrp)
+#endif
+ rd->locals[iptr->op1][TYPE_ADR].type = TYPE_ADR;
case ICMD_RETURN:
COUNT(count_pcmd_return);
SETDST;
iptr[0].opc = ICMD_IFEQ;
icmd_if_icmp_tail:
iptr[0].op1 = iptr[1].op1;
+ /* IF_ICMPxx is the last instruction in the */
+ /* basic block, just remove it */
+ /* iptr[1].opc = ICMD_NOP; */
bptr->icount--;
len--;
-#if 1
- /* iptr[1].opc = ICMD_NOP; */
+
OP1_0(TYPE_INT);
tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
MARKREACHED(tbptr, copy);
COUNT(count_pcmd_bra);
-#else
- goto icmd_if;
-#endif
break;
case ICMD_IF_ICMPLT:
iptr[0].opc = ICMD_IFLT;
case ICMD_BASTORE:
case ICMD_CASTORE:
case ICMD_SASTORE:
+# if defined(ENABLE_INTRP)
+ if (!opt_intrp) {
+# endif
#if SUPPORT_CONST_STORE_ZERO_ONLY
- if (iptr[0].val.i == 0) {
+ if (iptr[0].val.i == 0) {
#endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
- switch (iptr[1].opc) {
- case ICMD_IASTORE:
- iptr[0].opc = ICMD_IASTORECONST;
- break;
- case ICMD_BASTORE:
- iptr[0].opc = ICMD_BASTORECONST;
- break;
- case ICMD_CASTORE:
- iptr[0].opc = ICMD_CASTORECONST;
- break;
- case ICMD_SASTORE:
- iptr[0].opc = ICMD_SASTORECONST;
- break;
- }
-
- iptr[1].opc = ICMD_NOP;
- OPTT2_0(TYPE_INT, TYPE_ADR);
- COUNT(count_pcmd_op);
+ switch (iptr[1].opc) {
+ case ICMD_IASTORE:
+ iptr[0].opc = ICMD_IASTORECONST;
+ break;
+ case ICMD_BASTORE:
+ iptr[0].opc = ICMD_BASTORECONST;
+ break;
+ case ICMD_CASTORE:
+ iptr[0].opc = ICMD_CASTORECONST;
+ break;
+ case ICMD_SASTORE:
+ iptr[0].opc = ICMD_SASTORECONST;
+ break;
+ }
+
+ iptr[1].opc = ICMD_NOP;
+ OPTT2_0(TYPE_INT, TYPE_ADR);
+ COUNT(count_pcmd_op);
#if SUPPORT_CONST_STORE_ZERO_ONLY
+ } else
+ PUSHCONST(TYPE_INT);
+#endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
+# if defined(ENABLE_INTRP)
} else
PUSHCONST(TYPE_INT);
-#endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
+# endif
break;
case ICMD_PUTSTATIC:
#if SUPPORT_CONST_STORE
case ICMD_LASTORE:
+# if defined(ENABLE_INTRP)
+ if (!opt_intrp) {
+# endif
#if SUPPORT_CONST_STORE_ZERO_ONLY
- if (iptr[0].val.l == 0) {
+ if (iptr[0].val.l == 0) {
#endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
- iptr[0].opc = ICMD_LASTORECONST;
- iptr[1].opc = ICMD_NOP;
- OPTT2_0(TYPE_INT, TYPE_ADR);
- COUNT(count_pcmd_op);
+ iptr[0].opc = ICMD_LASTORECONST;
+ iptr[1].opc = ICMD_NOP;
+ OPTT2_0(TYPE_INT, TYPE_ADR);
+ COUNT(count_pcmd_op);
#if SUPPORT_CONST_STORE_ZERO_ONLY
+ } else
+ PUSHCONST(TYPE_LNG);
+#endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
+# if defined(ENABLE_INTRP)
} else
PUSHCONST(TYPE_LNG);
-#endif /* SUPPORT_CONST_STORE_ZERO_ONLY */
+# endif
break;
case ICMD_PUTSTATIC:
#if SUPPORT_CONST_STORE
if (len > 0 && iptr->val.a == 0) {
switch (iptr[1].opc) {
+#if !defined(__POWERPC__) && !defined(__X86_64__) && !defined(__I386__) && !defined(__ALPHA__) && !defined(__MIPS__)
case ICMD_BUILTIN:
if (iptr[1].val.fp != BUILTIN_aastore) {
PUSHCONST(TYPE_ADR);
break;
}
/* fall through */
+#endif
case ICMD_PUTSTATIC:
case ICMD_PUTFIELD:
switch (iptr[1].opc) {
case ICMD_DLOAD:
case ICMD_ALOAD:
COUNT(count_load_instruction);
- i = opcode-ICMD_ILOAD;
+ i = opcode - ICMD_ILOAD;
iptr->op1 = argren[iptr->op1];
- rd->locals[iptr->op1][i].type = i;
+#if defined(ENABLE_INTRP)
+ if (!opt_intrp)
+#endif
+ rd->locals[iptr->op1][i].type = i;
LOAD(i, LOCALVAR, iptr->op1);
break;
COUNT(count_check_null);
COUNT(count_check_bound);
COUNT(count_pcmd_mem);
- OP2IAT_1(opcode-ICMD_IALOAD);
+ OP2IAT_1(opcode - ICMD_IALOAD);
break;
case ICMD_BALOAD:
REQUIRE_1;
i = opcode - ICMD_ISTORE;
- rd->locals[iptr->op1][i].type = i;
+#if defined(ENABLE_INTRP)
+ if (!opt_intrp)
+#endif
+ rd->locals[iptr->op1][i].type = i;
#if defined(STATISTICS)
if (opt_stat) {
count_pcmd_store++;
curstack->varkind = LOCALVAR;
curstack->varnum = iptr->op1;
};
- STORE(opcode-ICMD_ISTORE);
+ STORE(opcode - ICMD_ISTORE);
break;
/* pop 3 push 0 */
- case ICMD_IASTORE:
case ICMD_AASTORE:
+ COUNT(count_check_null);
+ COUNT(count_check_bound);
+ COUNT(count_pcmd_mem);
+
+ bte = (builtintable_entry *) iptr->val.a;
+ md = bte->md;
+ i = iptr->op1;
+
+ if (md->memuse > rd->memuse)
+ rd->memuse = md->memuse;
+ if (md->argintreguse > rd->argintreguse)
+ rd->argintreguse = md->argintreguse;
+
+ /* make all stack variables saved */
+
+ copy = curstack;
+ while (copy) {
+ copy->flags |= SAVEDVAR;
+ copy = copy->prev;
+ }
+
+ OP3TIA_0(TYPE_ADR);
+ break;
+
+ case ICMD_IASTORE:
case ICMD_LASTORE:
case ICMD_FASTORE:
case ICMD_DASTORE:
COUNT(count_check_null);
COUNT(count_check_bound);
COUNT(count_pcmd_mem);
- OP3TIA_0(opcode-ICMD_IASTORE);
+ OP3TIA_0(opcode - ICMD_IASTORE);
break;
case ICMD_BASTORE:
case ICMD_FRETURN:
case ICMD_DRETURN:
case ICMD_ARETURN:
+ md_return_alloc(m, rd, opcode - ICMD_IRETURN, curstack);
COUNT(count_pcmd_return);
- OP1_0(opcode-ICMD_IRETURN);
+ OP1_0(opcode - ICMD_IRETURN);
superblockend = true;
break;
case ICMD_IFGE:
case ICMD_IFGT:
case ICMD_IFLE:
-#if 0
- icmd_if:
-#endif
COUNT(count_pcmd_bra);
#if CONDITIONAL_LOADCONST
- tbptr = m->basicblocks + b_index;
- if ((b_count >= 3) &&
- ((b_index + 2) == m->basicblockindex[iptr[0].op1]) &&
- (tbptr[1].pre_count == 1) &&
- (tbptr[1].iinstr[0].opc == ICMD_ICONST) &&
- (tbptr[1].iinstr[1].opc == ICMD_GOTO) &&
- ((b_index + 3) == m->basicblockindex[tbptr[1].iinstr[1].op1]) &&
- (tbptr[2].pre_count == 1) &&
- (tbptr[2].iinstr[0].opc == ICMD_ICONST) &&
- (tbptr[2].icount==1)) {
+# if defined(ENABLE_INTRP)
+ if (!opt_intrp) {
+# endif
+ tbptr = m->basicblocks + b_index;
+ if ((b_count >= 3) &&
+ ((b_index + 2) == m->basicblockindex[iptr[0].op1]) &&
+ (tbptr[1].pre_count == 1) &&
+ (tbptr[1].iinstr[0].opc == ICMD_ICONST) &&
+ (tbptr[1].iinstr[1].opc == ICMD_GOTO) &&
+ ((b_index + 3) == m->basicblockindex[tbptr[1].iinstr[1].op1]) &&
+ (tbptr[2].pre_count == 1) &&
+ (tbptr[2].iinstr[0].opc == ICMD_ICONST) &&
+ (tbptr[2].icount==1)) {
/*printf("tbptr[2].icount=%d\n",tbptr[2].icount);*/
OP1_1(TYPE_INT, TYPE_INT);
switch (iptr[0].opc) {
- case ICMD_IFEQ:
- iptr[0].opc = ICMD_IFNE_ICONST;
- break;
- case ICMD_IFNE:
- iptr[0].opc = ICMD_IFEQ_ICONST;
- break;
- case ICMD_IFLT:
- iptr[0].opc = ICMD_IFGE_ICONST;
- break;
- case ICMD_IFGE:
- iptr[0].opc = ICMD_IFLT_ICONST;
- break;
- case ICMD_IFGT:
- iptr[0].opc = ICMD_IFLE_ICONST;
- break;
- case ICMD_IFLE:
- iptr[0].opc = ICMD_IFGT_ICONST;
- break;
- }
+ case ICMD_IFEQ:
+ iptr[0].opc = ICMD_IFNE_ICONST;
+ break;
+ case ICMD_IFNE:
+ iptr[0].opc = ICMD_IFEQ_ICONST;
+ break;
+ case ICMD_IFLT:
+ iptr[0].opc = ICMD_IFGE_ICONST;
+ break;
+ case ICMD_IFGE:
+ iptr[0].opc = ICMD_IFLT_ICONST;
+ break;
+ case ICMD_IFGT:
+ iptr[0].opc = ICMD_IFLE_ICONST;
+ break;
+ case ICMD_IFLE:
+ iptr[0].opc = ICMD_IFGT_ICONST;
+ break;
+ }
#if 1
iptr[0].val.i = iptr[1].val.i;
iptr[1].opc = ICMD_ELSE_ICONST;
iptr[2].opc = ICMD_NOP;
iptr[3].opc = ICMD_NOP;
#else
- /* HACK: save compare value in iptr[1].op1 */
- iptr[1].op1 = iptr[0].val.i;
- iptr[0].val.i = tbptr[1].iinstr[0].val.i;
- iptr[1].opc = ICMD_ELSE_ICONST;
- iptr[1].val.i = tbptr[2].iinstr[0].val.i;
- tbptr[1].iinstr[0].opc = ICMD_NOP;
- tbptr[1].iinstr[1].opc = ICMD_NOP;
- tbptr[2].iinstr[0].opc = ICMD_NOP;
+ /* HACK: save compare value in iptr[1].op1 */
+ iptr[1].op1 = iptr[0].val.i;
+ iptr[0].val.i = tbptr[1].iinstr[0].val.i;
+ iptr[1].opc = ICMD_ELSE_ICONST;
+ iptr[1].val.i = tbptr[2].iinstr[0].val.i;
+ tbptr[1].iinstr[0].opc = ICMD_NOP;
+ tbptr[1].iinstr[1].opc = ICMD_NOP;
+ tbptr[2].iinstr[0].opc = ICMD_NOP;
#endif
tbptr[1].flags = BBDELETED;
tbptr[2].flags = BBDELETED;
bptr->icount++;
len ++;
}
- b_index += 2;
- break;
+ b_index += 2;
+ break;
+ }
+# if defined(ENABLE_INTRP)
}
+# endif
+
#endif /* CONDITIONAL_LOADCONST */
OP1_0(TYPE_INT);
+ iptr->val.i = 0;
tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
iptr[0].target = (void *) tbptr;
break;
/* pop 2 push 1 */
-
- case ICMD_IDIV:
-#if !SUPPORT_DIVISION
- bte = builtintable_get_internal(BUILTIN_idiv);
- iptr->opc = ICMD_BUILTIN;
- iptr->op1 = bte->md->paramcount;
- iptr->val.a = bte;
- m->isleafmethod = false;
- goto builtin;
-#endif
+ case ICMD_IDIV:
case ICMD_IREM:
#if !SUPPORT_DIVISION
- bte = builtintable_get_internal(BUILTIN_irem);
- iptr->opc = ICMD_BUILTIN;
- iptr->op1 = bte->md->paramcount;
- iptr->val.a = bte;
- m->isleafmethod = false;
- goto builtin;
-#endif
+ bte = (builtintable_entry *) iptr->val.a;
+ md = bte->md;
+ i = iptr->op1;
+
+ if (md->memuse > rd->memuse)
+ rd->memuse = md->memuse;
+ if (md->argintreguse > rd->argintreguse)
+ rd->argintreguse = md->argintreguse;
+
+ /* make all stack variables saved */
+
+ copy = curstack;
+ while (copy) {
+ copy->flags |= SAVEDVAR;
+ copy = copy->prev;
+ }
+#endif /* !SUPPORT_DIVISION */
case ICMD_ISHL:
case ICMD_ISHR:
break;
case ICMD_LDIV:
-#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
- bte = builtintable_get_internal(BUILTIN_ldiv);
- iptr->opc = ICMD_BUILTIN;
- iptr->op1 = bte->md->paramcount;
- iptr->val.a = bte;
- m->isleafmethod = false;
- goto builtin;
-#endif
-
case ICMD_LREM:
#if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
- bte = builtintable_get_internal(BUILTIN_lrem);
- iptr->opc = ICMD_BUILTIN;
- iptr->op1 = bte->md->paramcount;
- iptr->val.a = bte;
- m->isleafmethod = false;
- goto builtin;
-#endif
+ bte = (builtintable_entry *) iptr->val.a;
+ md = bte->md;
+ i = iptr->op1;
+
+ if (md->memuse > rd->memuse)
+ rd->memuse = md->memuse;
+ if (md->argintreguse > rd->argintreguse)
+ rd->argintreguse = md->argintreguse;
+
+ /* make all stack variables saved */
+
+ copy = curstack;
+ while (copy) {
+ copy->flags |= SAVEDVAR;
+ copy = copy->prev;
+ }
+#endif /* !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) */
case ICMD_LMUL:
case ICMD_LADD:
OP1_1(TYPE_ADR, TYPE_ADR);
break;
+ case ICMD_ARRAYCHECKCAST:
+ bte = (builtintable_entry *) iptr->val.a;
+ md = bte->md;
+
+ if (md->memuse > rd->memuse)
+ rd->memuse = md->memuse;
+ if (md->argintreguse > rd->argintreguse)
+ rd->argintreguse = md->argintreguse;
+
+ /* make all stack variables saved */
+
+ copy = curstack;
+ while (copy) {
+ copy->flags |= SAVEDVAR;
+ copy = copy->prev;
+ }
+
+ OP1_1(TYPE_ADR, TYPE_ADR);
+ break;
+
case ICMD_INSTANCEOF:
case ICMD_ARRAYLENGTH:
OP1_1(TYPE_ADR, TYPE_INT);
/* pop many push any */
case ICMD_BUILTIN:
+#if defined(USEBUILTINTABLE)
builtin:
+#endif
bte = (builtintable_entry *) iptr->val.a;
md = bte->md;
goto _callhandling;
_callhandling:
i = iptr->op1;
- if (md->memuse > rd->ifmemuse)
- rd->ifmemuse = md->memuse;
+ if (md->memuse > rd->memuse)
+ rd->memuse = md->memuse;
if (md->argintreguse > rd->argintreguse)
rd->argintreguse = md->argintreguse;
- if (md->argfltreguse > rd->argintreguse)
- rd->argfltreguse = md->argintreguse;
+ if (md->argfltreguse > rd->argfltreguse)
+ rd->argfltreguse = md->argfltreguse;
- if (i > rd->arguments_num)
- rd->arguments_num = i;
REQUIRE(i);
copy = curstack;
for (i-- ; i >= 0; i--) {
+#if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
+ /* If we pass float arguments in integer argument registers, we
+ * are not allowed to precolor them here. Floats have to be moved
+ * to this regs explicitly in codegen().
+ * Only arguments that are passed by stack anyway can be precolored
+ * (michi 2005/07/24) */
+ if (!(copy->flags & SAVEDVAR) &&
+ (!IS_FLT_DBL_TYPE(copy->type) || md->params[i].inmemory)) {
+#else
if (!(copy->flags & SAVEDVAR)) {
+#endif
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 {
+
+#if defined(ENABLE_INTRP)
+ if (!opt_intrp) {
+#endif
+ 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))
+#if defined(SUPPORT_PASS_FLOATARGS_IN_INTREGS)
+ assert(0);
+#else
copy->regoff =
- rd->argintregs[md->params[i].regoff];
+ rd->argfltregs[md->params[i].regoff];
+#endif
+ else {
#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
- if (IS_2_WORD_TYPE(copy->type))
- SET_SECOND_REG( copy->regoff,
- rd->argintregs[md->params[i].regoff + 1]);
+ if (IS_2_WORD_TYPE(copy->type))
+ copy->regoff = PACK_REGS(
+ rd->argintregs[GET_LOW_REG(md->params[i].regoff)],
+ rd->argintregs[GET_HIGH_REG(md->params[i].regoff)]);
+ else
#endif
+ copy->regoff =
+ rd->argintregs[md->params[i].regoff];
+ }
}
+#if defined(ENABLE_INTRP)
}
+#endif
}
copy = copy->prev;
}
REQUIRE(i);
#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;
+ if (rd->memuse < (i + INT_ARG_CNT + LA_WORD_SIZE))
+ rd->memuse = i + LA_WORD_SIZE + INT_ARG_CNT;
# else
- if (rd->ifmemuse < (i + LA_WORD_SIZE + 3))
- rd->ifmemuse = i + LA_WORD_SIZE + 3;
+ if (rd->memuse < (i + LA_WORD_SIZE + 3))
+ rd->memuse = i + LA_WORD_SIZE + 3;
# endif
#else
# if defined(__I386__)
- if (rd->ifmemuse < i + 3)
- rd->ifmemuse = i + 3; /* n integer args spilled on stack */
+ if (rd->memuse < i + 3)
+ rd->memuse = i + 3; /* n integer args spilled on stack */
# else
- if (rd->ifmemuse < i)
- rd->ifmemuse = i; /* n integer args spilled on stack */
+ if (rd->memuse < i)
+ rd->memuse = i; /* n integer args spilled on stack */
# endif /* defined(__I386__) */
#endif
- if ((i + INT_ARG_CNT) > rd->arguments_num)
- rd->arguments_num = i + INT_ARG_CNT;
copy = curstack;
while (--i >= 0) {
/* check INT type here? Currently typecheck does this. */
j = cd->maxstack - i;
while (--i >= 0)
printf(" ");
+
while (s) {
j--;
- /* DEBUG */ /*printf("(%d,%d,%d,%d)",s->varkind,s->flags,s->regoff,s->varnum); fflush(stdout);*/
if (s->flags & SAVEDVAR)
switch (s->varkind) {
case TEMPVAR:
else {
#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
if (IS_2_WORD_TYPE(s->type))
- printf(" %3s/%3s", regs[GET_FIRST_REG(s->regoff)],
- regs[GET_SECOND_REG(s->regoff)]);
+ printf(" %3s/%3s", regs[GET_LOW_REG(s->regoff)],
+ regs[GET_HIGH_REG(s->regoff)]);
else
- printf(" %3s", regs[GET_FIRST_REG(s->regoff)]);
+#endif
+#if defined(ENABLE_INTRP)
+ printf(" %3d", s->regoff);
#else
- printf(" %3s", regs[s->regoff]);
+ printf(" %3s", regs[s->regoff]);
#endif
}
break;
printf(" L%02d", s->varnum);
break;
case ARGVAR:
- printf(" A%02d", s->varnum);
+ if (s->varnum == -1) {
+ /* Return Value */
+ /* varkind ARGVAR "misused for this special case */
+ printf(" RA");
+ } else /* "normal" Argvar */
+ printf(" A%02d", s->varnum);
#ifdef INVOKE_NEW_DEBUG
if (s->flags & INMEMORY)
printf("(M%i)", s->regoff);
else {
#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
if (IS_2_WORD_TYPE(s->type))
- printf(" %3s/%3s", regs[GET_FIRST_REG(s->regoff)],
- regs[GET_SECOND_REG(s->regoff)]);
+ printf(" %3s/%3s", regs[GET_LOW_REG(s->regoff)],
+ regs[GET_HIGH_REG(s->regoff)]);
else
- printf(" %3s", regs[GET_FIRST_REG(s->regoff)]);
+#endif
+#if defined(ENABLE_INTRP)
+ printf(" %3d", s->regoff);
#else
- printf(" %3s", regs[s->regoff]);
+ printf(" %3s", regs[s->regoff]);
#endif
}
break;
printf(" l%02d", s->varnum);
break;
case ARGVAR:
+ if (s->varnum == -1) {
+ /* Return Value */
+ /* varkind ARGVAR "misused for this special case */
+ printf(" ra");
+ } else /* "normal" Argvar */
printf(" a%02d", s->varnum);
#ifdef INVOKE_NEW_DEBUG
if (s->flags & INMEMORY)
};
+/* show_icmd_method ************************************************************
+
+ XXX
+
+*******************************************************************************/
+
void show_icmd_method(methodinfo *m, codegendata *cd, registerdata *rd)
{
- int i, j;
- basicblock *bptr;
+ basicblock *bptr;
exceptiontable *ex;
+ s4 i, j;
+ u1 *u1ptr;
+
+#if defined(USE_THREADS)
+ /* We need to enter a lock here, since the binutils disassembler is not */
+ /* reentrant-able and we could not read functions printed at the same */
+ /* time. */
+
+ builtin_monitorenter(&show_icmd_lock);
+#endif
printf("\n");
utf_fprint_classname(stdout, m->class->name);
utf_fprint(stdout, m->descriptor);
printf("\n\nMax locals: %d\n", (int) cd->maxlocals);
printf("Max stack: %d\n", (int) cd->maxstack);
-
printf("Line number table length: %d\n", m->linenumbercount);
printf("Exceptions (Number: %d):\n", cd->exceptiontablelength);
printf("Local Table:\n");
for (i = 0; i < cd->maxlocals; i++) {
printf(" %3d: ", i);
- for (j = TYPE_INT; j <= TYPE_ADR; j++)
- if (rd->locals[i][j].type >= 0) {
- printf(" (%s) ", jit_type[j]);
- if (rd->locals[i][j].flags & INMEMORY)
- printf("m%2d", rd->locals[i][j].regoff);
+ 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 (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);
+ 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 {
+ 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_FIRST_REG(rd->locals[i][j].regoff)],
- regs[GET_SECOND_REG(rd->locals[i][j].regoff)]);
- else
- printf("%3s",
- regs[GET_FIRST_REG(rd->locals[i][j].regoff)]);
-#else
- printf("%3s", regs[rd->locals[i][j].regoff]);
+ 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]);
+ }
}
+#if defined(ENABLE_INTRP)
}
+#endif
+ }
printf("\n");
}
printf("\n");
+
#ifdef LSRA
if (!opt_lsra) {
+#endif
+#if defined(ENABLE_INTRP)
+ if (!opt_intrp) {
#endif
printf("Interface Table:\n");
for (i = 0; i < cd->maxstack; i++) {
#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
if (IS_2_WORD_TYPE(j))
printf(" %3s/%3s",
- regs[GET_FIRST_REG(rd->interfaces[i][j].regoff)],
- regs[GET_SECOND_REG(rd->interfaces[i][j].regoff)]);
+ regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
+ regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
else
- printf("%3s",
- regs[GET_FIRST_REG(rd->interfaces[i][j].regoff)]);
-#else
- printf("%3s", regs[rd->interfaces[i][j].regoff]);
#endif
+ printf("%3s",regs[rd->interfaces[i][j].regoff]);
}
}
else {
#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
if (IS_2_WORD_TYPE(j))
printf(" %3s/%3s",
- regs[GET_FIRST_REG(rd->interfaces[i][j].regoff)],
- regs[GET_SECOND_REG(rd->interfaces[i][j].regoff)]);
+ regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
+ regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
else
- printf("%3s",
- regs[GET_FIRST_REG(rd->interfaces[i][j].regoff)]);
-#else
- printf("%3s",regs[rd->interfaces[i][j].regoff]);
#endif
+ printf("%3s",regs[rd->interfaces[i][j].regoff]);
}
}
}
}
}
printf("\n");
+
+#if defined(ENABLE_INTRP)
+ }
+#endif
#ifdef LSRA
}
#endif
- if (showdisassemble) {
-#if defined(__I386__) || defined(__X86_64__)
- u1 *u1ptr;
- s4 a;
+ /* show code before first basic block */
+
+ if (opt_showdisassemble) {
u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen);
- for (i = 0; i < m->basicblocks[0].mpc;) {
- a = disassinstr(u1ptr);
- i += a;
- u1ptr += a;
- }
- printf("\n");
-#elif defined(__XDSPCORE__)
- s4 *s4ptr;
- s4 a;
- s4ptr = (s4 *) ((ptrint) m->mcode + cd->dseglen);
- for (i = 0; i < m->basicblocks[0].mpc;) {
- a = disassinstr(stdout, s4ptr);
- printf("\n");
- i += a * 4;
- s4ptr += a;
- }
- printf("\n");
-#else
- s4 *s4ptr;
+ for (; u1ptr < (u1 *) ((ptrint) m->mcode + cd->dseglen + m->basicblocks[0].mpc);)
+ u1ptr = disassinstr(u1ptr);
- s4ptr = (s4 *) ((ptrint) m->mcode + cd->dseglen);
- for (i = 0; i < m->basicblocks[0].mpc; i += 4, s4ptr++) {
- disassinstr(s4ptr);
- }
printf("\n");
-#endif
}
-
+
+ /* show code of all basic blocks */
+
for (bptr = m->basicblocks; bptr != NULL; bptr = bptr->next) {
show_icmd_block(m, cd, bptr);
}
+
+ /* show stubs code */
+
+ if (opt_showdisassemble && opt_showexceptionstubs) {
+ printf("\nException stubs code:\n");
+ printf("Length: %d\n\n", (s4) (m->mcodelength -
+ ((ptrint) cd->dseglen +
+ m->basicblocks[m->basicblockcount].mpc)));
+
+ u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen +
+ m->basicblocks[m->basicblockcount].mpc);
+
+ for (; (ptrint) u1ptr < ((ptrint) m->mcode + m->mcodelength);)
+ u1ptr = disassinstr(u1ptr);
+
+ printf("\n");
+ }
+
+#if defined(USE_THREADS)
+ builtin_monitorexit(&show_icmd_lock);
+#endif
}
void show_icmd_block(methodinfo *m, codegendata *cd, basicblock *bptr)
{
- int i, j;
- int deadcode;
+ s4 i, j;
+ bool deadcode;
instruction *iptr;
+ u1 *u1ptr;
if (bptr->flags != BBDELETED) {
deadcode = bptr->flags <= BBREACHED;
}
else
icmd_print_stack(cd, iptr->dst);
- printf("] %4d ", i);
+ printf("] %5d (line: %5d) ", i, iptr->line);
#ifdef LSRA_EDX
if (icmd_uses_tmp[iptr->opc][0])
printf("\n");
}
- if (showdisassemble && (!deadcode)) {
-#if defined(__I386__) || defined(__X86_64__)
- u1 *u1ptr;
- s4 a;
-
- printf("\n");
- i = bptr->mpc;
- u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen + i);
-
- if (bptr->next != NULL) {
- for (; i < bptr->next->mpc; ) {
- a = disassinstr(u1ptr);
- i += a;
- u1ptr += a;
- }
- printf("\n");
-
- } else {
- for (; u1ptr < (u1 *) ((ptrint) m->mcode + m->mcodelength); ) {
- a = disassinstr(u1ptr);
- i += a;
- u1ptr += a;
- }
- printf("\n");
- }
-#elif defined(__XDSPCORE__)
- s4 *s4ptr;
- s4 a;
-
+ if (opt_showdisassemble && (!deadcode)) {
printf("\n");
- i = bptr->mpc;
- s4ptr = (s4 *) ((ptrint) m->mcode + cd->dseglen + i);
+ u1ptr = (u1 *) ((ptrint) m->mcode + cd->dseglen + bptr->mpc);
if (bptr->next != NULL) {
- for (; i < bptr->next->mpc;) {
- a = disassinstr(stdout, s4ptr);
- printf("\n");
- i += a * 4;
- s4ptr += a;
- }
- printf("\n");
+ for (; u1ptr < (u1 *) ((ptrint) m->mcode + cd->dseglen + bptr->next->mpc);)
+ u1ptr = disassinstr(u1ptr);
} else {
- for (; s4ptr < (s4 *) ((ptrint) m->mcode + m->mcodelength); ) {
- a = disassinstr(stdout, s4ptr);
- i += a * 4;
- s4ptr += a;
- }
- printf("\n");
+ for (; u1ptr < (u1 *) ((ptrint) m->mcode + m->mcodelength);)
+ u1ptr = disassinstr(u1ptr);
}
-#else
- s4 *s4ptr;
-
printf("\n");
- i = bptr->mpc;
- s4ptr = (s4 *) ((ptrint) m->mcode + cd->dseglen + i);
-
- if (bptr->next != NULL) {
- for (; i < bptr->next->mpc; i += 4, s4ptr++)
- disassinstr(s4ptr);
- printf("\n");
-
- } else {
- for (; s4ptr < (s4 *) ((ptrint) m->mcode + m->mcodelength); i += 4, s4ptr++)
- disassinstr(s4ptr);
- printf("\n");
- }
-#endif
}
}
}
break;
case ICMD_FCONST:
- printf(" %f", iptr->val.f);
+ printf(" %f (0x%08x)", iptr->val.f, iptr->val.i);
break;
case ICMD_DCONST:
- printf(" %f", iptr->val.d);
+#if SIZEOF_VOID_P == 4
+ printf(" %g (0x%016llx)", iptr->val.d, iptr->val.l);
+#else
+ printf(" %g (0x%016lx)", iptr->val.d, iptr->val.l);
+#endif
break;
case ICMD_ACONST:
case ICMD_PUTSTATIC:
case ICMD_GETSTATIC:
- if (iptr->val.a)
- printf(" ");
- else
+ if (iptr->val.a) {
+ if (!((fieldinfo *) iptr->val.a)->class->initialized)
+ printf(" (NOT INITIALIZED) ");
+ else
+ printf(" ");
+ } else
printf(" (NOT RESOLVED) ");
utf_display_classname(((unresolved_field *) iptr->target)->fieldref->classref->name);
printf(".");
case ICMD_CHECKCAST:
case ICMD_INSTANCEOF:
- if (iptr->op1) {
+ {
classinfo *c = iptr->val.a;
if (c) {
if (c->flags & ACC_INTERFACE)
}
break;
+ case ICMD_ARRAYCHECKCAST:
+ if (iptr->op1) {
+ classinfo *c = ((vftbl_t *) iptr->target)->class;
+ if (c->flags & ACC_INTERFACE)
+ printf(" (INTERFACE) ");
+ else
+ printf(" (CLASS,%3d) ", c->vftbl->diffval);
+ utf_display_classname(c->name);
+ } else {
+ printf(" (NOT RESOLVED) ");
+ utf_display_classname(((constant_classref *) iptr->target)->name);
+ }
+ break;
+
case ICMD_INLINE_START:
- printf("\t\t\t%s.%s%s depth=%i",iptr->method->class->name->text,iptr->method->name->text,iptr->method->descriptor->text, iptr->op1);
+ printf(" ");
+ utf_display_classname(iptr->method->class->name);
+ printf(".");
+ utf_display_classname(iptr->method->name);
+ utf_display_classname(iptr->method->descriptor);
+ printf(", depth=%i", iptr->op1);
break;
case ICMD_INLINE_END:
break;
}
break;
}
- printf(" Line number: %d, method:",iptr->line);
-/* printf("\t\t");
- utf_display(iptr->method->class->name);
- printf(".");
- utf_display(iptr->method->name); */
}