Changes: Edwin Steiner
Christian Thalinger
+ Christian Ullrich
- $Id: stack.c 2044 2005-03-20 14:28:36Z edwin $
+ $Id: stack.c 3699 2005-11-17 18:53:07Z twisti $
*/
+#include <assert.h>
#include <stdio.h>
#include <string.h>
-#include "disass.h"
-#include "types.h"
+#include "vm/types.h"
+
+#include "arch.h"
+#include "md-abi.h"
+
#include "mm/memory.h"
#include "native/native.h"
#include "toolbox/logging.h"
#include "vm/global.h"
#include "vm/builtin.h"
#include "vm/options.h"
+#include "vm/resolve.h"
#include "vm/statistics.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;
+}
/**********************************************************************/
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;
+ 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;
+#endif
argren = DMNEW(s4, cd->maxlocals); /* table for argument renaming */
for (i = 0; i < cd->maxlocals; i++)
argren[i] = i;
- rd->arguments_num = 0;
new = m->stack;
loops = 0;
m->basicblocks[0].flags = BBREACHED;
NEWXSTACK;
}
-#ifdef CONDITIONAL_LOADCONST
+#if CONDITIONAL_LOADCONST
b_count = m->basicblockcount;
bptr = m->basicblocks;
while (--b_count >= 0) {
}
bptr++;
}
-#endif
+#endif /* CONDITIONAL_LOADCONST */
do {
repeat = false;
STACKRESET;
deadcode = true;
+
while (--b_count >= 0) {
if (bptr->flags == BBDELETED) {
/* do nothing */
- }
- else if (superblockend && (bptr->flags < BBREACHED))
+
+ } else if (superblockend && (bptr->flags < BBREACHED)) {
repeat = true;
- else if (bptr->flags <= BBREACHED) {
- if (superblockend)
+
+ } else if (bptr->flags <= BBREACHED) {
+ if (superblockend) {
stackdepth = bptr->indepth;
- else if (bptr->flags < BBREACHED) {
+
+ } else if (bptr->flags < BBREACHED) {
COPYCURSTACK(copy);
bptr->instack = copy;
bptr->indepth = stackdepth;
+
+ } else if (bptr->indepth != stackdepth) {
+ /*show_icmd_method(m, cd, rd);
+ printf("Block: %d, required depth: %d, current depth: %d\n",
+ bptr->debug_nr, bptr->indepth, stackdepth);*/
+ *exceptionptr = new_verifyerror(m,"Stack depth mismatch");
+ return NULL;
}
- else if (bptr->indepth != stackdepth) {
- show_icmd_method(m, cd, rd);
- printf("Block: %d, required depth: %d, current depth: %d\n", bptr->debug_nr, bptr->indepth, stackdepth);
- panic("Stack depth mismatch");
-
- }
+
curstack = bptr->instack;
deadcode = false;
superblockend = false;
len = bptr->icount;
iptr = bptr->iinstr;
b_index = bptr - m->basicblocks;
+
while (--len >= 0) {
opcode = iptr->opc;
- 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;
+# if defined(ENABLE_INTRP)
+ if (!opt_intrp) {
+# endif
+ bte = builtintable_get_automatic(opcode);
+
+ if (bte && bte->opcode == opcode) {
+ iptr->opc = ICMD_BUILTIN;
+ iptr->op1 = false; /* don't check for exception */
+ iptr->val.a = bte;
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;
- }
+ goto builtin;
}
+# if defined(ENABLE_INTRP)
}
+# endif
#endif /* defined(USEBUILTINTABLE) */
switch (opcode) {
/* pop 0 push 0 */
+ case ICMD_CHECKNULL:
+ COUNT(count_check_null);
case ICMD_NOP:
- case ICMD_CHECKASIZE:
- case ICMD_CHECKEXCEPTION:
case ICMD_IFEQ_ICONST:
case ICMD_IFNE_ICONST:
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_IDIVPOW2;
goto icmd_iconst_tail;
case ICMD_IREM:
+ /*log_text("stack.c: ICMD_ICONST/ICMD_IREM");*/
if ((iptr[0].val.i == 0x00000002) ||
(iptr[0].val.i == 0x00000004) ||
(iptr[0].val.i == 0x00000008) ||
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--;
- /* iptr[1].opc = ICMD_NOP; */
+
OP1_0(TYPE_INT);
tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
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;
- }
+ 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);
+ 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:
}
iptr[1].opc = ICMD_NOP;
- iptr[1].op1 = TYPE_INT;
+ iptr[0].op1 = TYPE_INT;
COUNT(count_pcmd_op);
#if SUPPORT_CONST_STORE_ZERO_ONLY
} else
iptr[0].opc = ICMD_LXORCONST;
goto icmd_lconst_tail;
#endif /* SUPPORT_LONG_LOGICAL && SUPPORT_CONST_LOGICAL */
-#if !defined(NOLONG_CONDITIONAL)
+
+#if SUPPORT_LONG_CMP_CONST
case ICMD_LCMP:
if ((len > 1) && (iptr[2].val.i == 0)) {
switch (iptr[2].opc) {
else
PUSHCONST(TYPE_LNG);
break;
-#endif /* !defined(NOLONG_CONDITIONAL) */
+#endif /* SUPPORT_LONG_CMP_CONST */
#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:
}
iptr[1].opc = ICMD_NOP;
- iptr[1].op1 = TYPE_LNG;
+ iptr[0].op1 = TYPE_LNG;
COUNT(count_pcmd_op);
#if SUPPORT_CONST_STORE_ZERO_ONLY
} else
#if SUPPORT_CONST_STORE
if (len > 0 && iptr->val.a == 0) {
switch (iptr[1].opc) {
- case ICMD_BUILTIN3:
+#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_BUILTIN3:
+ case ICMD_BUILTIN:
iptr[0].opc = ICMD_AASTORECONST;
OPTT2_0(TYPE_INT, TYPE_ADR);
break;
case ICMD_PUTSTATIC:
iptr[0].opc = ICMD_PUTSTATICCONST;
+ iptr[0].op1 = TYPE_ADR;
SETDST;
break;
case ICMD_PUTFIELD:
iptr[0].opc = ICMD_PUTFIELDCONST;
+ iptr[0].op1 = TYPE_ADR;
OP1_0(TYPE_ADR);
break;
}
iptr[1].opc = ICMD_NOP;
- iptr[1].op1 = TYPE_ADR;
COUNT(count_pcmd_op);
break;
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_get_internal(BUILTIN_canstore);
+ 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;
+ }
+
+ 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_IFGT:
case ICMD_IFLE:
COUNT(count_pcmd_bra);
-#ifdef CONDITIONAL_LOADCONST
- {
+#if CONDITIONAL_LOADCONST
+# 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) &&
- (iptr[1].opc == ICMD_ICONST) &&
- (iptr[2].opc == ICMD_GOTO) &&
- ((b_index + 3) == m->basicblockindex[iptr[2].op1]) &&
- (tbptr[2].pre_count == 1) &&
- (iptr[3].opc == ICMD_ICONST)) {
+ ((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_IFGT_ICONST;
break;
}
+#if 1
iptr[0].val.i = iptr[1].val.i;
iptr[1].opc = ICMD_ELSE_ICONST;
iptr[1].val.i = iptr[3].val.i;
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;
+#endif
tbptr[1].flags = BBDELETED;
tbptr[2].flags = BBDELETED;
tbptr[1].icount = 0;
b_index += 2;
break;
}
+# if defined(ENABLE_INTRP)
}
-#endif
+# endif
+
+#endif /* CONDITIONAL_LOADCONST */
+
OP1_0(TYPE_INT);
+ iptr->val.i = 0;
tbptr = m->basicblocks + m->basicblockindex[iptr->op1];
iptr[0].target = (void *) tbptr;
superblockend = true;
break;
- case ICMD_NULLCHECKPOP:
case ICMD_MONITORENTER:
COUNT(count_check_null);
case ICMD_MONITOREXIT:
break;
/* pop 2 push 1 */
-
- case ICMD_IDIV:
-#if !SUPPORT_DIVISION
- iptr[0].opc = ICMD_BUILTIN2;
- iptr[0].op1 = TYPE_INT;
- iptr[0].val.fp = BUILTIN_idiv;
- m->isleafmethod = false;
- goto builtin2;
-#endif
+ case ICMD_IDIV:
case ICMD_IREM:
#if !SUPPORT_DIVISION
- iptr[0].opc = ICMD_BUILTIN2;
- iptr[0].op1 = TYPE_INT;
- iptr[0].val.fp = BUILTIN_irem;
- m->isleafmethod = false;
- goto builtin2;
-#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;
+ }
+
+ /* fall through */
+#endif /* !SUPPORT_DIVISION */
case ICMD_ISHL:
case ICMD_ISHR:
break;
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;
- m->isleafmethod = false;
- goto builtin2;
-#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;
- m->isleafmethod = false;
- goto builtin2;
-#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;
+ }
+
+ /* fall through */
+#endif /* !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV) */
case ICMD_LMUL:
case ICMD_LADD:
case ICMD_LCMP:
COUNT(count_pcmd_op);
-#if !defined(NOLONG_CONDITIONAL)
+#if SUPPORT_LONG_CMP_CONST
if ((len > 0) && (iptr[1].val.i == 0)) {
switch (iptr[1].opc) {
case ICMD_IFEQ:
}
}
else
-#endif
+#endif /* SUPPORT_LONG_CMP_CONST */
OPTT2_1(TYPE_LNG, TYPE_INT);
break;
case ICMD_FCMPL:
break;
case ICMD_CHECKCAST:
+ if (iptr->op1 == 0) {
+ /* array type cast-check */
+
+ bte = builtintable_get_internal(BUILTIN_arraycheckcast);
+ 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;
OP1_0ANY;
break;
- /* pop many push any */
-
- case ICMD_INVOKEVIRTUAL:
+ /* pop many push any */
+
+ case ICMD_BUILTIN:
+#if defined(USEBUILTINTABLE)
+ builtin:
+#endif
+ bte = (builtintable_entry *) iptr->val.a;
+ md = bte->md;
+ goto _callhandling;
+
+ case ICMD_INVOKESTATIC:
case ICMD_INVOKESPECIAL:
+ case ICMD_INVOKEVIRTUAL:
case ICMD_INVOKEINTERFACE:
- case ICMD_INVOKESTATIC:
COUNT(count_pcmd_met);
- {
- methodinfo *lm = iptr->val.a;
- if (lm->flags & ACC_STATIC)
- {COUNT(count_check_null);}
- i = iptr->op1;
- if (i > rd->arguments_num)
- rd->arguments_num = i;
- REQUIRE(i);
-#if defined(__X86_64__)
- {
- s4 iarg = 0;
- s4 farg = 0;
- s4 stackargs = 0;
-
- /* count integer and float arguments */
-
- copy = curstack;
- while (--i >= 0) {
- (IS_FLT_DBL_TYPE(copy->type)) ? farg++ : iarg++;
- copy = copy->prev;
- }
+ um = iptr->target;
+ md = um->methodref->parseddesc.md;
+/* if (lm->flags & ACC_STATIC) */
+/* {COUNT(count_check_null);} */
- /* calculate stack space required */
+ _callhandling:
+ i = md->paramcount;
- stackargs += (iarg < INT_ARG_CNT) ?
- 0 : (iarg - INT_ARG_CNT);
- stackargs += (farg < FLT_ARG_CNT) ?
- 0 : (farg - FLT_ARG_CNT);
+ if (md->memuse > rd->memuse)
+ rd->memuse = md->memuse;
+ if (md->argintreguse > rd->argintreguse)
+ rd->argintreguse = md->argintreguse;
+ if (md->argfltreguse > rd->argfltreguse)
+ rd->argfltreguse = md->argfltreguse;
- i = iptr->op1;
- copy = curstack;
- while (--i >= 0) {
- if (!(copy->flags & SAVEDVAR)) {
- copy->varkind = ARGVAR;
+ REQUIRE(i);
- if (IS_FLT_DBL_TYPE(copy->type)) {
- if (--farg < FLT_ARG_CNT)
- copy->varnum = farg;
- else
- copy->varnum = --stackargs + FLT_ARG_CNT;
+ 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;
- } else {
- if (--iarg < INT_ARG_CNT)
- copy->varnum = iarg;
+#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); /* XXX is this assert ok? */
+#else
+ copy->regoff =
+ rd->argfltregs[md->params[i].regoff];
+#endif
+ else {
+#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+ 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
- copy->varnum = --stackargs + INT_ARG_CNT;
+#endif
+ copy->regoff =
+ rd->argintregs[md->params[i].regoff];
}
-
- } else {
- (IS_FLT_DBL_TYPE(copy->type)) ? --farg : --iarg;
}
- copy = copy->prev;
+#if defined(ENABLE_INTRP)
}
+#endif
}
-#else /* defined(__X86_64__) */
- copy = curstack;
- while (--i >= 0) {
- if (!(copy->flags & SAVEDVAR)) {
- copy->varkind = ARGVAR;
- copy->varnum = i;
- }
- copy = copy->prev;
- }
-#endif /* defined(__X86_64__) */
- while (copy) {
- copy->flags |= SAVEDVAR;
- copy = copy->prev;
- }
- i = iptr->op1;
- POPMANY(i);
- if (lm->returntype != TYPE_VOID)
- OP0_1(lm->returntype);
- break;
+ copy = copy->prev;
}
- case ICMD_INLINE_START:
- case ICMD_INLINE_END:
- SETDST;
- break;
- case ICMD_BUILTIN3:
- /* DEBUG */ /*dolog("builtin3");*/
- REQUIRE_3;
- if (!(curstack->flags & SAVEDVAR)) {
- curstack->varkind = ARGVAR;
- curstack->varnum = 2;
- }
- if (3 > rd->arguments_num) {
- rd->arguments_num = 3;
+ while (copy) {
+ copy->flags |= SAVEDVAR;
+ copy = copy->prev;
}
- OP1_0ANY;
- case ICMD_BUILTIN2:
-#if defined(USEBUILTINTABLE) || !SUPPORT_DIVISION
- /* Just prevent a compiler warning... */
- builtin2:
-#endif
- REQUIRE_2;
- /* DEBUG */ /*dolog("builtin2");*/
- if (!(curstack->flags & SAVEDVAR)) {
- curstack->varkind = ARGVAR;
- curstack->varnum = 1;
- }
- if (2 > rd->arguments_num) {
- rd->arguments_num = 2;
- }
- OP1_0ANY;
+ i = md->paramcount;
+ POPMANY(i);
+ if (md->returntype.type != TYPE_VOID)
+ OP0_1(md->returntype.type);
+ break;
- case ICMD_BUILTIN1:
-#if defined(USEBUILTINTABLE)
- /* Just prevent a compiler warning... */
- builtin1:
-#endif
- REQUIRE_1;
- /* DEBUG */ /*dolog("builtin1");*/
- if (!(curstack->flags & SAVEDVAR)) {
- curstack->varkind = ARGVAR;
- curstack->varnum = 0;
- }
- if (1 > rd->arguments_num) {
- rd->arguments_num = 1;
- }
- OP1_0ANY;
- copy = curstack;
- while (copy) {
- copy->flags |= SAVEDVAR;
- copy = copy->prev;
- }
- if (iptr->op1 != TYPE_VOID)
- OP0_1(iptr->op1);
- break;
+ case ICMD_INLINE_START:
+ case ICMD_INLINE_END:
+ SETDST;
+ break;
case ICMD_MULTIANEWARRAY:
+ if (rd->argintreguse < 3)
+ rd->argintreguse = 3;
+
i = iptr->op1;
+
REQUIRE(i);
- if ((i + INT_ARG_CNT) > rd->arguments_num)
- rd->arguments_num = i + INT_ARG_CNT;
+#if defined(SPECIALMEMUSE)
+# if defined(__DARWIN__)
+ if (rd->memuse < (i + INT_ARG_CNT + LA_WORD_SIZE))
+ rd->memuse = i + LA_WORD_SIZE + INT_ARG_CNT;
+# else
+ if (rd->memuse < (i + LA_WORD_SIZE + 3))
+ rd->memuse = i + LA_WORD_SIZE + 3;
+# endif
+#else
+# if defined(__I386__)
+ if (rd->memuse < i + 3)
+ rd->memuse = i + 3; /* n integer args spilled on stack */
+# elif defined(__MIPS__) && SIZEOF_VOID_P == 4
+ if (rd->memuse < i + 2)
+ rd->memuse = i + 2; /* 4*4 bytes callee save space */
+# else
+ if (rd->memuse < i)
+ rd->memuse = i; /* n integer args spilled on stack */
+# endif /* defined(__I386__) */
+#endif
copy = curstack;
while (--i >= 0) {
/* check INT type here? Currently typecheck does this. */
if (!(copy->flags & SAVEDVAR)) {
copy->varkind = ARGVAR;
copy->varnum = i + INT_ARG_CNT;
+ copy->flags |= INMEMORY;
+#if defined(SPECIALMEMUSE)
+# 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;
+# elif defined(__MIPS__) && SIZEOF_VOID_P == 4
+ copy->regoff = i + 2;
+# else
+ copy->regoff = i;
+# endif /* defined(__I386__) */
+#endif /* defined(SPECIALMEMUSE) */
}
copy = copy->prev;
}
default:
*exceptionptr =
- new_exception_message(string_java_lang_InternalError,
- "Unknown ICMD");
+ new_internalerror("Unknown ICMD %d", opcode);
return NULL;
} /* switch */
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:
if (s->flags & INMEMORY)
printf(" M%02d", s->regoff);
+#ifdef HAS_ADDRESS_REGISTER_FILE
+ else if (s->type == TYPE_ADR)
+ printf(" R%02d", s->regoff);
+#endif
else if (IS_FLT_DBL_TYPE(s->type))
printf(" F%02d", s->regoff);
else {
- printf(" %3s", regs[s->regoff]);
+#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+ if (IS_2_WORD_TYPE(s->type))
+ printf(" %3s/%3s", regs[GET_LOW_REG(s->regoff)],
+ regs[GET_HIGH_REG(s->regoff)]);
+ else
+#endif
+#if defined(ENABLE_INTRP)
+ printf(" %3d", s->regoff);
+#else
+ printf(" %3s", regs[s->regoff]);
+#endif
}
break;
case STACKVAR:
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(" V0");
+ } else /* "normal" Argvar */
+ printf(" A%02d", s->varnum);
+#ifdef INVOKE_NEW_DEBUG
+ if (s->flags & INMEMORY)
+ printf("(M%i)", s->regoff);
+ else
+ printf("(R%i)", s->regoff);
+#endif
break;
default:
printf(" !%02d", j);
case TEMPVAR:
if (s->flags & INMEMORY)
printf(" m%02d", s->regoff);
+#ifdef HAS_ADDRESS_REGISTER_FILE
+ else if (s->type == TYPE_ADR)
+ printf(" r%02d", s->regoff);
+#endif
else if (IS_FLT_DBL_TYPE(s->type))
printf(" f%02d", s->regoff);
else {
- printf(" %3s", regs[s->regoff]);
+#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+ if (IS_2_WORD_TYPE(s->type))
+ printf(" %3s/%3s", regs[GET_LOW_REG(s->regoff)],
+ regs[GET_HIGH_REG(s->regoff)]);
+ else
+#endif
+#if defined(ENABLE_INTRP)
+ printf(" %3d", s->regoff);
+#else
+ printf(" %3s", regs[s->regoff]);
+#endif
}
break;
case STACKVAR:
printf(" l%02d", s->varnum);
break;
case ARGVAR:
+ if (s->varnum == -1) {
+ /* Return Value */
+ /* varkind ARGVAR "misused for this special case */
+ printf(" v0");
+ } else /* "normal" Argvar */
printf(" a%02d", s->varnum);
+#ifdef INVOKE_NEW_DEBUG
+ if (s->flags & INMEMORY)
+ printf("(M%i)", s->regoff);
+ else
+ printf("(R%i)", s->regoff);
+#endif
break;
default:
printf(" ?%02d", j);
#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",
};
+/* 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);
printf(".");
utf_fprint(stdout, m->name);
- utf_fprint_classname(stdout, m->descriptor);
+ 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);
for (ex = cd->exceptiontable; 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("L%03d", ex->handler->debug_nr);
+ printf(" (catchtype: ");
+ if (ex->catchtype.any)
+ if (IS_CLASSREF(ex->catchtype))
+ utf_display_classname(ex->catchtype.ref->name);
+ else
+ utf_display_classname(ex->catchtype.cls->name);
+ else
+ printf("ANY");
+ printf(")\n");
}
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);
- else if ((j == TYPE_FLT) || (j == TYPE_DBL))
- printf("f%02d", rd->locals[i][j].regoff);
- else {
- printf("%3s", regs[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);
+#endif
+ 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_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 (rd->interfaces[i][j].flags & SAVEDVAR) {
if (rd->interfaces[i][j].flags & INMEMORY)
printf("M%2d", rd->interfaces[i][j].regoff);
+#ifdef HAS_ADDRESS_REGISTER_FILE
+ else if (j == TYPE_ADR)
+ printf("R%02d", rd->interfaces[i][j].regoff);
+#endif
else if ((j == TYPE_FLT) || (j == TYPE_DBL))
printf("F%02d", rd->interfaces[i][j].regoff);
else {
- printf("%3s", regs[rd->interfaces[i][j].regoff]);
+#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+ if (IS_2_WORD_TYPE(j))
+ printf(" %3s/%3s",
+ regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
+ regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
+ else
+#endif
+ printf("%3s",regs[rd->interfaces[i][j].regoff]);
}
}
else {
if (rd->interfaces[i][j].flags & INMEMORY)
printf("m%2d", rd->interfaces[i][j].regoff);
+#ifdef HAS_ADDRESS_REGISTER_FILE
+ else if (j == TYPE_ADR)
+ printf("r%02d", rd->interfaces[i][j].regoff);
+#endif
else if ((j == TYPE_FLT) || (j == TYPE_DBL))
printf("f%02d", rd->interfaces[i][j].regoff);
else {
- printf("%3s", regs[rd->interfaces[i][j].regoff]);
+#if defined(SUPPORT_COMBINE_INTEGER_REGISTERS)
+ if (IS_2_WORD_TYPE(j))
+ printf(" %3s/%3s",
+ regs[GET_LOW_REG(rd->interfaces[i][j].regoff)],
+ regs[GET_HIGH_REG(rd->interfaces[i][j].regoff)]);
+ else
+#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);
- show_icmd(iptr, deadcode);
- printf("\n");
- }
+ printf("] %5d (line: %5d) ", i, iptr->line);
- if (showdisassemble && (!deadcode)) {
-#if defined(__I386__) || defined(__X86_64__)
- u1 *u1ptr;
- s4 a;
+#ifdef LSRA_EDX
+ if (icmd_uses_tmp[iptr->opc][0])
+ printf(" ---");
+ else
+ printf(" EAX");
+ if (icmd_uses_tmp[iptr->opc][1])
+ printf(" ---");
+ else
+ printf(" ECX");
+ if (icmd_uses_tmp[iptr->opc][2])
+ printf(" --- ");
+ else
+ printf(" EDX ");
+#endif
+ show_icmd(iptr, deadcode);
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
}
}
}
case ICMD_LUSHRCONST:
case ICMD_ICONST:
case ICMD_ELSE_ICONST:
+ case ICMD_IASTORECONST:
+ case ICMD_BASTORECONST:
+ case ICMD_CASTORECONST:
+ case ICMD_SASTORECONST:
+ printf(" %d (0x%08x)", iptr->val.i, iptr->val.i);
+ break;
+
case ICMD_IFEQ_ICONST:
case ICMD_IFNE_ICONST:
case ICMD_IFLT_ICONST:
case ICMD_IFGE_ICONST:
case ICMD_IFGT_ICONST:
case ICMD_IFLE_ICONST:
- case ICMD_IASTORECONST:
- case ICMD_BASTORECONST:
- case ICMD_CASTORECONST:
- case ICMD_SASTORECONST:
- printf(" %d", iptr->val.i);
+ printf("(%d) %d", iptr[1].op1, iptr->val.i);
break;
case ICMD_LADDCONST:
case ICMD_LXORCONST:
case ICMD_LCONST:
case ICMD_LASTORECONST:
-#if defined(__I386__) || defined(__POWERPC__)
- printf(" %lld", iptr->val.l);
+#if SIZEOF_VOID_P == 4
+ printf(" %lld (0x%016llx)", iptr->val.l, iptr->val.l);
#else
- printf(" %ld", iptr->val.l);
+ printf(" %ld (0x%016lx)", iptr->val.l, iptr->val.l);
#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_AASTORECONST:
- printf(" %p", iptr->val.a);
+ /* check if this is a constant string or a class reference */
+
+ if (iptr->target) {
+ if (iptr->val.a)
+ printf(" %p", iptr->val.a);
+ else
+ printf(" (NOT RESOLVED)");
+
+ printf(", Class = \"");
+ utf_display(((constant_classref *) iptr->target)->name);
+ printf("\"");
+
+ } else {
+ printf(" %p", iptr->val.a);
+ if (iptr->val.a) {
+ printf(", String = \"");
+ utf_display(javastring_toutf(iptr->val.a, false));
+ printf("\"");
+ }
+ }
break;
case ICMD_GETFIELD:
case ICMD_PUTFIELD:
- printf(" %d,", ((fieldinfo *) iptr->val.a)->offset);
- case ICMD_PUTSTATIC:
+ if (iptr->val.a)
+ printf(" %d, ", ((fieldinfo *) iptr->val.a)->offset);
+ else
+ printf(" (NOT RESOLVED), ");
+ utf_display_classname(((unresolved_field *) iptr->target)->fieldref->classref->name);
+ printf(".");
+ utf_display(((unresolved_field *) iptr->target)->fieldref->name);
+ printf(" (type ");
+ utf_display(((unresolved_field *) iptr->target)->fieldref->descriptor);
+ printf(")");
+ break;
+
+ case ICMD_PUTSTATIC:
case ICMD_GETSTATIC:
- printf(" ");
- utf_fprint(stdout, ((fieldinfo *) iptr->val.a)->class->name);
+ 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(".");
- utf_fprint(stdout, ((fieldinfo *) iptr->val.a)->name);
+ utf_display(((unresolved_field *) iptr->target)->fieldref->name);
printf(" (type ");
- utf_fprint(stdout, ((fieldinfo *) iptr->val.a)->descriptor);
+ utf_display(((unresolved_field *) iptr->target)->fieldref->descriptor);
printf(")");
break;
case ICMD_PUTSTATICCONST:
case ICMD_PUTFIELDCONST:
- switch (iptr[1].opc) {
+ switch (iptr[1].op1) {
case TYPE_INT:
- printf(" %d,", iptr->val.i);
+ printf(" %d (0x%08x),", iptr->val.i, iptr->val.i);
break;
case TYPE_LNG:
-#if defined(__I386__) || defined(__POWERPC__)
- printf(" %lld,", iptr->val.l);
+#if SIZEOF_VOID_P == 4
+ printf(" %lld (0x%016llx),", iptr->val.l, iptr->val.l);
#else
- printf(" %ld,", iptr->val.l);
+ printf(" %ld (0x%016lx),", iptr->val.l, iptr->val.l);
#endif
break;
case TYPE_ADR:
printf(" %p,", iptr->val.a);
break;
case TYPE_FLT:
- printf(" %g,", iptr->val.f);
+ printf(" %g (0x%08x),", iptr->val.f, iptr->val.i);
break;
case TYPE_DBL:
- printf(" %g,", 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;
}
- if (iptr->opc == ICMD_PUTFIELDCONST)
- printf(" %d,", ((fieldinfo *) iptr[1].val.a)->offset);
- printf(" ");
- utf_fprint(stdout, ((fieldinfo *) iptr[1].val.a)->class->name);
- printf(".");
- utf_fprint(stdout, ((fieldinfo *) iptr[1].val.a)->name);
- printf(" (type ");
- utf_fprint(stdout, ((fieldinfo *) iptr[1].val.a)->descriptor);
- printf(")");
+ if (iptr->opc == ICMD_PUTFIELDCONST) {
+ if (iptr[1].val.a)
+ printf(" %d,", ((fieldinfo *) iptr[1].val.a)->offset);
+ else
+ printf(" (NOT RESOLVED),");
+ }
+ printf(" ");
+ utf_display_classname(((unresolved_field *) iptr[1].target)->fieldref->classref->name);
+ printf(".");
+ utf_display(((unresolved_field *) iptr[1].target)->fieldref->name);
+ printf(" (type ");
+ utf_display(((unresolved_field *) iptr[1].target)->fieldref->descriptor);
+ printf(")");
break;
case ICMD_IINC:
case ICMD_NEW:
printf(" ");
- utf_fprint(stdout,
- ((classinfo *) iptr->val.a)->name);
+ utf_display_classname(((classinfo *) iptr->val.a)->name);
break;
case ICMD_NEWARRAY:
case ICMD_ANEWARRAY:
if (iptr->op1) {
printf(" ");
- utf_fprint(stdout,
- ((classinfo *) iptr->val.a)->name);
+ utf_display_classname(((classinfo *) iptr->val.a)->name);
}
break;
case ICMD_MULTIANEWARRAY:
- {
- vftbl_t *vft;
+ if (iptr->target) {
+ printf(" (NOT RESOLVED) %d ",iptr->op1);
+ utf_display(((constant_classref *) iptr->val.a)->name);
+ } else {
printf(" %d ",iptr->op1);
- vft = (vftbl_t *)iptr->val.a;
- if (vft)
- utf_fprint(stdout,vft->class->name);
- else
- printf("<null>");
+ utf_display_classname(((vftbl_t *) iptr->val.a)->class->name);
}
break;
case ICMD_CHECKCAST:
case ICMD_INSTANCEOF:
- if (iptr->op1) {
+ {
classinfo *c = iptr->val.a;
- if (c->flags & ACC_INTERFACE)
- printf(" (INTERFACE) ");
- else
- printf(" (CLASS,%3d) ", c->vftbl->diffval);
- utf_fprint(stdout, c->name);
+ if (c) {
+ if (c->flags & ACC_INTERFACE)
+ printf(" (INTERFACE) ");
+ else
+ printf(" (CLASS,%3d) ", c->vftbl->diffval);
+ } 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;
- 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:
case ICMD_INVOKESPECIAL:
case ICMD_INVOKESTATIC:
case ICMD_INVOKEINTERFACE:
- printf(" ");
- utf_fprint(stdout,
- ((methodinfo *) iptr->val.a)->class->name);
+ if (!iptr->val.a)
+ printf(" (NOT RESOLVED) ");
+ else
+ printf(" ");
+ utf_display_classname(((unresolved_method *) iptr->target)->methodref->classref->name);
printf(".");
- utf_fprint(stdout,
- ((methodinfo *) iptr->val.a)->name);
+ utf_display(((unresolved_method *) iptr->target)->methodref->name);
+ utf_display(((unresolved_method *) iptr->target)->methodref->descriptor);
break;
case ICMD_IFEQ:
case ICMD_IFGT:
case ICMD_IFLE:
if (deadcode || !iptr->target)
- printf("(%d) op1=%d", iptr->val.i, iptr->op1);
+ printf(" %d (0x%08x) op1=%d", iptr->val.i, iptr->val.i, iptr->op1);
else
- printf("(%d) L%03d", iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
+ printf(" %d (0x%08x) L%03d", iptr->val.i, iptr->val.i, ((basicblock *) iptr->target)->debug_nr);
break;
case ICMD_IF_LEQ:
case ICMD_IF_LGT:
case ICMD_IF_LLE:
if (deadcode || !iptr->target)
-#if defined(__I386__) || defined(__POWERPC__)
+#if SIZEOF_VOID_P == 4
printf("(%lld) op1=%d", iptr->val.l, iptr->op1);
#else
printf("(%ld) op1=%d", iptr->val.l, iptr->op1);
#endif
else
-#if defined(__I386__) || defined(__POWERPC__)
+#if SIZEOF_VOID_P == 4
printf("(%lld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
#else
printf("(%ld) L%03d", iptr->val.l, ((basicblock *) iptr->target)->debug_nr);
}
}
break;
+
+ case ICMD_ARETURN:
+ if (iptr->val.a) {
+ printf(" (NOT RESOLVED), Class = \"");
+ utf_display(((unresolved_class *) iptr->val.a)->classref->name);
+ printf("\"");
+ }
}
- printf(" Line number: %d, method:",iptr->line);
-/* printf("\t\t");
- utf_display(iptr->method->class->name);
- printf(".");
- utf_display(iptr->method->name); */
}