X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fjit%2Fstack.c;h=ba2708cc5a8cc133bd494f8cadefe70b91e80005;hb=9047461489a68fe445ccd57681eb150fe291e40c;hp=5d9d5bcd7d5f4ccbf7044b948a69d3d4455e5b18;hpb=32543d30bbaef8d75ca8c7d206f98bb94a033264;p=cacao.git diff --git a/src/vm/jit/stack.c b/src/vm/jit/stack.c index 5d9d5bcd7..ba2708cc5 100644 --- a/src/vm/jit/stack.c +++ b/src/vm/jit/stack.c @@ -28,18 +28,22 @@ Changes: Edwin Steiner Christian Thalinger + Christian Ullrich - $Id: stack.c 2429 2005-05-03 19:25:36Z twisti $ + $Id: stack.c 3699 2005-11-17 18:53:07Z twisti $ */ +#include #include #include -#include "disass.h" -#include "types.h" -#include "codegen.h" +#include "vm/types.h" + +#include "arch.h" +#include "md-abi.h" + #include "mm/memory.h" #include "native/native.h" #include "toolbox/logging.h" @@ -48,14 +52,43 @@ #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; +} + + /**********************************************************************/ /* analyse_stack */ /**********************************************************************/ @@ -83,23 +116,24 @@ 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; @@ -109,7 +143,6 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) for (i = 0; i < cd->maxlocals; i++) argren[i] = i; - rd->arguments_num = 0; new = m->stack; loops = 0; m->basicblocks[0].flags = BBREACHED; @@ -205,28 +238,31 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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)) + + } 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; @@ -234,48 +270,26 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) len = bptr->icount; iptr = bptr->iinstr; b_index = bptr - m->basicblocks; + while (--len >= 0) { opcode = iptr->opc; - /* 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; +# 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; - } + goto builtin; } +# if defined(ENABLE_INTRP) } +# endif #endif /* defined(USEBUILTINTABLE) */ switch (opcode) { @@ -285,8 +299,6 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) case ICMD_CHECKNULL: COUNT(count_check_null); case ICMD_NOP: - case ICMD_CHECKASIZE: - case ICMD_CHECKEXCEPTION: case ICMD_IFEQ_ICONST: case ICMD_IFNE_ICONST: @@ -299,7 +311,10 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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; @@ -540,10 +555,12 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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]; @@ -551,9 +568,6 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) MARKREACHED(tbptr, copy); COUNT(count_pcmd_bra); -#else - goto icmd_if; -#endif break; case ICMD_IF_ICMPLT: iptr[0].opc = ICMD_IFLT; @@ -576,31 +590,38 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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: @@ -850,7 +871,8 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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) { @@ -893,21 +915,28 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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: @@ -958,16 +987,18 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) #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; @@ -1003,9 +1034,12 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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; @@ -1019,7 +1053,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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: @@ -1068,7 +1102,10 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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++; @@ -1099,20 +1136,43 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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: @@ -1144,8 +1204,9 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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; @@ -1181,43 +1242,43 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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; @@ -1225,14 +1286,14 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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; @@ -1249,12 +1310,17 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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; @@ -1593,26 +1659,29 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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 - /*log_text("ICMD_IREM: !SUPPORT_DIVISION");*/ - iptr[0].opc = ICMD_BUILTIN2; - iptr[0].op1 = TYPE_INT; - iptr[0].val.fp = BUILTIN_irem; - m->isleafmethod = false; - goto builtin2; -#endif - /*log_text("ICMD_IREM: SUPPORT_DIVISION");*/ + 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: @@ -1628,22 +1697,27 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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: @@ -1684,7 +1758,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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: @@ -1722,7 +1796,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) } } else -#endif +#endif /* SUPPORT_LONG_CMP_CONST */ OPTT2_1(TYPE_LNG, TYPE_INT); break; case ICMD_FCMPL: @@ -1808,6 +1882,25 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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; @@ -1859,108 +1952,149 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) 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); - { -#if defined(__X86_64__) || defined(__I386__) || defined(__ALPHA__) - 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; -#else - methodinfo *lm = iptr->val.a; - if (lm->flags & ACC_STATIC) - {COUNT(count_check_null);} - call_argcount = iptr->op1; - call_returntype = lm->returntype; -#endif - _callhandling: - i = call_argcount; + _callhandling: + i = md->paramcount; - if (i > rd->arguments_num) - rd->arguments_num = i; - REQUIRE(i); + 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; - /* Macro in codegen.h */ - SET_ARG_STACKSLOTS; + REQUIRE(i); - while (copy) { - copy->flags |= SAVEDVAR; - copy = copy->prev; + 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 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 +#endif + copy->regoff = + rd->argintregs[md->params[i].regoff]; + } + } +#if defined(ENABLE_INTRP) + } +#endif } - 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 = md->paramcount; + POPMANY(i); + if (md->returntype.type != TYPE_VOID) + OP0_1(md->returntype.type); + break; + case ICMD_INLINE_START: case ICMD_INLINE_END: SETDST; break; case ICMD_MULTIANEWARRAY: - if (rd->argintreguse < 3) - rd->argintreguse = 3; + if (rd->argintreguse < 3) + rd->argintreguse = 3; 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->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->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 */ +# 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->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. */ 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; +# elif defined(__MIPS__) && SIZEOF_VOID_P == 4 + copy->regoff = i + 2; # else copy->regoff = i; # endif /* defined(__I386__) */ @@ -2003,8 +2137,7 @@ methodinfo *analyse_stack(methodinfo *m, codegendata *cd, registerdata *rd) default: *exceptionptr = - new_exception_message(string_java_lang_InternalError, - "Unknown ICMD"); + new_internalerror("Unknown ICMD %d", opcode); return NULL; } /* switch */ @@ -2122,9 +2255,9 @@ void icmd_print_stack(codegendata *cd, stackptr s) 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: @@ -2137,7 +2270,17 @@ void icmd_print_stack(codegendata *cd, stackptr s) 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: @@ -2147,7 +2290,12 @@ void icmd_print_stack(codegendata *cd, stackptr s) 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); @@ -2170,7 +2318,17 @@ void icmd_print_stack(codegendata *cd, stackptr s) 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: @@ -2180,6 +2338,11 @@ void icmd_print_stack(codegendata *cd, stackptr s) 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) @@ -2247,15 +2410,6 @@ static void print_reg(stackptr s) { #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 : ""; -} - - static char *jit_type[] = { "int", "lng", @@ -2265,52 +2419,93 @@ static char *jit_type[] = { }; +/* 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); + 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 { - printf("%3s", regs[rd->locals[i][j].regoff]); + 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++) { @@ -2333,7 +2528,14 @@ void show_icmd_method(methodinfo *m, codegendata *cd, registerdata *rd) 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 { @@ -2346,7 +2548,14 @@ void show_icmd_method(methodinfo *m, codegendata *cd, registerdata *rd) 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]); } } } @@ -2354,55 +2563,60 @@ void show_icmd_method(methodinfo *m, codegendata *cd, registerdata *rd) } } 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; @@ -2423,7 +2637,7 @@ void show_icmd_block(methodinfo *m, codegendata *cd, basicblock *bptr) } 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]) @@ -2444,74 +2658,19 @@ void show_icmd_block(methodinfo *m, codegendata *cd, basicblock *bptr) 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 } } } @@ -2570,7 +2729,7 @@ void show_icmd(instruction *iptr, bool deadcode) case ICMD_LXORCONST: case ICMD_LCONST: case ICMD_LASTORECONST: -#if defined(__I386__) || defined(__POWERPC__) +#if SIZEOF_VOID_P == 4 printf(" %lld (0x%016llx)", iptr->val.l, iptr->val.l); #else printf(" %ld (0x%016lx)", iptr->val.l, iptr->val.l); @@ -2578,21 +2737,43 @@ void show_icmd(instruction *iptr, bool deadcode) 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: -#if defined(__X86_64__) || defined(__I386__) || defined(__ALPHA__) if (iptr->val.a) printf(" %d, ", ((fieldinfo *) iptr->val.a)->offset); else @@ -2603,24 +2784,16 @@ void show_icmd(instruction *iptr, bool deadcode) printf(" (type "); utf_display(((unresolved_field *) iptr->target)->fieldref->descriptor); printf(")"); -#else - printf(" %d,", ((fieldinfo *) iptr->val.a)->offset); - printf(" "); - utf_display_classname(((fieldinfo *) iptr->val.a)->class->name); - printf("."); - utf_display(((fieldinfo *) iptr->val.a)->name); - printf(" (type "); - utf_display(((fieldinfo *) iptr->val.a)->descriptor); - printf(")"); -#endif break; case ICMD_PUTSTATIC: case ICMD_GETSTATIC: -#if defined(__X86_64__) || defined(__I386__) || defined(__ALPHA__) - 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("."); @@ -2628,43 +2801,41 @@ void show_icmd(instruction *iptr, bool deadcode) printf(" (type "); utf_display(((unresolved_field *) iptr->target)->fieldref->descriptor); printf(")"); -#else - printf(" "); - utf_display_classname(((fieldinfo *) iptr->val.a)->class->name); - printf("."); - utf_display(((fieldinfo *) iptr->val.a)->name); - printf(" (type "); - utf_display(((fieldinfo *) iptr->val.a)->descriptor); - printf(")"); -#endif break; case ICMD_PUTSTATICCONST: case ICMD_PUTFIELDCONST: 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 defined(__X86_64__) - if (iptr->opc == ICMD_PUTFIELDCONST) - printf(" NOT RESOLVED,"); + 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("."); @@ -2672,17 +2843,6 @@ void show_icmd(instruction *iptr, bool deadcode) 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: @@ -2766,61 +2926,51 @@ void show_icmd(instruction *iptr, bool deadcode) 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_display_classname(vft->class->name); - else - printf(""); + utf_display_classname(((vftbl_t *) iptr->val.a)->class->name); } break; case ICMD_CHECKCAST: case ICMD_INSTANCEOF: -#if defined(__X86_64__) || defined(__I386__) || defined(__ALPHA__) - if (iptr->op1) { - classinfo *c = iptr->val.a; - 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; -#endif - if (iptr->op1) { + { classinfo *c = iptr->val.a; - if (c->flags & ACC_INTERFACE) - printf(" (INTERFACE) "); - else - printf(" (CLASS,%3d) ", c->vftbl->diffval); - utf_display_classname(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: -#if defined(__X86_64__) || defined(__I386__) || defined(__ALPHA__) if (!iptr->val.a) printf(" (NOT RESOLVED) "); else @@ -2829,13 +2979,6 @@ void show_icmd(instruction *iptr, bool deadcode) printf("."); utf_display(((unresolved_method *) iptr->target)->methodref->name); utf_display(((unresolved_method *) iptr->target)->methodref->descriptor); -#else - printf(" "); - utf_display_classname(((methodinfo *) iptr->val.a)->class->name); - printf("."); - utf_display(((methodinfo *) iptr->val.a)->name); - utf_display(((methodinfo *) iptr->val.a)->descriptor); -#endif break; case ICMD_IFEQ: @@ -2845,9 +2988,9 @@ void show_icmd(instruction *iptr, bool deadcode) 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: @@ -2857,13 +3000,13 @@ void show_icmd(instruction *iptr, bool deadcode) 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); @@ -2945,12 +3088,14 @@ void show_icmd(instruction *iptr, bool deadcode) } } 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); */ }