From 06a775781abb06bf7814540098d0be06141a01a4 Mon Sep 17 00:00:00 2001 From: twisti Date: Mon, 24 Apr 2006 16:06:16 +0000 Subject: [PATCH] * src/vm/jit/codegen-common.c (codegen_increase): Changed signature. (codegen_addreference): Likewise. (codegen_add_exception_ref): Likewise. (codegen_add_arithmeticexception_ref): Likewise. (codegen_add_arrayindexoutofboundsexception_ref): Likewise. (codegen_add_arraystoreexception_ref): Likewise. (codegen_add_classcastexception_ref): Likewise. (codegen_add_nullpointerexception_ref): Likewise. (codegen_add_fillinstacktrace_ref): Likewise. (codegen_addpatchref): Likewise. (codegen_finish): Likewise. * src/vm/jit/codegen-common.h: Likewise. * src/vm/jit/dseg.c (dseg_increase): Made static. (dseg_adds4): Use dseg_increase. (dseg_adds8): Likewise. (dseg_addfloat): Likewise. (dseg_adddouble): Likewise. (dseg_adds4_increase): Removed. (dseg_adds8_increase): Likewise. (dseg_addfloat_increase): Likewise. (dseg_adddouble_increase): Likewise. (dseg_addlinenumber): Changed signature. (dseg_addlinenumber_inline_start): Likewise. (dseg_adddata): Likewise. * src/vm/jit/dseg.h: Likewise. * src/vm/jit/alpha/emit.c (vm/jit/alpha/emit.h): Removed. (vm/jit/emit.h): Added. (emit_lconst): New method. * src/vm/jit/alpha/Makefile.am (libarch_la_SOURCES): Added emit.c * src/vm/jit/alpha/codegen.c (vm/jit/emit.h): Added. (codegen): Use cd->mcodeptr instead of mcodeptr, and emit_load/store functions instead of macros. Saves over 50kB object code size. Use new signatures of codegen-common and dseg functions. * src/vm/jit/alpha/codegen.h (var_to_reg_int): Removed. (var_to_reg_flt): Likewise. (store_reg_to_var_int): Likewise. (store_reg_to_var_flt): Likewise. * src/vm/jit/i386/codegen.c: Use new signatures of codegen-common and dseg functions. * src/vm/jit/i386/codegen.h: Likewise. * src/vm/jit/intrp/codegen.c: Likewise. * src/vm/jit/intrp/codegen.h: Likewise. * src/vm/jit/mips/codegen.c: Likewise. * src/vm/jit/mips/codegen.h: Likewise. * src/vm/jit/powerpc/codegen.c: Likewise. * src/vm/jit/powerpc/codegen.h: Likewise. * src/vm/jit/x86_64/codegen.c: Likewise. * src/vm/jit/x86_64/codegen.h: Likewise. --- src/vm/jit/alpha/Makefile.am | 3 +- src/vm/jit/alpha/codegen.c | 931 +++++++++++++++++------------------ src/vm/jit/alpha/codegen.h | 133 +---- src/vm/jit/alpha/emit.c | 20 +- src/vm/jit/codegen-common.c | 76 ++- src/vm/jit/codegen-common.h | 25 +- src/vm/jit/dseg.c | 78 +-- src/vm/jit/dseg.h | 17 +- src/vm/jit/i386/codegen.c | 209 ++++---- src/vm/jit/i386/codegen.h | 14 +- src/vm/jit/intrp/codegen.c | 31 +- src/vm/jit/intrp/codegen.h | 9 +- src/vm/jit/mips/codegen.c | 150 +++--- src/vm/jit/mips/codegen.h | 14 +- src/vm/jit/powerpc/codegen.c | 187 ++++--- src/vm/jit/powerpc/codegen.h | 12 +- src/vm/jit/x86_64/codegen.c | 125 ++--- src/vm/jit/x86_64/codegen.h | 14 +- 18 files changed, 924 insertions(+), 1124 deletions(-) diff --git a/src/vm/jit/alpha/Makefile.am b/src/vm/jit/alpha/Makefile.am index dfdcc5087..7e4a6db83 100644 --- a/src/vm/jit/alpha/Makefile.am +++ b/src/vm/jit/alpha/Makefile.am @@ -28,7 +28,7 @@ ## ## Changes: ## -## $Id: Makefile.am 4786 2006-04-18 20:10:23Z twisti $ +## $Id: Makefile.am 4826 2006-04-24 16:06:16Z twisti $ ## Process this file with automake to produce Makefile.in @@ -65,6 +65,7 @@ libarch_la_SOURCES = \ codegen.c \ codegen.h \ $(DISASS_SOURCES) \ + emit.c \ patcher.c \ \ md-abi.c \ diff --git a/src/vm/jit/alpha/codegen.c b/src/vm/jit/alpha/codegen.c index bed82a065..dbb668a74 100644 --- a/src/vm/jit/alpha/codegen.c +++ b/src/vm/jit/alpha/codegen.c @@ -32,7 +32,7 @@ Christian Ullrich Edwin Steiner - $Id: codegen.c 4760 2006-04-12 20:06:23Z edwin $ + $Id: codegen.c 4826 2006-04-24 16:06:16Z twisti $ */ @@ -62,6 +62,7 @@ #include "vm/jit/asmpart.h" #include "vm/jit/codegen-common.h" #include "vm/jit/dseg.h" +#include "vm/jit/emit.h" #include "vm/jit/jit.h" #include "vm/jit/parse.h" #include "vm/jit/patcher.h" @@ -86,7 +87,6 @@ bool codegen(jitdata *jd) registerdata *rd; s4 len, s1, s2, s3, d, disp; s4 stackframesize; - s4 *mcodeptr; stackptr src; varinfo *var; basicblock *bptr; @@ -168,10 +168,6 @@ bool codegen(jitdata *jd) (void) dseg_addaddress(cd, ex->catchtype.cls); } - /* initialize mcode variables */ - - mcodeptr = (s4 *) cd->mcodeptr; - /* create stack frame (if necessary) */ if (stackframesize) @@ -274,17 +270,17 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, BUILTIN_staticmonitorenter); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = -(s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, disp); } else { M_BEQZ(rd->argintregs[0], 0); - codegen_add_nullpointerexception_ref(cd, mcodeptr); + codegen_add_nullpointerexception_ref(cd); M_AST(rd->argintregs[0], REG_SP, s1 * 8); disp = dseg_addaddress(cd, BUILTIN_monitorenter); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = -(s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, disp); } @@ -340,7 +336,7 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, (void *) builtin_trace_args); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = -(s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, disp); M_ALD(REG_RA, REG_SP, 1 * 8); @@ -381,7 +377,7 @@ bool codegen(jitdata *jd) for (bptr = m->basicblocks; bptr != NULL; bptr = bptr->next) { - bptr->mpc = (s4) ((u1 *) mcodeptr - cd->mcodebase); + bptr->mpc = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); if (bptr->flags >= BBREACHED) { @@ -419,7 +415,7 @@ bool codegen(jitdata *jd) else d = REG_ITMP1; M_INTMOVE(REG_ITMP1, d); - store_reg_to_var_int(src, d); + emit_store(jd, NULL, src, d); } src = src->prev; } @@ -430,7 +426,8 @@ bool codegen(jitdata *jd) if ((len == 0) && (bptr->type != BBTYPE_STD)) { d = codegen_reg_of_var(rd, 0, src, REG_ITMP1); M_INTMOVE(REG_ITMP1, d); - store_reg_to_var_int(src, d); + emit_store(jd, NULL, src, d); + } else { d = codegen_reg_of_var(rd, 0, src, REG_IFTMP); if ((src->varkind != STACKVAR)) { @@ -442,7 +439,7 @@ bool codegen(jitdata *jd) } else { M_DLD(d, REG_SP, rd->interfaces[len][s2].regoff * 8); } - store_reg_to_var_flt(src, d); + emit_store(jd, NULL, src, d); } else { if (!(rd->interfaces[len][s2].flags & INMEMORY)) { @@ -451,7 +448,7 @@ bool codegen(jitdata *jd) } else { M_LLD(d, REG_SP, rd->interfaces[len][s2].regoff * 8); } - store_reg_to_var_int(src, d); + emit_store(jd, NULL, src, d); } } } @@ -468,7 +465,7 @@ bool codegen(jitdata *jd) for (iptr = bptr->iinstr; len > 0; src = iptr->dst, len--, iptr++) { if (iptr->line != currentline) { - dseg_addlinenumber(cd, iptr->line, (u1 *) mcodeptr); + dseg_addlinenumber(cd, iptr->line); currentline = iptr->line; } @@ -484,9 +481,9 @@ bool codegen(jitdata *jd) case ICMD_CHECKNULL: /* ..., objectref ==> ..., objectref */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); M_BEQZ(s1, 0); - codegen_add_nullpointerexception_ref(cd, mcodeptr); + codegen_add_nullpointerexception_ref(cd); break; /* constant operations ************************************************/ @@ -496,7 +493,7 @@ bool codegen(jitdata *jd) d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1); ICONST(d, iptr->val.i); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LCONST: /* ... ==> ..., constant */ @@ -504,7 +501,7 @@ bool codegen(jitdata *jd) d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1); LCONST(d, iptr->val.l); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_FCONST: /* ... ==> ..., constant */ @@ -513,7 +510,7 @@ bool codegen(jitdata *jd) d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1); disp = dseg_addfloat(cd, iptr->val.f); M_FLD(d, REG_PV, disp); - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_DCONST: /* ... ==> ..., constant */ @@ -522,7 +519,7 @@ bool codegen(jitdata *jd) d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1); disp = dseg_adddouble(cd, iptr->val.d); M_DLD(d, REG_PV, disp); - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_ACONST: /* ... ==> ..., constant */ @@ -533,8 +530,7 @@ bool codegen(jitdata *jd) if ((iptr->target != NULL) && (iptr->val.a == NULL)) { disp = dseg_addaddress(cd, iptr->val.a); - codegen_addpatchref(cd, mcodeptr, - PATCHER_aconst, + codegen_addpatchref(cd, PATCHER_aconst, (unresolved_class *) iptr->target, disp); if (opt_showdisassemble) @@ -550,7 +546,7 @@ bool codegen(jitdata *jd) M_ALD(d, REG_PV, disp); } } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; @@ -570,7 +566,7 @@ bool codegen(jitdata *jd) } else { M_INTMOVE(var->regoff, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_FLOAD: /* ... ==> ..., content of local variable */ @@ -586,7 +582,7 @@ bool codegen(jitdata *jd) } else { M_FLTMOVE(var->regoff, d); } - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; @@ -599,10 +595,10 @@ bool codegen(jitdata *jd) break; var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ISTORE]); if (var->flags & INMEMORY) { - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); M_LST(s1, REG_SP, var->regoff * 8); } else { - var_to_reg_int(s1, src, var->regoff); + s1 = emit_load_s1(jd, iptr, src, var->regoff); M_INTMOVE(s1, var->regoff); } break; @@ -615,10 +611,10 @@ bool codegen(jitdata *jd) break; var = &(rd->locals[iptr->op1][iptr->opc - ICMD_ISTORE]); if (var->flags & INMEMORY) { - var_to_reg_flt(s1, src, REG_FTMP1); + s1 = emit_load_s1(jd, iptr, src, REG_FTMP1); M_DST(s1, REG_SP, var->regoff * 8); } else { - var_to_reg_flt(s1, src, var->regoff); + s1 = emit_load_s1(jd, iptr, src, var->regoff); M_FLTMOVE(s1, var->regoff); } break; @@ -687,39 +683,39 @@ bool codegen(jitdata *jd) case ICMD_INEG: /* ..., value ==> ..., - value */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_ISUB(REG_ZERO, s1, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LNEG: /* ..., value ==> ..., - value */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_LSUB(REG_ZERO, s1, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_I2L: /* ..., value ==> ..., value */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_INTMOVE(s1, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_L2I: /* ..., value ==> ..., value */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_IADD(s1, REG_ZERO, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_INT2BYTE: /* ..., value ==> ..., value */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if (has_ext_instr_set) { M_BSEXT(s1, d); @@ -727,20 +723,20 @@ bool codegen(jitdata *jd) M_SLL_IMM(s1, 56, d); M_SRA_IMM( d, 56, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_INT2CHAR: /* ..., value ==> ..., value */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_CZEXT(s1, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_INT2SHORT: /* ..., value ==> ..., value */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if (has_ext_instr_set) { M_SSEXT(s1, d); @@ -748,23 +744,23 @@ bool codegen(jitdata *jd) M_SLL_IMM(s1, 48, d); M_SRA_IMM( d, 48, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IADD: /* ..., val1, val2 ==> ..., val1 + val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_IADD(s1, s2, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IADDCONST: /* ..., value ==> ..., value + constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) { M_IADD_IMM(s1, iptr->val.i, d); @@ -772,22 +768,22 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP2, iptr->val.i); M_IADD(s1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LADD: /* ..., val1, val2 ==> ..., val1 + val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_LADD(s1, s2, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LADDCONST: /* ..., value ==> ..., value + constant */ /* val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) { M_LADD_IMM(s1, iptr->val.l, d); @@ -795,22 +791,22 @@ bool codegen(jitdata *jd) LCONST(REG_ITMP2, iptr->val.l); M_LADD(s1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_ISUB: /* ..., val1, val2 ==> ..., val1 - val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_ISUB(s1, s2, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_ISUBCONST: /* ..., value ==> ..., value + constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) { M_ISUB_IMM(s1, iptr->val.i, d); @@ -818,22 +814,22 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP2, iptr->val.i); M_ISUB(s1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LSUB: /* ..., val1, val2 ==> ..., val1 - val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_LSUB(s1, s2, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LSUBCONST: /* ..., value ==> ..., value - constant */ /* val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) { M_LSUB_IMM(s1, iptr->val.l, d); @@ -841,22 +837,22 @@ bool codegen(jitdata *jd) LCONST(REG_ITMP2, iptr->val.l); M_LSUB(s1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IMUL: /* ..., val1, val2 ==> ..., val1 * val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_IMUL(s1, s2, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IMULCONST: /* ..., value ==> ..., value * constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) { M_IMUL_IMM(s1, iptr->val.i, d); @@ -864,22 +860,22 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP2, iptr->val.i); M_IMUL(s1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LMUL: /* ..., val1, val2 ==> ..., val1 * val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_LMUL(s1, s2, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LMULCONST: /* ..., value ==> ..., value * constant */ /* val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) { M_LMUL_IMM(s1, iptr->val.l, d); @@ -887,17 +883,17 @@ bool codegen(jitdata *jd) LCONST(REG_ITMP2, iptr->val.l); M_LMUL(s1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IDIV: /* ..., val1, val2 ==> ..., val1 / val2 */ case ICMD_IREM: /* ..., val1, val2 ==> ..., val1 % val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT); M_BEQZ(s2, 0); - codegen_add_arithmeticexception_ref(cd, mcodeptr); + codegen_add_arithmeticexception_ref(cd); M_MOV(s1, rd->argintregs[0]); M_MOV(s2, rd->argintregs[1]); @@ -905,21 +901,21 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, bte->fp); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); M_IADD(REG_RESULT, REG_ZERO, d); /* sign extend (bugfix for gcc -O2) */ - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LDIV: /* ..., val1, val2 ==> ..., val1 / val2 */ case ICMD_LREM: /* ..., val1, val2 ==> ..., val1 % val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT); M_BEQZ(s2, 0); - codegen_add_arithmeticexception_ref(cd, mcodeptr); + codegen_add_arithmeticexception_ref(cd); M_MOV(s1, rd->argintregs[0]); M_MOV(s2, rd->argintregs[1]); @@ -927,17 +923,17 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, bte->fp); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); M_INTMOVE(REG_RESULT, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IDIVPOW2: /* ..., value ==> ..., value << constant */ case ICMD_LDIVPOW2: /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if (iptr->val.i <= 15) { M_LDA(REG_ITMP2, s1, (1 << iptr->val.i) -1); @@ -948,140 +944,140 @@ bool codegen(jitdata *jd) M_LADD(s1, REG_ITMP2, REG_ITMP2); } M_SRA_IMM(REG_ITMP2, iptr->val.i, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_ISHL: /* ..., val1, val2 ==> ..., val1 << val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_AND_IMM(s2, 0x1f, REG_ITMP3); M_SLL(s1, REG_ITMP3, d); M_IADD(d, REG_ZERO, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_ISHLCONST: /* ..., value ==> ..., value << constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_SLL_IMM(s1, iptr->val.i & 0x1f, d); M_IADD(d, REG_ZERO, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_ISHR: /* ..., val1, val2 ==> ..., val1 >> val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_AND_IMM(s2, 0x1f, REG_ITMP3); M_SRA(s1, REG_ITMP3, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_ISHRCONST: /* ..., value ==> ..., value >> constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_SRA_IMM(s1, iptr->val.i & 0x1f, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IUSHR: /* ..., val1, val2 ==> ..., val1 >>> val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_AND_IMM(s2, 0x1f, REG_ITMP2); M_IZEXT(s1, d); M_SRL(d, REG_ITMP2, d); M_IADD(d, REG_ZERO, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IUSHRCONST: /* ..., value ==> ..., value >>> constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_IZEXT(s1, d); M_SRL_IMM(d, iptr->val.i & 0x1f, d); M_IADD(d, REG_ZERO, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LSHL: /* ..., val1, val2 ==> ..., val1 << val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_SLL(s1, s2, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LSHLCONST: /* ..., value ==> ..., value << constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_SLL_IMM(s1, iptr->val.i & 0x3f, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LSHR: /* ..., val1, val2 ==> ..., val1 >> val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_SRA(s1, s2, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LSHRCONST: /* ..., value ==> ..., value >> constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_SRA_IMM(s1, iptr->val.i & 0x3f, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LUSHR: /* ..., val1, val2 ==> ..., val1 >>> val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_SRL(s1, s2, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LUSHRCONST: /* ..., value ==> ..., value >>> constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_SRL_IMM(s1, iptr->val.i & 0x3f, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IAND: /* ..., val1, val2 ==> ..., val1 & val2 */ case ICMD_LAND: - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_AND(s1, s2, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IANDCONST: /* ..., value ==> ..., value & constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) { M_AND_IMM(s1, iptr->val.i, d); @@ -1093,13 +1089,13 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP2, iptr->val.i); M_AND(s1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IREMPOW2: /* ..., value ==> ..., value % constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if (s1 == d) { M_MOV(s1, REG_ITMP1); @@ -1128,13 +1124,13 @@ bool codegen(jitdata *jd) M_AND(d, REG_ITMP2, d); } M_ISUB(REG_ZERO, d, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LANDCONST: /* ..., value ==> ..., value & constant */ /* val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) { M_AND_IMM(s1, iptr->val.l, d); @@ -1154,13 +1150,13 @@ bool codegen(jitdata *jd) LCONST(REG_ITMP2, iptr->val.l); M_AND(s1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LREMPOW2: /* ..., value ==> ..., value % constant */ /* val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if (s1 == d) { M_MOV(s1, REG_ITMP1); @@ -1209,23 +1205,23 @@ bool codegen(jitdata *jd) M_AND(d, REG_ITMP2, d); } M_LSUB(REG_ZERO, d, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IOR: /* ..., val1, val2 ==> ..., val1 | val2 */ case ICMD_LOR: - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_OR( s1,s2, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IORCONST: /* ..., value ==> ..., value | constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) { M_OR_IMM(s1, iptr->val.i, d); @@ -1233,13 +1229,13 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP2, iptr->val.i); M_OR(s1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LORCONST: /* ..., value ==> ..., value | constant */ /* val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) { M_OR_IMM(s1, iptr->val.l, d); @@ -1247,23 +1243,23 @@ bool codegen(jitdata *jd) LCONST(REG_ITMP2, iptr->val.l); M_OR(s1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IXOR: /* ..., val1, val2 ==> ..., val1 ^ val2 */ case ICMD_LXOR: - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_XOR(s1, s2, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IXORCONST: /* ..., value ==> ..., value ^ constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if ((iptr->val.i >= 0) && (iptr->val.i <= 255)) { M_XOR_IMM(s1, iptr->val.i, d); @@ -1271,13 +1267,13 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP2, iptr->val.i); M_XOR(s1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LXORCONST: /* ..., value ==> ..., value ^ constant */ /* val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if ((iptr->val.l >= 0) && (iptr->val.l <= 255)) { M_XOR_IMM(s1, iptr->val.l, d); @@ -1285,19 +1281,19 @@ bool codegen(jitdata *jd) LCONST(REG_ITMP2, iptr->val.l); M_XOR(s1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LCMP: /* ..., val1, val2 ==> ..., val1 cmp val2 */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_CMPLT(s1, s2, REG_ITMP3); M_CMPLT(s2, s1, REG_ITMP1); M_LSUB(REG_ITMP1, REG_ITMP3, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; @@ -1327,24 +1323,24 @@ bool codegen(jitdata *jd) case ICMD_FNEG: /* ..., value ==> ..., - value */ - var_to_reg_flt(s1, src, REG_FTMP1); + s1 = emit_load_s1(jd, iptr, src, REG_FTMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2); M_FMOVN(s1, d); - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_DNEG: /* ..., value ==> ..., - value */ - var_to_reg_flt(s1, src, REG_FTMP1); + s1 = emit_load_s1(jd, iptr, src, REG_FTMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2); M_FMOVN(s1, d); - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_FADD: /* ..., val1, val2 ==> ..., val1 + val2 */ - var_to_reg_flt(s1, src->prev, REG_FTMP1); - var_to_reg_flt(s2, src, REG_FTMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3); if (opt_noieee) { M_FADD(s1, s2, d); @@ -1358,13 +1354,13 @@ bool codegen(jitdata *jd) M_TRAPB; } } - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_DADD: /* ..., val1, val2 ==> ..., val1 + val2 */ - var_to_reg_flt(s1, src->prev, REG_FTMP1); - var_to_reg_flt(s2, src, REG_FTMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3); if (opt_noieee) { M_DADD(s1, s2, d); @@ -1378,13 +1374,13 @@ bool codegen(jitdata *jd) M_TRAPB; } } - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_FSUB: /* ..., val1, val2 ==> ..., val1 - val2 */ - var_to_reg_flt(s1, src->prev, REG_FTMP1); - var_to_reg_flt(s2, src, REG_FTMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3); if (opt_noieee) { M_FSUB(s1, s2, d); @@ -1398,13 +1394,13 @@ bool codegen(jitdata *jd) M_TRAPB; } } - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_DSUB: /* ..., val1, val2 ==> ..., val1 - val2 */ - var_to_reg_flt(s1, src->prev, REG_FTMP1); - var_to_reg_flt(s2, src, REG_FTMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3); if (opt_noieee) { M_DSUB(s1, s2, d); @@ -1418,13 +1414,13 @@ bool codegen(jitdata *jd) M_TRAPB; } } - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_FMUL: /* ..., val1, val2 ==> ..., val1 * val2 */ - var_to_reg_flt(s1, src->prev, REG_FTMP1); - var_to_reg_flt(s2, src, REG_FTMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3); if (opt_noieee) { M_FMUL(s1, s2, d); @@ -1438,13 +1434,13 @@ bool codegen(jitdata *jd) M_TRAPB; } } - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_DMUL: /* ..., val1, val2 ==> ..., val1 *** val2 */ - var_to_reg_flt(s1, src->prev, REG_FTMP1); - var_to_reg_flt(s2, src, REG_FTMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3); if (opt_noieee) { M_DMUL(s1, s2, d); @@ -1458,13 +1454,13 @@ bool codegen(jitdata *jd) M_TRAPB; } } - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_FDIV: /* ..., val1, val2 ==> ..., val1 / val2 */ - var_to_reg_flt(s1, src->prev, REG_FTMP1); - var_to_reg_flt(s2, src, REG_FTMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3); if (opt_noieee) { M_FDIV(s1, s2, d); @@ -1478,13 +1474,13 @@ bool codegen(jitdata *jd) M_TRAPB; } } - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_DDIV: /* ..., val1, val2 ==> ..., val1 / val2 */ - var_to_reg_flt(s1, src->prev, REG_FTMP1); - var_to_reg_flt(s2, src, REG_FTMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3); if (opt_noieee) { M_DDIV(s1, s2, d); @@ -1498,66 +1494,66 @@ bool codegen(jitdata *jd) M_TRAPB; } } - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_I2F: /* ..., value ==> ..., (float) value */ case ICMD_L2F: - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3); disp = dseg_adddouble(cd, 0.0); M_LST(s1, REG_PV, disp); M_DLD(d, REG_PV, disp); M_CVTLF(d, d); - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_I2D: /* ..., value ==> ..., (double) value */ case ICMD_L2D: - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3); disp = dseg_adddouble(cd, 0.0); M_LST(s1, REG_PV, disp); M_DLD(d, REG_PV, disp); M_CVTLD(d, d); - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_F2I: /* ..., value ==> ..., (int) value */ case ICMD_D2I: - var_to_reg_flt(s1, src, REG_FTMP1); + s1 = emit_load_s1(jd, iptr, src, REG_FTMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP3); disp = dseg_adddouble(cd, 0.0); M_CVTDL_C(s1, REG_FTMP2); M_CVTLI(REG_FTMP2, REG_FTMP3); M_DST(REG_FTMP3, REG_PV, disp); M_ILD(d, REG_PV, disp); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_F2L: /* ..., value ==> ..., (long) value */ case ICMD_D2L: - var_to_reg_flt(s1, src, REG_FTMP1); + s1 = emit_load_s1(jd, iptr, src, REG_FTMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP3); disp = dseg_adddouble(cd, 0.0); M_CVTDL_C(s1, REG_FTMP2); M_DST(REG_FTMP2, REG_PV, disp); M_LLD(d, REG_PV, disp); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_F2D: /* ..., value ==> ..., (double) value */ - var_to_reg_flt(s1, src, REG_FTMP1); + s1 = emit_load_s1(jd, iptr, src, REG_FTMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3); M_CVTFDS(s1, d); M_TRAPB; - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_D2F: /* ..., value ==> ..., (float) value */ - var_to_reg_flt(s1, src, REG_FTMP1); + s1 = emit_load_s1(jd, iptr, src, REG_FTMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP3); if (opt_noieee) { M_CVTDF(s1, d); @@ -1565,13 +1561,13 @@ bool codegen(jitdata *jd) M_CVTDFS(s1, d); M_TRAPB; } - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_FCMPL: /* ..., val1, val2 ==> ..., val1 fcmpl val2 */ case ICMD_DCMPL: - var_to_reg_flt(s1, src->prev, REG_FTMP1); - var_to_reg_flt(s2, src, REG_FTMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP3); if (opt_noieee) { M_LSUB_IMM(REG_ZERO, 1, d); @@ -1592,13 +1588,13 @@ bool codegen(jitdata *jd) M_FBEQZ (REG_FTMP3, 1); /* jump over next instruction */ M_LADD_IMM(REG_ZERO, 1, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_FCMPG: /* ..., val1, val2 ==> ..., val1 fcmpg val2 */ case ICMD_DCMPG: - var_to_reg_flt(s1, src->prev, REG_FTMP1); - var_to_reg_flt(s2, src, REG_FTMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_FTMP1); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP3); if (opt_noieee) { M_LADD_IMM(REG_ZERO, 1, d); @@ -1619,7 +1615,7 @@ bool codegen(jitdata *jd) M_FBEQZ (REG_FTMP3, 1); /* jump over next instruction */ M_LSUB_IMM(REG_ZERO, 1, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; @@ -1627,17 +1623,17 @@ bool codegen(jitdata *jd) case ICMD_ARRAYLENGTH: /* ..., arrayref ==> ..., length */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); gen_nullptr_check(s1); M_ILD(d, s1, OFFSET(java_arrayheader, size)); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_BALOAD: /* ..., arrayref, index ==> ..., value */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); @@ -1654,13 +1650,13 @@ bool codegen(jitdata *jd) M_EXTQH(REG_ITMP2, REG_ITMP1, d); M_SRA_IMM(d, 56, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_CALOAD: /* ..., arrayref, index ==> ..., value */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); @@ -1677,13 +1673,13 @@ bool codegen(jitdata *jd) M_LDA (REG_ITMP1, REG_ITMP1, OFFSET(java_chararray, data[0])); M_EXTWL(REG_ITMP2, REG_ITMP1, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_SALOAD: /* ..., arrayref, index ==> ..., value */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); @@ -1702,13 +1698,13 @@ bool codegen(jitdata *jd) M_EXTQH(REG_ITMP2, REG_ITMP1, d); M_SRA_IMM(d, 48, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IALOAD: /* ..., arrayref, index ==> ..., value */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); @@ -1716,13 +1712,13 @@ bool codegen(jitdata *jd) } M_S4ADDQ(s2, s1, REG_ITMP1); M_ILD(d, REG_ITMP1, OFFSET(java_intarray, data[0])); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_LALOAD: /* ..., arrayref, index ==> ..., value */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); @@ -1730,13 +1726,13 @@ bool codegen(jitdata *jd) } M_S8ADDQ(s2, s1, REG_ITMP1); M_LLD(d, REG_ITMP1, OFFSET(java_longarray, data[0])); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_FALOAD: /* ..., arrayref, index ==> ..., value */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); @@ -1744,13 +1740,13 @@ bool codegen(jitdata *jd) } M_S4ADDQ(s2, s1, REG_ITMP1); M_FLD(d, REG_ITMP1, OFFSET(java_floatarray, data[0])); - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_DALOAD: /* ..., arrayref, index ==> ..., value */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); @@ -1758,13 +1754,13 @@ bool codegen(jitdata *jd) } M_S8ADDQ(s2, s1, REG_ITMP1); M_DLD(d, REG_ITMP1, OFFSET(java_doublearray, data[0])); - store_reg_to_var_flt(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_AALOAD: /* ..., arrayref, index ==> ..., value */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); @@ -1772,19 +1768,19 @@ bool codegen(jitdata *jd) } M_SAADDQ(s2, s1, REG_ITMP1); M_ALD(d, REG_ITMP1, OFFSET(java_objectarray, data[0])); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_BASTORE: /* ..., arrayref, index, value ==> ... */ - var_to_reg_int(s1, src->prev->prev, REG_ITMP1); - var_to_reg_int(s2, src->prev, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; } - var_to_reg_int(s3, src, REG_ITMP3); + s3 = emit_load_s3(jd, iptr, src, REG_ITMP3); if (has_ext_instr_set) { M_LADD(s2, s1, REG_ITMP1); M_BST(s3, REG_ITMP1, OFFSET(java_bytearray, data[0])); @@ -1801,13 +1797,13 @@ bool codegen(jitdata *jd) case ICMD_CASTORE: /* ..., arrayref, index, value ==> ... */ - var_to_reg_int(s1, src->prev->prev, REG_ITMP1); - var_to_reg_int(s2, src->prev, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; } - var_to_reg_int(s3, src, REG_ITMP3); + s3 = emit_load_s3(jd, iptr, src, REG_ITMP3); if (has_ext_instr_set) { M_LADD(s2, s1, REG_ITMP1); M_LADD(s2, REG_ITMP1, REG_ITMP1); @@ -1826,13 +1822,13 @@ bool codegen(jitdata *jd) case ICMD_SASTORE: /* ..., arrayref, index, value ==> ... */ - var_to_reg_int(s1, src->prev->prev, REG_ITMP1); - var_to_reg_int(s2, src->prev, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; } - var_to_reg_int(s3, src, REG_ITMP3); + s3 = emit_load_s3(jd, iptr, src, REG_ITMP3); if (has_ext_instr_set) { M_LADD(s2, s1, REG_ITMP1); M_LADD(s2, REG_ITMP1, REG_ITMP1); @@ -1851,80 +1847,80 @@ bool codegen(jitdata *jd) case ICMD_IASTORE: /* ..., arrayref, index, value ==> ... */ - var_to_reg_int(s1, src->prev->prev, REG_ITMP1); - var_to_reg_int(s2, src->prev, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; } - var_to_reg_int(s3, src, REG_ITMP3); + s3 = emit_load_s3(jd, iptr, src, REG_ITMP3); M_S4ADDQ(s2, s1, REG_ITMP1); M_IST(s3, REG_ITMP1, OFFSET(java_intarray, data[0])); break; case ICMD_LASTORE: /* ..., arrayref, index, value ==> ... */ - var_to_reg_int(s1, src->prev->prev, REG_ITMP1); - var_to_reg_int(s2, src->prev, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; } - var_to_reg_int(s3, src, REG_ITMP3); + s3 = emit_load_s3(jd, iptr, src, REG_ITMP3); M_S8ADDQ(s2, s1, REG_ITMP1); M_LST(s3, REG_ITMP1, OFFSET(java_longarray, data[0])); break; case ICMD_FASTORE: /* ..., arrayref, index, value ==> ... */ - var_to_reg_int(s1, src->prev->prev, REG_ITMP1); - var_to_reg_int(s2, src->prev, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; } - var_to_reg_flt(s3, src, REG_FTMP3); + s3 = emit_load_s3(jd, iptr, src, REG_FTMP3); M_S4ADDQ(s2, s1, REG_ITMP1); M_FST(s3, REG_ITMP1, OFFSET(java_floatarray, data[0])); break; case ICMD_DASTORE: /* ..., arrayref, index, value ==> ... */ - var_to_reg_int(s1, src->prev->prev, REG_ITMP1); - var_to_reg_int(s2, src->prev, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; } - var_to_reg_flt(s3, src, REG_FTMP3); + s3 = emit_load_s3(jd, iptr, src, REG_FTMP3); M_S8ADDQ(s2, s1, REG_ITMP1); M_DST(s3, REG_ITMP1, OFFSET(java_doublearray, data[0])); break; case ICMD_AASTORE: /* ..., arrayref, index, value ==> ... */ - var_to_reg_int(s1, src->prev->prev, REG_ITMP1); - var_to_reg_int(s2, src->prev, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; } - var_to_reg_int(s3, src, REG_ITMP3); + s3 = emit_load_s3(jd, iptr, src, REG_ITMP3); M_MOV(s1, rd->argintregs[0]); M_MOV(s3, rd->argintregs[1]); disp = dseg_addaddress(cd, BUILTIN_canstore); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); M_BEQZ(REG_RESULT, 0); - codegen_add_arraystoreexception_ref(cd, mcodeptr); + codegen_add_arraystoreexception_ref(cd); - var_to_reg_int(s1, src->prev->prev, REG_ITMP1); - var_to_reg_int(s2, src->prev, REG_ITMP2); - var_to_reg_int(s3, src, REG_ITMP3); + s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2); + s3 = emit_load_s3(jd, iptr, src, REG_ITMP3); M_SAADDQ(s2, s1, REG_ITMP1); M_AST(s3, REG_ITMP1, OFFSET(java_objectarray, data[0])); break; @@ -1932,8 +1928,8 @@ bool codegen(jitdata *jd) case ICMD_IASTORECONST: /* ..., arrayref, index ==> ... */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; @@ -1944,8 +1940,8 @@ bool codegen(jitdata *jd) case ICMD_LASTORECONST: /* ..., arrayref, index ==> ... */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; @@ -1956,8 +1952,8 @@ bool codegen(jitdata *jd) case ICMD_AASTORECONST: /* ..., arrayref, index ==> ... */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; @@ -1968,8 +1964,8 @@ bool codegen(jitdata *jd) case ICMD_BASTORECONST: /* ..., arrayref, index ==> ... */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; @@ -1991,8 +1987,8 @@ bool codegen(jitdata *jd) case ICMD_CASTORECONST: /* ..., arrayref, index ==> ... */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; @@ -2016,8 +2012,8 @@ bool codegen(jitdata *jd) case ICMD_SASTORECONST: /* ..., arrayref, index ==> ... */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); if (iptr->op1 == 0) { gen_nullptr_check(s1); gen_bound_check; @@ -2046,8 +2042,7 @@ bool codegen(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { disp = dseg_addaddress(cd, 0); - codegen_addpatchref(cd, mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr), disp); if (opt_showdisassemble) @@ -2060,8 +2055,7 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, &(fi->value)); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { - codegen_addpatchref(cd, mcodeptr, - PATCHER_clinit, fi->class, 0); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); if (opt_showdisassemble) M_NOP; @@ -2073,29 +2067,25 @@ bool codegen(jitdata *jd) case TYPE_INT: d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_ILD(d, REG_ITMP1, 0); - store_reg_to_var_int(iptr->dst, d); break; case TYPE_LNG: d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_LLD(d, REG_ITMP1, 0); - store_reg_to_var_int(iptr->dst, d); break; case TYPE_ADR: d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_ALD(d, REG_ITMP1, 0); - store_reg_to_var_int(iptr->dst, d); break; case TYPE_FLT: d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1); M_FLD(d, REG_ITMP1, 0); - store_reg_to_var_flt(iptr->dst, d); break; case TYPE_DBL: d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1); M_DLD(d, REG_ITMP1, 0); - store_reg_to_var_flt(iptr->dst, d); break; } + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_PUTSTATIC: /* ..., value ==> ... */ @@ -2104,8 +2094,7 @@ bool codegen(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { disp = dseg_addaddress(cd, 0); - codegen_addpatchref(cd, mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr), disp); if (opt_showdisassemble) @@ -2117,8 +2106,7 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, &(fi->value)); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { - codegen_addpatchref(cd, mcodeptr, - PATCHER_clinit, fi->class, 0); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); if (opt_showdisassemble) M_NOP; @@ -2128,23 +2116,23 @@ bool codegen(jitdata *jd) M_ALD(REG_ITMP1, REG_PV, disp); switch (iptr->op1) { case TYPE_INT: - var_to_reg_int(s2, src, REG_ITMP2); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_IST(s2, REG_ITMP1, 0); break; case TYPE_LNG: - var_to_reg_int(s2, src, REG_ITMP2); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_LST(s2, REG_ITMP1, 0); break; case TYPE_ADR: - var_to_reg_int(s2, src, REG_ITMP2); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_AST(s2, REG_ITMP1, 0); break; case TYPE_FLT: - var_to_reg_flt(s2, src, REG_FTMP2); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); M_FST(s2, REG_ITMP1, 0); break; case TYPE_DBL: - var_to_reg_flt(s2, src, REG_FTMP2); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); M_DST(s2, REG_ITMP1, 0); break; } @@ -2158,8 +2146,7 @@ bool codegen(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr + 1)) { disp = dseg_addaddress(cd, 0); - codegen_addpatchref(cd, mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr + 1), disp); if (opt_showdisassemble) @@ -2171,8 +2158,7 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, &(fi->value)); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { - codegen_addpatchref(cd, mcodeptr, - PATCHER_clinit, fi->class, 0); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); if (opt_showdisassemble) M_NOP; @@ -2203,12 +2189,11 @@ bool codegen(jitdata *jd) case ICMD_GETFIELD: /* ... ==> ..., value */ /* op1 = type, val.i = field offset */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); gen_nullptr_check(s1); if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - codegen_addpatchref(cd, mcodeptr, - PATCHER_get_putfield, + codegen_addpatchref(cd, PATCHER_get_putfield, INSTRUCTION_UNRESOLVED_FIELD(iptr), 0); if (opt_showdisassemble) @@ -2224,46 +2209,41 @@ bool codegen(jitdata *jd) case TYPE_INT: d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_ILD(d, s1, disp); - store_reg_to_var_int(iptr->dst, d); break; case TYPE_LNG: d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_LLD(d, s1, disp); - store_reg_to_var_int(iptr->dst, d); break; case TYPE_ADR: d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_ALD(d, s1, disp); - store_reg_to_var_int(iptr->dst, d); break; case TYPE_FLT: d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1); M_FLD(d, s1, disp); - store_reg_to_var_flt(iptr->dst, d); break; case TYPE_DBL: d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FTMP1); M_DLD(d, s1, disp); - store_reg_to_var_flt(iptr->dst, d); break; } + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_PUTFIELD: /* ..., objectref, value ==> ... */ /* op1 = type, val.a = field address */ - var_to_reg_int(s1, src->prev, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); gen_nullptr_check(s1); if (!IS_FLT_DBL_TYPE(iptr->op1)) { - var_to_reg_int(s2, src, REG_ITMP2); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); } else { - var_to_reg_flt(s2, src, REG_FTMP2); + s2 = emit_load_s2(jd, iptr, src, REG_FTMP2); } if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - codegen_addpatchref(cd, mcodeptr, - PATCHER_get_putfield, + codegen_addpatchref(cd, PATCHER_get_putfield, INSTRUCTION_UNRESOLVED_FIELD(iptr), 0); if (opt_showdisassemble) @@ -2299,12 +2279,11 @@ bool codegen(jitdata *jd) /* op1 = type, val.a = field address (in */ /* following NOP) */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); gen_nullptr_check(s1); if (INSTRUCTION_IS_UNRESOLVED(iptr + 1)) { - codegen_addpatchref(cd, mcodeptr, - PATCHER_get_putfield, + codegen_addpatchref(cd, PATCHER_get_putfield, INSTRUCTION_UNRESOLVED_FIELD(iptr + 1), 0); if (opt_showdisassemble) @@ -2340,13 +2319,12 @@ bool codegen(jitdata *jd) case ICMD_ATHROW: /* ..., objectref ==> ... (, objectref) */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); M_INTMOVE(s1, REG_ITMP1_XPTR); #ifdef ENABLE_VERIFIER if (iptr->val.a) { - codegen_addpatchref(cd, mcodeptr, - PATCHER_athrow_areturn, + codegen_addpatchref(cd, PATCHER_athrow_areturn, (unresolved_class *) iptr->val.a, 0); if (opt_showdisassemble) @@ -2365,7 +2343,7 @@ bool codegen(jitdata *jd) case ICMD_GOTO: /* ... ==> ... */ /* op1 = target JavaVM pc */ M_BR(0); - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); ALIGNCODENOP; break; @@ -2373,7 +2351,7 @@ bool codegen(jitdata *jd) /* op1 = target JavaVM pc */ M_BSR(REG_ITMP1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_RET: /* ... ==> ... */ @@ -2392,23 +2370,23 @@ bool codegen(jitdata *jd) case ICMD_IFNULL: /* ..., value ==> ... */ /* op1 = target JavaVM pc */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); M_BEQZ(s1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFNONNULL: /* ..., value ==> ... */ /* op1 = target JavaVM pc */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); M_BNEZ(s1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFEQ: /* ..., value ==> ... */ /* op1 = target JavaVM pc, val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (iptr->val.i == 0) { M_BEQZ(s1, 0); } @@ -2422,13 +2400,13 @@ bool codegen(jitdata *jd) } M_BNEZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFLT: /* ..., value ==> ... */ /* op1 = target JavaVM pc, val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (iptr->val.i == 0) { M_BLTZ(s1, 0); } @@ -2442,13 +2420,13 @@ bool codegen(jitdata *jd) } M_BNEZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFLE: /* ..., value ==> ... */ /* op1 = target JavaVM pc, val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (iptr->val.i == 0) { M_BLEZ(s1, 0); } @@ -2462,13 +2440,13 @@ bool codegen(jitdata *jd) } M_BNEZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFNE: /* ..., value ==> ... */ /* op1 = target JavaVM pc, val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (iptr->val.i == 0) { M_BNEZ(s1, 0); } @@ -2482,13 +2460,13 @@ bool codegen(jitdata *jd) } M_BEQZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFGT: /* ..., value ==> ... */ /* op1 = target JavaVM pc, val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (iptr->val.i == 0) { M_BGTZ(s1, 0); } @@ -2502,13 +2480,13 @@ bool codegen(jitdata *jd) } M_BEQZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFGE: /* ..., value ==> ... */ /* op1 = target JavaVM pc, val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (iptr->val.i == 0) { M_BGEZ(s1, 0); } @@ -2522,13 +2500,13 @@ bool codegen(jitdata *jd) } M_BEQZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LEQ: /* ..., value ==> ... */ /* op1 = target JavaVM pc, val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (iptr->val.l == 0) { M_BEQZ(s1, 0); } @@ -2542,13 +2520,13 @@ bool codegen(jitdata *jd) } M_BNEZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LLT: /* ..., value ==> ... */ /* op1 = target JavaVM pc, val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (iptr->val.l == 0) { M_BLTZ(s1, 0); } @@ -2562,13 +2540,13 @@ bool codegen(jitdata *jd) } M_BNEZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LLE: /* ..., value ==> ... */ /* op1 = target JavaVM pc, val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (iptr->val.l == 0) { M_BLEZ(s1, 0); } @@ -2582,13 +2560,13 @@ bool codegen(jitdata *jd) } M_BNEZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LNE: /* ..., value ==> ... */ /* op1 = target JavaVM pc, val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (iptr->val.l == 0) { M_BNEZ(s1, 0); } @@ -2602,13 +2580,13 @@ bool codegen(jitdata *jd) } M_BEQZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LGT: /* ..., value ==> ... */ /* op1 = target JavaVM pc, val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (iptr->val.l == 0) { M_BGTZ(s1, 0); } @@ -2622,13 +2600,13 @@ bool codegen(jitdata *jd) } M_BEQZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LGE: /* ..., value ==> ... */ /* op1 = target JavaVM pc, val.l = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (iptr->val.l == 0) { M_BGEZ(s1, 0); } @@ -2642,69 +2620,69 @@ bool codegen(jitdata *jd) } M_BEQZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPEQ: /* ..., value, value ==> ... */ case ICMD_IF_LCMPEQ: /* op1 = target JavaVM pc */ case ICMD_IF_ACMPEQ: - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMPEQ(s1, s2, REG_ITMP1); M_BNEZ(REG_ITMP1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPNE: /* ..., value, value ==> ... */ case ICMD_IF_LCMPNE: /* op1 = target JavaVM pc */ case ICMD_IF_ACMPNE: - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMPEQ(s1, s2, REG_ITMP1); M_BEQZ(REG_ITMP1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPLT: /* ..., value, value ==> ... */ case ICMD_IF_LCMPLT: /* op1 = target JavaVM pc */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMPLT(s1, s2, REG_ITMP1); M_BNEZ(REG_ITMP1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPGT: /* ..., value, value ==> ... */ case ICMD_IF_LCMPGT: /* op1 = target JavaVM pc */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMPLE(s1, s2, REG_ITMP1); M_BEQZ(REG_ITMP1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPLE: /* ..., value, value ==> ... */ case ICMD_IF_LCMPLE: /* op1 = target JavaVM pc */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMPLE(s1, s2, REG_ITMP1); M_BNEZ(REG_ITMP1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPGE: /* ..., value, value ==> ... */ case ICMD_IF_LCMPGE: /* op1 = target JavaVM pc */ - var_to_reg_int(s1, src->prev, REG_ITMP1); - var_to_reg_int(s2, src, REG_ITMP2); + s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMPLT(s1, s2, REG_ITMP1); M_BEQZ(REG_ITMP1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; /* (value xx 0) ? IFxx_ICONST : ELSE_ICONST */ @@ -2715,19 +2693,19 @@ bool codegen(jitdata *jd) case ICMD_IFEQ_ICONST: /* ..., value ==> ..., constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); s3 = iptr->val.i; if (iptr[1].opc == ICMD_ELSE_ICONST) { if ((s3 == 1) && (iptr[1].val.i == 0)) { M_CMPEQ(s1, REG_ZERO, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; } if ((s3 == 0) && (iptr[1].val.i == 1)) { M_CMPEQ(s1, REG_ZERO, d); M_XOR_IMM(d, 1, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; } if (s1 == d) { @@ -2742,25 +2720,25 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP3, s3); M_CMOVEQ(s1, REG_ITMP3, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IFNE_ICONST: /* ..., value ==> ..., constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); s3 = iptr->val.i; if (iptr[1].opc == ICMD_ELSE_ICONST) { if ((s3 == 0) && (iptr[1].val.i == 1)) { M_CMPEQ(s1, REG_ZERO, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; } if ((s3 == 1) && (iptr[1].val.i == 0)) { M_CMPEQ(s1, REG_ZERO, d); M_XOR_IMM(d, 1, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; } if (s1 == d) { @@ -2775,24 +2753,24 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP3, s3); M_CMOVNE(s1, REG_ITMP3, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IFLT_ICONST: /* ..., value ==> ..., constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); s3 = iptr->val.i; if ((iptr[1].opc == ICMD_ELSE_ICONST)) { if ((s3 == 1) && (iptr[1].val.i == 0)) { M_CMPLT(s1, REG_ZERO, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; } if ((s3 == 0) && (iptr[1].val.i == 1)) { M_CMPLE(REG_ZERO, s1, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; } if (s1 == d) { @@ -2807,24 +2785,24 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP3, s3); M_CMOVLT(s1, REG_ITMP3, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IFGE_ICONST: /* ..., value ==> ..., constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); s3 = iptr->val.i; if ((iptr[1].opc == ICMD_ELSE_ICONST)) { if ((s3 == 1) && (iptr[1].val.i == 0)) { M_CMPLE(REG_ZERO, s1, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; } if ((s3 == 0) && (iptr[1].val.i == 1)) { M_CMPLT(s1, REG_ZERO, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; } if (s1 == d) { @@ -2839,24 +2817,24 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP3, s3); M_CMOVGE(s1, REG_ITMP3, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IFGT_ICONST: /* ..., value ==> ..., constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); s3 = iptr->val.i; if ((iptr[1].opc == ICMD_ELSE_ICONST)) { if ((s3 == 1) && (iptr[1].val.i == 0)) { M_CMPLT(REG_ZERO, s1, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; } if ((s3 == 0) && (iptr[1].val.i == 1)) { M_CMPLE(s1, REG_ZERO, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; } if (s1 == d) { @@ -2871,24 +2849,24 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP3, s3); M_CMOVGT(s1, REG_ITMP3, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IFLE_ICONST: /* ..., value ==> ..., constant */ /* val.i = constant */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); s3 = iptr->val.i; if ((iptr[1].opc == ICMD_ELSE_ICONST)) { if ((s3 == 1) && (iptr[1].val.i == 0)) { M_CMPLE(s1, REG_ZERO, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; } if ((s3 == 0) && (iptr[1].val.i == 1)) { M_CMPLT(REG_ZERO, s1, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; } if (s1 == d) { @@ -2903,26 +2881,25 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP3, s3); M_CMOVLE(s1, REG_ITMP3, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_IRETURN: /* ..., retvalue ==> ... */ case ICMD_LRETURN: - var_to_reg_int(s1, src, REG_RESULT); + s1 = emit_load_s1(jd, iptr, src, REG_RESULT); M_INTMOVE(s1, REG_RESULT); goto nowperformreturn; case ICMD_ARETURN: /* ..., retvalue ==> ... */ - var_to_reg_int(s1, src, REG_RESULT); + s1 = emit_load_s1(jd, iptr, src, REG_RESULT); M_INTMOVE(s1, REG_RESULT); #ifdef ENABLE_VERIFIER if (iptr->val.a) { - codegen_addpatchref(cd, mcodeptr, - PATCHER_athrow_areturn, + codegen_addpatchref(cd, PATCHER_athrow_areturn, (unresolved_class *) iptr->val.a, 0); if (opt_showdisassemble) @@ -2934,7 +2911,7 @@ bool codegen(jitdata *jd) case ICMD_FRETURN: /* ..., retvalue ==> ... */ case ICMD_DRETURN: - var_to_reg_flt(s1, src, REG_FRESULT); + s1 = emit_load_s1(jd, iptr, src, REG_FRESULT); M_FLTMOVE(s1, REG_FRESULT); goto nowperformreturn; @@ -2964,7 +2941,7 @@ nowperformreturn: disp = dseg_addaddress(cd, (void *) builtin_displaymethodstop); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); M_DLD(REG_FRESULT, REG_SP, 2 * 8); @@ -2993,7 +2970,7 @@ nowperformreturn: disp = dseg_addaddress(cd, BUILTIN_monitorexit); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = -(s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = -(s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, disp); switch (iptr->opc) { @@ -3047,7 +3024,7 @@ nowperformreturn: l = s4ptr[1]; /* low */ i = s4ptr[2]; /* high */ - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); if (l == 0) { M_INTMOVE(s1, REG_ITMP1); } else if (l <= 32768) { @@ -3067,7 +3044,7 @@ nowperformreturn: M_CMPULE(REG_ITMP1, REG_ITMP2, REG_ITMP2); } M_BEQZ(REG_ITMP2, 0); - codegen_addreference(cd, (basicblock *) tptr[0], mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); /* build jump table top down and use address of lowest entry */ @@ -3101,7 +3078,7 @@ nowperformreturn: i = s4ptr[1]; /* count */ MCODECHECK((i<<2)+8); - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); while (--i >= 0) { s4ptr += 2; ++tptr; @@ -3119,13 +3096,13 @@ nowperformreturn: M_CMPEQ(s1, REG_ITMP2, REG_ITMP2); } M_BNEZ(REG_ITMP2, 0); - codegen_addreference(cd, (basicblock *) tptr[0], mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); } M_BR(0); tptr = (void **) iptr->target; - codegen_addreference(cd, (basicblock *) tptr[0], mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); ALIGNCODENOP; break; @@ -3168,20 +3145,20 @@ gen_method: if (IS_INT_LNG_TYPE(src->type)) { if (!md->params[s3].inmemory) { s1 = rd->argintregs[md->params[s3].regoff]; - var_to_reg_int(d, src, s1); + d = emit_load_s1(jd, iptr, src, s1); M_INTMOVE(d, s1); } else { - var_to_reg_int(d, src, REG_ITMP1); + d = emit_load_s1(jd, iptr, src, REG_ITMP1); M_LST(d, REG_SP, md->params[s3].regoff * 8); } } else { if (!md->params[s3].inmemory) { s1 = rd->argfltregs[md->params[s3].regoff]; - var_to_reg_flt(d, src, s1); + d = emit_load_s1(jd, iptr, src, s1); M_FLTMOVE(d, s1); } else { - var_to_reg_flt(d, src, REG_FTMP1); + d = emit_load_s1(jd, iptr, src, REG_FTMP1); M_DST(d, REG_SP, md->params[s3].regoff * 8); } } @@ -3194,20 +3171,20 @@ gen_method: M_ALD(REG_PV, REG_PV, disp); /* Pointer to built-in-function */ M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); /* if op1 == true, we need to check for an exception */ if (iptr->op1 == true) { M_BEQZ(REG_RESULT, 0); - codegen_add_fillinstacktrace_ref(cd, mcodeptr); + codegen_add_fillinstacktrace_ref(cd); } break; case ICMD_INVOKESPECIAL: M_BEQZ(rd->argintregs[0], 0); - codegen_add_nullpointerexception_ref(cd, mcodeptr); + codegen_add_nullpointerexception_ref(cd); /* fall through */ case ICMD_INVOKESTATIC: @@ -3216,8 +3193,8 @@ gen_method: disp = dseg_addaddress(cd, NULL); - codegen_addpatchref(cd, mcodeptr, - PATCHER_invokestatic_special, um, disp); + codegen_addpatchref(cd, PATCHER_invokestatic_special, + um, disp); if (opt_showdisassemble) M_NOP; @@ -3231,7 +3208,7 @@ gen_method: M_ALD(REG_PV, REG_PV, disp); /* method pointer in r27 */ M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); break; @@ -3241,8 +3218,7 @@ gen_method: if (!lm) { unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr); - codegen_addpatchref(cd, mcodeptr, - PATCHER_invokevirtual, um, 0); + codegen_addpatchref(cd, PATCHER_invokevirtual, um, 0); if (opt_showdisassemble) M_NOP; @@ -3260,7 +3236,7 @@ gen_method: OFFSET(java_objectheader, vftbl)); M_ALD(REG_PV, REG_METHODPTR, s1); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); break; @@ -3270,8 +3246,7 @@ gen_method: if (!lm) { unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr); - codegen_addpatchref(cd, mcodeptr, - PATCHER_invokeinterface, um, 0); + codegen_addpatchref(cd, PATCHER_invokeinterface, um, 0); if (opt_showdisassemble) M_NOP; @@ -3294,7 +3269,7 @@ gen_method: M_ALD(REG_METHODPTR, REG_METHODPTR, s1); M_ALD(REG_PV, REG_METHODPTR, s2); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); break; } @@ -3305,12 +3280,13 @@ gen_method: if (IS_INT_LNG_TYPE(iptr->dst->type)) { s1 = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT); M_INTMOVE(REG_RESULT, s1); - store_reg_to_var_int(iptr->dst, s1); +/* emit_store(jd, iptr, iptr->dst, s1); */ } else { s1 = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_FRESULT); M_FLTMOVE(REG_FRESULT, s1); - store_reg_to_var_flt(iptr->dst, s1); +/* emit_store(jd, iptr, iptr->dst, s1); */ } + emit_store(jd, iptr, iptr->dst, s1); } break; @@ -3352,9 +3328,9 @@ gen_method: } #if defined(USE_THREADS) && defined(NATIVE_THREADS) - codegen_threadcritrestart(cd, (u1 *) mcodeptr - cd->mcodebase); + codegen_threadcritrestart(cd, (u1 *) cd->mcodeptr - cd->mcodebase); #endif - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); /* calculate interface checkcast code size */ @@ -3375,8 +3351,7 @@ gen_method: disp = dseg_adds4(cd, 0); /* super->flags */ - codegen_addpatchref(cd, mcodeptr, - PATCHER_checkcast_instanceof_flags, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags, (constant_classref *) iptr->target, disp); @@ -3397,7 +3372,7 @@ gen_method: M_BEQZ(s1, s2); } else { - codegen_addpatchref(cd, mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_interface, (constant_classref *) iptr->target, 0); @@ -3411,12 +3386,12 @@ gen_method: OFFSET(vftbl_t, interfacetablelength)); M_LDA(REG_ITMP3, REG_ITMP3, -superindex); M_BLEZ(REG_ITMP3, 0); - codegen_add_classcastexception_ref(cd, mcodeptr); + codegen_add_classcastexception_ref(cd); M_ALD(REG_ITMP3, REG_ITMP2, (s4) (OFFSET(vftbl_t, interfacetable[0]) - superindex * sizeof(methodptr*))); M_BEQZ(REG_ITMP3, 0); - codegen_add_classcastexception_ref(cd, mcodeptr); + codegen_add_classcastexception_ref(cd); if (!super) M_BR(s3); @@ -3431,7 +3406,7 @@ gen_method: M_BEQZ(s1, s3); } else { - codegen_addpatchref(cd, mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_class, (constant_classref *) iptr->target, disp); @@ -3443,7 +3418,7 @@ gen_method: M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); M_ALD(REG_ITMP3, REG_PV, disp); #if defined(USE_THREADS) && defined(NATIVE_THREADS) - codegen_threadcritstart(cd, (u1 *) mcodeptr - cd->mcodebase); + codegen_threadcritstart(cd, (u1 *) cd->mcodeptr - cd->mcodebase); #endif M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, baseval)); /* if (s1 != REG_ITMP1) { */ @@ -3460,26 +3435,25 @@ gen_method: M_ALD(REG_ITMP3, REG_PV, disp); M_ILD(REG_ITMP3, REG_ITMP3, OFFSET(vftbl_t, diffval)); #if defined(USE_THREADS) && defined(NATIVE_THREADS) - codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase); + codegen_threadcritstop(cd, (u1 *) cd->mcodeptr - cd->mcodebase); #endif /* } */ M_CMPULE(REG_ITMP2, REG_ITMP3, REG_ITMP3); M_BEQZ(REG_ITMP3, 0); - codegen_add_classcastexception_ref(cd, mcodeptr); + codegen_add_classcastexception_ref(cd); } d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, s1); } else { /* array type cast-check */ - var_to_reg_int(s1, src, rd->argintregs[0]); + s1 = emit_load_s1(jd, iptr, src, rd->argintregs[0]); M_INTMOVE(s1, rd->argintregs[0]); disp = dseg_addaddress(cd, iptr->val.a); if (iptr->val.a == NULL) { - codegen_addpatchref(cd, mcodeptr, - PATCHER_builtin_arraycheckcast, + codegen_addpatchref(cd, PATCHER_builtin_arraycheckcast, (constant_classref *) iptr->target, disp); @@ -3491,17 +3465,17 @@ gen_method: disp = dseg_addaddress(cd, BUILTIN_arraycheckcast); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); M_BEQZ(REG_RESULT, 0); - codegen_add_classcastexception_ref(cd, mcodeptr); + codegen_add_classcastexception_ref(cd); - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, s1); } M_INTMOVE(s1, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; case ICMD_INSTANCEOF: /* ..., objectref ==> ..., intresult */ @@ -3539,9 +3513,9 @@ gen_method: } #if defined(USE_THREADS) && defined(NATIVE_THREADS) - codegen_threadcritrestart(cd, (u1 *) mcodeptr - cd->mcodebase); + codegen_threadcritrestart(cd, (u1 *) cd->mcodeptr - cd->mcodebase); #endif - var_to_reg_int(s1, src, REG_ITMP1); + s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); if (s1 == d) { M_MOV(s1, REG_ITMP1); @@ -3568,8 +3542,7 @@ gen_method: disp = dseg_adds4(cd, 0); /* super->flags */ - codegen_addpatchref(cd, mcodeptr, - PATCHER_checkcast_instanceof_flags, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags, (constant_classref *) iptr->target, disp); if (opt_showdisassemble) @@ -3596,7 +3569,7 @@ gen_method: if (d == REG_ITMP2) M_CLR(d); - codegen_addpatchref(cd, mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_interface, (constant_classref *) iptr->target, 0); @@ -3627,8 +3600,7 @@ gen_method: M_BEQZ(s1, s3); } else { - codegen_addpatchref(cd, mcodeptr, - PATCHER_checkcast_instanceof_class, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_class, (constant_classref *) iptr->target, disp); @@ -3639,18 +3611,18 @@ gen_method: M_ALD(REG_ITMP1, s1, OFFSET(java_objectheader, vftbl)); M_ALD(REG_ITMP2, REG_PV, disp); #if defined(USE_THREADS) && defined(NATIVE_THREADS) - codegen_threadcritstart(cd, (u1 *) mcodeptr - cd->mcodebase); + codegen_threadcritstart(cd, (u1 *) cd->mcodeptr - cd->mcodebase); #endif M_ILD(REG_ITMP1, REG_ITMP1, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, baseval)); M_ILD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, diffval)); #if defined(USE_THREADS) && defined(NATIVE_THREADS) - codegen_threadcritstop(cd, (u1 *) mcodeptr - cd->mcodebase); + codegen_threadcritstop(cd, (u1 *) cd->mcodeptr - cd->mcodebase); #endif M_ISUB(REG_ITMP1, REG_ITMP3, REG_ITMP1); M_CMPULE(REG_ITMP1, REG_ITMP2, d); } - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); } break; @@ -3665,7 +3637,7 @@ gen_method: /* copy SAVEDVAR sizes to stack */ if (src->varkind != ARGVAR) { - var_to_reg_int(s2, src, REG_ITMP1); + s2 = emit_load_s2(jd, iptr, src, REG_ITMP1); M_LST(s2, REG_SP, s1 * 8); } } @@ -3679,8 +3651,7 @@ gen_method: if (iptr->val.a == NULL) { disp = dseg_addaddress(cd, 0); - codegen_addpatchref(cd, mcodeptr, - PATCHER_builtin_multianewarray, + codegen_addpatchref(cd, PATCHER_builtin_multianewarray, (constant_classref *) iptr->target, disp); @@ -3702,17 +3673,17 @@ gen_method: disp = dseg_addaddress(cd, BUILTIN_multianewarray); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); /* check for exception before result assignment */ M_BEQZ(REG_RESULT, 0); - codegen_add_fillinstacktrace_ref(cd, mcodeptr); + codegen_add_fillinstacktrace_ref(cd); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT); M_INTMOVE(REG_RESULT, d); - store_reg_to_var_int(iptr->dst, d); + emit_store(jd, iptr, iptr->dst, d); break; default: @@ -3736,7 +3707,8 @@ gen_method: if ((src->varkind != STACKVAR)) { s2 = src->type; if (IS_FLT_DBL_TYPE(s2)) { - var_to_reg_flt(s1, src, REG_FTMP1); + /* XXX can be one call */ + s1 = emit_load_s1(jd, NULL, src, REG_FTMP1); if (!(rd->interfaces[len][s2].flags & INMEMORY)) { M_FLTMOVE(s1,rd->interfaces[len][s2].regoff); } @@ -3745,7 +3717,8 @@ gen_method: } } else { - var_to_reg_int(s1, src, REG_ITMP1); + /* XXX can be one call */ + s1 = emit_load_s1(jd, NULL, src, REG_ITMP1); if (!(rd->interfaces[len][s2].flags & INMEMORY)) { M_INTMOVE(s1,rd->interfaces[len][s2].regoff); } @@ -3768,8 +3741,8 @@ gen_method: exceptionref *eref; patchref *pref; u4 mcode; - s4 *savedmcodeptr; - s4 *tmpmcodeptr; + u4 *savedmcodeptr; + u4 *tmpmcodeptr; savedmcodeptr = NULL; @@ -3778,7 +3751,7 @@ gen_method: for (eref = cd->exceptionrefs; eref != NULL; eref = eref->next) { gen_resolvebranch((u1 *) cd->mcodebase + eref->branchpos, eref->branchpos, - (u1 *) mcodeptr - cd->mcodebase); + (u1 *) cd->mcodeptr - cd->mcodebase); MCODECHECK(100); @@ -3801,11 +3774,11 @@ gen_method: M_ALD(REG_ITMP3, REG_PV, disp); if (savedmcodeptr != NULL) { - disp = savedmcodeptr - mcodeptr - 1; + disp = savedmcodeptr - (cd->mcodeptr + 1); M_BR(disp); } else { - savedmcodeptr = mcodeptr; + savedmcodeptr = cd->mcodeptr; M_MOV(REG_PV, rd->argintregs[0]); M_MOV(REG_SP, rd->argintregs[1]); @@ -3824,7 +3797,7 @@ gen_method: M_MOV(REG_ITMP3, REG_PV); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); M_MOV(REG_RESULT, REG_ITMP1_XPTR); @@ -3852,18 +3825,18 @@ gen_method: /* Get machine code which is patched back in later. The call is 1 instruction word long. */ - savedmcodeptr = (s4 *) (cd->mcodebase + pref->branchpos); + savedmcodeptr = (u4 *) (cd->mcodebase + pref->branchpos); mcode = *savedmcodeptr; /* Patch in the call to call the following code (done at compile time). */ - tmpmcodeptr = mcodeptr; /* save current mcodeptr */ - mcodeptr = savedmcodeptr; /* set mcodeptr to patch position */ + tmpmcodeptr = cd->mcodeptr; /* save current mcodeptr */ + cd->mcodeptr = savedmcodeptr; /* set mcodeptr to patch position */ M_BSR(REG_ITMP3, tmpmcodeptr - (savedmcodeptr + 1)); - mcodeptr = tmpmcodeptr; /* restore the current mcodeptr */ + cd->mcodeptr = tmpmcodeptr; /* restore the current mcodeptr */ /* create stack frame */ @@ -3930,17 +3903,17 @@ gen_method: /* note start of stub code */ - replacementpoint->outcode = (u1*) (ptrint)((u1*)mcodeptr - cd->mcodebase); + replacementpoint->outcode = (u1*) (ptrint)((u1 *) cd->mcodeptr - cd->mcodebase); /* make machine code for patching */ - tmpmcodeptr = mcodeptr; - mcodeptr = (s4*) &(replacementpoint->mcode); + tmpmcodeptr = cd->mcodeptr; + cd->mcodeptr = (u4 *) &(replacementpoint->mcode); disp = (ptrint)((s4*)replacementpoint->outcode - (s4*)replacementpoint->pc) - 1; M_BR(disp); - mcodeptr = tmpmcodeptr; + cd->mcodeptr = tmpmcodeptr; /* create stack frame - 16-byte aligned */ @@ -3961,7 +3934,7 @@ gen_method: } } - codegen_finish(jd, (s4) ((u1 *) mcodeptr - cd->mcodebase)); + codegen_finish(jd); /* everything's ok */ @@ -3983,9 +3956,10 @@ gen_method: u1 *createcompilerstub(methodinfo *m) { - u1 *s; /* memory to hold the stub */ - ptrint *d; - s4 *mcodeptr; /* code generation pointer */ + u1 *s; /* memory to hold the stub */ + ptrint *d; + codegendata *cd; + s4 dumpsize; /* code generation pointer */ s = CNEW(u1, COMPILERSTUB_SIZE); @@ -3994,8 +3968,13 @@ u1 *createcompilerstub(methodinfo *m) d = (ptrint *) s; s = s + COMPILERSTUB_DATASIZE; - mcodeptr = (s4 *) s; - + /* mark start of dump memory area */ + + dumpsize = dump_size(); + + cd = DNEW(codegendata); + cd->mcodeptr = (u4 *) s; + /* Store the methodinfo* in the same place as in the methodheader for compiled methods. */ @@ -4013,6 +3992,10 @@ u1 *createcompilerstub(methodinfo *m) count_cstub_len += COMPILERSTUB_SIZE; #endif + /* release dump area */ + + dump_release(dumpsize); + return s; } @@ -4028,7 +4011,6 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) methodinfo *m; codegendata *cd; registerdata *rd; - s4 *mcodeptr; /* code generation pointer */ s4 stackframesize; /* size of stackframe if needed */ methoddesc *md; s4 nativeparams; @@ -4069,11 +4051,6 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) (void) dseg_addlinenumbertablesize(cd); (void) dseg_adds4(cd, 0); /* ExTableSize */ - - /* initialize mcode variables */ - - mcodeptr = (s4 *) cd->mcodeptr; - /* generate stub code */ M_LDA(REG_SP, REG_SP, -stackframesize * 8); @@ -4115,7 +4092,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) disp = dseg_addaddress(cd, builtin_trace_args); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); for (i = 0, j = 1; i < md->paramcount && i < INT_ARG_CNT; i++) { @@ -4146,7 +4123,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) #if !defined(WITH_STATIC_CLASSPATH) if (f == NULL) { - codegen_addpatchref(cd, mcodeptr, PATCHER_resolve_native, m, funcdisp); + codegen_addpatchref(cd, PATCHER_resolve_native, m, funcdisp); if (opt_showdisassemble) M_NOP; @@ -4178,7 +4155,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) disp = dseg_addaddress(cd, codegen_start_native_call); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); /* restore integer and float argument registers */ @@ -4266,7 +4243,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) M_ALD(REG_PV, REG_PV, funcdisp); M_JSR(REG_RA, REG_PV); /* call native method */ - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); /* recompute pv from ra */ /* save return value */ @@ -4282,7 +4259,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) disp = dseg_addaddress(cd, codegen_finish_native_call); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); /* call finished trace */ @@ -4306,7 +4283,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) disp = dseg_addaddress(cd, builtin_displaymethodstop); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); } #endif /* !defined(NDEBUG) */ @@ -4317,7 +4294,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) disp = dseg_addaddress(cd, builtin_get_exceptionptrptr); M_ALD(REG_PV, REG_PV, disp); M_JSR(REG_RA, REG_PV); - disp = (s4) ((u1 *) mcodeptr - cd->mcodebase); + disp = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); M_LDA(REG_PV, REG_RA, -disp); M_MOV(REG_RESULT, REG_ITMP3); #else @@ -4358,8 +4335,8 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) { patchref *pref; u4 mcode; - s4 *savedmcodeptr; - s4 *tmpmcodeptr; + u4 *savedmcodeptr; + u4 *tmpmcodeptr; /* there can only be one ref entry */ @@ -4369,18 +4346,18 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) /* Get machine code which is patched back in later. The call is 1 instruction word long. */ - savedmcodeptr = (s4 *) (cd->mcodebase + pref->branchpos); + savedmcodeptr = (u4 *) (cd->mcodebase + pref->branchpos); mcode = (u4) *savedmcodeptr; /* patch in the call to call the following code (done at compile */ /* time) */ - tmpmcodeptr = mcodeptr; /* save current mcodeptr */ - mcodeptr = savedmcodeptr; /* set mcodeptr to patch position */ + tmpmcodeptr = cd->mcodeptr; /* save current mcodeptr */ + cd->mcodeptr = savedmcodeptr; /* set mcodeptr to patch position */ M_BSR(REG_ITMP3, tmpmcodeptr - (savedmcodeptr + 1)); - mcodeptr = tmpmcodeptr; /* restore the current mcodeptr */ + cd->mcodeptr = tmpmcodeptr; /* restore the current mcodeptr */ /* create stack frame */ @@ -4434,7 +4411,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) } } - codegen_finish(jd, (s4) ((u1 *) mcodeptr - cd->mcodebase)); + codegen_finish(jd); return jd->code->entrypoint; } diff --git a/src/vm/jit/alpha/codegen.h b/src/vm/jit/alpha/codegen.h index 34ed13b46..3e81bff67 100644 --- a/src/vm/jit/alpha/codegen.h +++ b/src/vm/jit/alpha/codegen.h @@ -29,7 +29,7 @@ Changes: Christian Thalinger - $Id: codegen.h 4722 2006-04-03 15:36:00Z twisti $ + $Id: codegen.h 4826 2006-04-24 16:06:16Z twisti $ */ @@ -50,7 +50,7 @@ #define gen_nullptr_check(objreg) \ if (checknull) { \ M_BEQZ((objreg), 0); \ - codegen_add_nullpointerexception_ref(cd, mcodeptr); \ + codegen_add_nullpointerexception_ref(cd); \ } #define gen_bound_check \ @@ -58,19 +58,21 @@ M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\ M_CMPULT(s2, REG_ITMP3, REG_ITMP3);\ M_BEQZ(REG_ITMP3, 0);\ - codegen_add_arrayindexoutofboundsexception_ref(cd, mcodeptr, s2); \ + codegen_add_arrayindexoutofboundsexception_ref(cd, s2); \ } /* MCODECHECK(icnt) */ #define MCODECHECK(icnt) \ - if ((mcodeptr + (icnt)) > cd->mcodeend) \ - mcodeptr = codegen_increase(cd, (u1 *) mcodeptr) + do { \ + if ((cd->mcodeptr + (icnt)) > (u4 *) cd->mcodeend) \ + codegen_increase(cd); \ + } while (0) #define ALIGNCODENOP \ - if ((s4) ((ptrint) mcodeptr & 7)) { \ + if ((s4) ((ptrint) cd->mcodeptr & 7)) { \ M_NOP; \ } @@ -80,7 +82,11 @@ if a and b are the same int-register, no code will be generated. */ -#define M_INTMOVE(a,b) if (a != b) { M_MOV(a, b); } +#define M_INTMOVE(a,b) \ + do { \ + if ((a) != (b)) \ + M_MOV(a, b); \ + } while (0) /* M_FLTMOVE: @@ -88,109 +94,16 @@ if a and b are the same float-register, no code will be generated */ -#define M_FLTMOVE(a,b) if (a != b) { M_FMOV(a, b); } - - -/* var_to_reg_xxx ************************************************************** - - This function generates code to fetch data from a pseudo-register - into a real register. If the pseudo-register has actually been - assigned to a real register, no code will be emitted, since - following operations can use this register directly. - - v: pseudoregister to be fetched from - tempregnum: temporary register to be used if v is actually spilled to ram - - return: the register number, where the operand can be found after - fetching (this wil be either tempregnum or the register - number allready given to v) - -*******************************************************************************/ - -#define var_to_reg_int(regnr,v,tempnr) \ +#define M_FLTMOVE(a,b) \ do { \ - if ((v)->flags & INMEMORY) { \ - COUNT_SPILLS; \ - M_LLD(tempnr, REG_SP, (v)->regoff * 8); \ - regnr = tempnr; \ - } else { \ - regnr = (v)->regoff; \ - } \ + if ((a) != (b)) \ + M_FMOV(a, b); \ } while (0) -#define var_to_reg_flt(regnr,v,tempnr) \ - do { \ - if ((v)->flags & INMEMORY) { \ - COUNT_SPILLS; \ - M_DLD(tempnr, REG_SP, (v)->regoff * 8); \ - regnr = tempnr; \ - } else { \ - regnr = (v)->regoff; \ - } \ - } while (0) - - -/* store_reg_to_var_xxx ******************************************************** - - This function generates the code to store the result of an - operation back into a spilled pseudo-variable. If the - pseudo-variable has not been spilled in the first place, this - function will generate nothing. - - v ............ Pseudovariable - tempregnum ... Number of the temporary registers as returned by - reg_of_var. - -*******************************************************************************/ - -#define store_reg_to_var_int(sptr, tempregnum) \ - do { \ - if ((sptr)->flags & INMEMORY) { \ - COUNT_SPILLS; \ - M_LST(tempregnum, REG_SP, (sptr)->regoff * 8); \ - } \ - } while (0) - -#define store_reg_to_var_flt(sptr, tempregnum) \ - do { \ - if ((sptr)->flags & INMEMORY) { \ - COUNT_SPILLS; \ - M_DST(tempregnum, REG_SP, (sptr)->regoff * 8); \ - } \ - } while (0) - - -#define M_COPY(from,to) \ - d = codegen_reg_of_var(rd, iptr->opc, (to), REG_IFTMP); \ - if ((from->regoff != to->regoff) || \ - ((from->flags ^ to->flags) & INMEMORY)) { \ - if (IS_FLT_DBL_TYPE(from->type)) { \ - var_to_reg_flt(s1, from, d); \ - M_FLTMOVE(s1,d); \ - store_reg_to_var_flt(to, d); \ - } else { \ - var_to_reg_int(s1, from, d); \ - M_INTMOVE(s1,d); \ - store_reg_to_var_int(to, d); \ - } \ - } - -#define ICONST(r,c) \ - if ((c) >= -32768 && (c) <= 32767) { \ - M_LDA_INTERN((r), REG_ZERO, c); \ - } else { \ - disp = dseg_adds4(cd, (c)); \ - M_ILD((r), REG_PV, disp); \ - } - -#define LCONST(r,c) \ - if ((c) >= -32768 && (c) <= 32767) { \ - M_LDA_INTERN((r), REG_ZERO, (c)); \ - } else { \ - disp = dseg_adds8(cd, (c)); \ - M_LLD((r), REG_PV, disp); \ - } +#define M_COPY(s,d) emit_copy(jd, iptr, (s), (d)) +#define ICONST(d,c) emit_iconst(cd, (d), (c)) +#define LCONST(d,c) emit_lconst(cd, (d), (c)) /* macros to create code ******************************************************/ @@ -210,7 +123,7 @@ */ #define M_OP3(op,fu,a,b,c,const) \ - *(mcodeptr++) = ((((s4) (op)) << 26) | ((a) << 21) | ((b) << (16 - 3 * (const))) | ((const) << 12) | ((fu) << 5) | ((c))) + *(cd->mcodeptr++) = ((((s4) (op)) << 26) | ((a) << 21) | ((b) << (16 - 3 * (const))) | ((const) << 12) | ((fu) << 5) | ((c))) /* 3-address-floating-point-operation: M_FOP3 @@ -221,7 +134,7 @@ */ #define M_FOP3(op,fu,a,b,c) \ - *(mcodeptr++) = ((((s4) (op)) << 26) | ((a) << 21) | ((b) << 16) | ((fu) << 5) | (c)) + *(cd->mcodeptr++) = ((((s4) (op)) << 26) | ((a) << 21) | ((b) << 16) | ((fu) << 5) | (c)) /* branch instructions: M_BRA @@ -231,7 +144,7 @@ */ #define M_BRA(op,a,disp) \ - *(mcodeptr++) = ((((s4) (op)) << 26) | ((a) << 21) | ((disp) & 0x1fffff)) + *(cd->mcodeptr++) = ((((s4) (op)) << 26) | ((a) << 21) | ((disp) & 0x1fffff)) /* memory operations: M_MEM @@ -242,7 +155,7 @@ */ #define M_MEM(op,a,b,disp) \ - *(mcodeptr++) = ((((s4) (op)) << 26) | ((a) << 21) | ((b) << 16) | ((disp) & 0xffff)) + *(cd->mcodeptr++) = ((((s4) (op)) << 26) | ((a) << 21) | ((b) << 16) | ((disp) & 0xffff)) /* macros for all used commands (see an Alpha-manual for description) *********/ diff --git a/src/vm/jit/alpha/emit.c b/src/vm/jit/alpha/emit.c index 17c66027b..5a29543b5 100644 --- a/src/vm/jit/alpha/emit.c +++ b/src/vm/jit/alpha/emit.c @@ -28,7 +28,7 @@ Changes: - $Id: emitfuncs.c 4398 2006-01-31 23:43:08Z twisti $ + $Id: emit.c 4398 2006-01-31 23:43:08Z twisti $ */ @@ -37,9 +37,9 @@ #include "md-abi.h" +#include "vm/jit/emit.h" #include "vm/jit/jit.h" #include "vm/jit/alpha/codegen.h" -#include "vm/jit/alpha/emit.h" /* code generation functions **************************************************/ @@ -173,10 +173,9 @@ void emit_copy(jitdata *jd, instruction *iptr, stackptr src, stackptr dst) cd = jd->cd; rd = jd->rd; - d = codegen_reg_of_var(rd, iptr->opc, dst, REG_IFTMP); - if ((src->regoff != dst->regoff) || ((src->flags ^ dst->flags) & INMEMORY)) { + d = codegen_reg_of_var(rd, iptr->opc, dst, REG_IFTMP); s1 = emit_load_s1(jd, iptr, src, d); if (IS_FLT_DBL_TYPE(src->type)) @@ -202,6 +201,19 @@ void emit_iconst(codegendata *cd, s4 d, s4 value) } +void emit_lconst(codegendata *cd, s4 d, s8 value) +{ + s4 disp; + + if ((value >= -32768) && (value <= 32767)) { + M_LDA_INTERN(d, REG_ZERO, value); + } else { + disp = dseg_adds8(cd, value); + M_LLD(d, REG_PV, disp); + } +} + + /* * These are local overrides for various environment variables in Emacs. * Please do not remove this and leave it at the end of the file, where diff --git a/src/vm/jit/codegen-common.c b/src/vm/jit/codegen-common.c index 7be1d3e9e..59689625d 100644 --- a/src/vm/jit/codegen-common.c +++ b/src/vm/jit/codegen-common.c @@ -48,7 +48,7 @@ memory. All functions writing values into the data area return the offset relative the begin of the code area (start of procedure). - $Id: codegen-common.c 4775 2006-04-14 11:57:04Z twisti $ + $Id: codegen-common.c 4826 2006-04-24 16:06:16Z twisti $ */ @@ -165,7 +165,7 @@ void codegen_setup(jitdata *jd) /* initialize mcode variables */ -#if defined(__I386__) || defined(__X86_64__) +#if defined(__I386__) || defined(__X86_64__) cd->mcodeptr = cd->mcodebase; #else cd->mcodeptr = (u4 *) cd->mcodebase; @@ -245,7 +245,7 @@ void codegen_close(void) *******************************************************************************/ -s4 *codegen_increase(codegendata *cd, u1 *mcodeptr) +void codegen_increase(codegendata *cd) { u1 *oldmcodebase; @@ -262,16 +262,21 @@ s4 *codegen_increase(codegendata *cd, u1 *mcodeptr) cd->mcodesize *= 2; cd->mcodeend = cd->mcodebase + cd->mcodesize; + /* set new mcodeptr */ + +#if defined(__I386__) || defined(__X86_64__) + cd->mcodeptr = cd->mcodebase + ((u1 *) cd->mcodeptr - oldmcodebase); +#else + cd->mcodeptr = (u4 *) (cd->mcodebase + + ((u1 *) cd->mcodeptr - oldmcodebase)); +#endif + #if defined(__I386__) || defined(__MIPS__) || defined(__X86_64__) || defined(ENABLE_INTRP) /* adjust the pointer to the last patcher position */ if (cd->lastmcodeptr != NULL) cd->lastmcodeptr = cd->mcodebase + (cd->lastmcodeptr - oldmcodebase); #endif - - /* return the new mcodeptr */ - - return (s4 *) (cd->mcodebase + (mcodeptr - oldmcodebase)); } @@ -305,11 +310,11 @@ u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr) #endif -void codegen_addreference(codegendata *cd, basicblock *target, void *branchptr) +void codegen_addreference(codegendata *cd, basicblock *target) { s4 branchpos; - branchpos = (u1 *) branchptr - cd->mcodebase; + branchpos = (u1 *) cd->mcodeptr - cd->mcodebase; #if defined(ENABLE_JIT) /* Check if the target basicblock has already a start pc, so the @@ -347,13 +352,13 @@ void codegen_addreference(codegendata *cd, basicblock *target, void *branchptr) *******************************************************************************/ -static void codegen_add_exception_ref(codegendata *cd, void *branchptr, s4 reg, +static void codegen_add_exception_ref(codegendata *cd, s4 reg, functionptr function) { s4 branchpos; exceptionref *eref; - branchpos = (u1 *) branchptr - cd->mcodebase; + branchpos = (u1 *) cd->mcodeptr - cd->mcodebase; eref = DNEW(exceptionref); @@ -372,10 +377,9 @@ static void codegen_add_exception_ref(codegendata *cd, void *branchptr, s4 reg, *******************************************************************************/ -void codegen_add_arithmeticexception_ref(codegendata *cd, void *branchptr) +void codegen_add_arithmeticexception_ref(codegendata *cd) { - codegen_add_exception_ref(cd, branchptr, -1, - STACKTRACE_inline_arithmeticexception); + codegen_add_exception_ref(cd, -1, STACKTRACE_inline_arithmeticexception); } @@ -385,10 +389,9 @@ void codegen_add_arithmeticexception_ref(codegendata *cd, void *branchptr) *******************************************************************************/ -void codegen_add_arrayindexoutofboundsexception_ref(codegendata *cd, - void *branchptr, s4 reg) +void codegen_add_arrayindexoutofboundsexception_ref(codegendata *cd, s4 reg) { - codegen_add_exception_ref(cd, branchptr, reg, + codegen_add_exception_ref(cd, reg, STACKTRACE_inline_arrayindexoutofboundsexception); } @@ -399,10 +402,9 @@ void codegen_add_arrayindexoutofboundsexception_ref(codegendata *cd, *******************************************************************************/ -void codegen_add_arraystoreexception_ref(codegendata *cd, void *branchptr) +void codegen_add_arraystoreexception_ref(codegendata *cd) { - codegen_add_exception_ref(cd, branchptr, -1, - STACKTRACE_inline_arraystoreexception); + codegen_add_exception_ref(cd, -1, STACKTRACE_inline_arraystoreexception); } @@ -412,10 +414,9 @@ void codegen_add_arraystoreexception_ref(codegendata *cd, void *branchptr) *******************************************************************************/ -void codegen_add_classcastexception_ref(codegendata *cd, void *branchptr) +void codegen_add_classcastexception_ref(codegendata *cd) { - codegen_add_exception_ref(cd, branchptr, -1, - STACKTRACE_inline_classcastexception); + codegen_add_exception_ref(cd, -1, STACKTRACE_inline_classcastexception); } @@ -425,10 +426,9 @@ void codegen_add_classcastexception_ref(codegendata *cd, void *branchptr) *******************************************************************************/ -void codegen_add_nullpointerexception_ref(codegendata *cd, void *branchptr) +void codegen_add_nullpointerexception_ref(codegendata *cd) { - codegen_add_exception_ref(cd, branchptr, -1, - STACKTRACE_inline_nullpointerexception); + codegen_add_exception_ref(cd, -1, STACKTRACE_inline_nullpointerexception); } @@ -438,10 +438,9 @@ void codegen_add_nullpointerexception_ref(codegendata *cd, void *branchptr) *******************************************************************************/ -void codegen_add_fillinstacktrace_ref(codegendata *cd, void *branchptr) +void codegen_add_fillinstacktrace_ref(codegendata *cd) { - codegen_add_exception_ref(cd, branchptr, -1, - STACKTRACE_inline_fillInStackTrace); + codegen_add_exception_ref(cd, -1, STACKTRACE_inline_fillInStackTrace); } @@ -451,13 +450,13 @@ void codegen_add_fillinstacktrace_ref(codegendata *cd, void *branchptr) *******************************************************************************/ -void codegen_addpatchref(codegendata *cd, voidptr branchptr, - functionptr patcher, voidptr ref, s4 disp) +void codegen_addpatchref(codegendata *cd, functionptr patcher, voidptr ref, + s4 disp) { patchref *pr; s4 branchpos; - branchpos = (u1 *) branchptr - cd->mcodebase; + branchpos = (u1 *) cd->mcodeptr - cd->mcodebase; pr = DNEW(patchref); @@ -476,7 +475,7 @@ void codegen_addpatchref(codegendata *cd, voidptr branchptr, the basic block code generation is completed, we check the range and maybe generate some nop's. */ - cd->lastmcodeptr = ((u1 *) branchptr) + PATCHER_CALL_SIZE; + cd->lastmcodeptr = ((u1 *) cd->mcodeptr) + PATCHER_CALL_SIZE; #endif } @@ -578,13 +577,11 @@ u1 *codegen_findmethod(u1 *pc) *******************************************************************************/ -void codegen_finish(jitdata *jd, s4 mcodelen) +void codegen_finish(jitdata *jd) { codeinfo *code; codegendata *cd; -#if 0 s4 mcodelen; -#endif #if defined(ENABLE_INTRP) s4 ncodelen; #endif @@ -605,6 +602,10 @@ void codegen_finish(jitdata *jd, s4 mcodelen) ncodelen = 0; #endif + /* calculate the code length */ + + mcodelen = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); + #if defined(USE_THREADS) && defined(NATIVE_THREADS) extralen = sizeof(threadcritnode) * cd->threadcritcount; #else @@ -618,9 +619,6 @@ void codegen_finish(jitdata *jd, s4 mcodelen) } #endif -#if 0 - mcodelen = cd->mcodeptr - cd->mcodebase; -#endif alignedmcodelen = ALIGN(mcodelen, MAX_ALIGN); #if defined(ENABLE_INTRP) diff --git a/src/vm/jit/codegen-common.h b/src/vm/jit/codegen-common.h index 17dda3bae..d36baf73d 100644 --- a/src/vm/jit/codegen-common.h +++ b/src/vm/jit/codegen-common.h @@ -29,7 +29,7 @@ Changes: Christian Ullrich Edwin Steiner - $Id: codegen-common.h 4780 2006-04-17 11:47:03Z twisti $ + $Id: codegen-common.h 4826 2006-04-24 16:06:16Z twisti $ */ @@ -160,30 +160,29 @@ void codegen_setup(jitdata *jd); void codegen_close(void); -s4 *codegen_increase(codegendata *cd, u1 *mcodeptr); +void codegen_increase(codegendata *cd); #if defined(ENABLE_INTRP) u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr); #endif -void codegen_addreference(codegendata *cd, basicblock *target, void *branchptr); +void codegen_addreference(codegendata *cd, basicblock *target); -void codegen_add_arithmeticexception_ref(codegendata *cd, void *branchptr); -void codegen_add_arrayindexoutofboundsexception_ref(codegendata *cd, - void *branchptr, s4 reg); -void codegen_add_arraystoreexception_ref(codegendata *cd, void *branchptr); -void codegen_add_classcastexception_ref(codegendata *cd, void *branchptr); -void codegen_add_nullpointerexception_ref(codegendata *cd, void *branchptr); -void codegen_add_fillinstacktrace_ref(codegendata *cd, void *branchptr); +void codegen_add_arithmeticexception_ref(codegendata *cd); +void codegen_add_arrayindexoutofboundsexception_ref(codegendata *cd, s4 reg); +void codegen_add_arraystoreexception_ref(codegendata *cd); +void codegen_add_classcastexception_ref(codegendata *cd); +void codegen_add_nullpointerexception_ref(codegendata *cd); +void codegen_add_fillinstacktrace_ref(codegendata *cd); -void codegen_addpatchref(codegendata *cd, voidptr branchptr, - functionptr patcher, voidptr ref, s4 disp); +void codegen_addpatchref(codegendata *cd, functionptr patcher, voidptr ref, + s4 disp); void codegen_insertmethod(u1 *startpc, u1 *endpc); u1 *codegen_findmethod(u1 *pc); -void codegen_finish(jitdata *jd, s4 mcodelen); +void codegen_finish(jitdata *jd); codeinfo *codegen_createnativestub(functionptr f, methodinfo *m); #if defined(ENABLE_DISASSEMBLER) diff --git a/src/vm/jit/dseg.c b/src/vm/jit/dseg.c index cfe121ef2..81741e582 100644 --- a/src/vm/jit/dseg.c +++ b/src/vm/jit/dseg.c @@ -31,7 +31,7 @@ Joseph Wenninger Edwin Steiner - $Id: dseg.c 4734 2006-04-05 09:57:55Z edwin $ + $Id: dseg.c 4826 2006-04-24 16:06:16Z twisti $ */ @@ -52,7 +52,7 @@ *******************************************************************************/ -void dseg_increase(codegendata *cd) +static void dseg_increase(codegendata *cd) { u1 *newstorage; @@ -67,37 +67,18 @@ void dseg_increase(codegendata *cd) } -s4 dseg_adds4_increase(codegendata *cd, s4 value) -{ - dseg_increase(cd); - - *((s4 *) (cd->dsegtop - cd->dseglen)) = value; - - return -(cd->dseglen); -} - - s4 dseg_adds4(codegendata *cd, s4 value) { s4 *dataptr; cd->dseglen += 4; - dataptr = (s4 *) (cd->dsegtop - cd->dseglen); if (cd->dseglen > cd->dsegsize) - return dseg_adds4_increase(cd, value); - - *dataptr = value; + dseg_increase(cd); - return -(cd->dseglen); -} - - -s4 dseg_adds8_increase(codegendata *cd, s8 value) -{ - dseg_increase(cd); + dataptr = (s4 *) (cd->dsegtop - cd->dseglen); - *((s8 *) (cd->dsegtop - cd->dseglen)) = value; + *dataptr = value; return -(cd->dseglen); } @@ -108,22 +89,13 @@ s4 dseg_adds8(codegendata *cd, s8 value) s8 *dataptr; cd->dseglen = ALIGN(cd->dseglen + 8, 8); - dataptr = (s8 *) (cd->dsegtop - cd->dseglen); if (cd->dseglen > cd->dsegsize) - return dseg_adds8_increase(cd, value); - - *dataptr = value; + dseg_increase(cd); - return -(cd->dseglen); -} - - -s4 dseg_addfloat_increase(codegendata *cd, float value) -{ - dseg_increase(cd); + dataptr = (s8 *) (cd->dsegtop - cd->dseglen); - *((float *) (cd->dsegtop - cd->dseglen)) = value; + *dataptr = value; return -(cd->dseglen); } @@ -134,22 +106,13 @@ s4 dseg_addfloat(codegendata *cd, float value) float *dataptr; cd->dseglen += 4; - dataptr = (float *) (cd->dsegtop - cd->dseglen); if (cd->dseglen > cd->dsegsize) - return dseg_addfloat_increase(cd, value); - - *dataptr = value; + dseg_increase(cd); - return -(cd->dseglen); -} - - -s4 dseg_adddouble_increase(codegendata *cd, double value) -{ - dseg_increase(cd); + dataptr = (float *) (cd->dsegtop - cd->dseglen); - *((double *) (cd->dsegtop - cd->dseglen)) = value; + *dataptr = value; return -(cd->dseglen); } @@ -160,10 +123,11 @@ s4 dseg_adddouble(codegendata *cd, double value) double *dataptr; cd->dseglen = ALIGN(cd->dseglen + 8, 8); - dataptr = (double *) (cd->dsegtop - cd->dseglen); if (cd->dseglen > cd->dsegsize) - return dseg_adddouble_increase(cd, value); + dseg_increase(cd); + + dataptr = (double *) (cd->dsegtop - cd->dseglen); *dataptr = value; @@ -221,7 +185,7 @@ void dseg_addlinenumbertablesize(codegendata *cd) *******************************************************************************/ -void dseg_addlinenumber(codegendata *cd, u2 linenumber, u1 *mcodeptr) +void dseg_addlinenumber(codegendata *cd, u2 linenumber) { linenumberref *lr; @@ -229,7 +193,7 @@ void dseg_addlinenumber(codegendata *cd, u2 linenumber, u1 *mcodeptr) lr->linenumber = linenumber; lr->tablepos = 0; - lr->targetmpc = mcodeptr - cd->mcodebase; + lr->targetmpc = (u1 *) cd->mcodeptr - cd->mcodebase; lr->next = cd->linenumberreferences; cd->linenumberreferences = lr; @@ -248,9 +212,7 @@ void dseg_addlinenumber(codegendata *cd, u2 linenumber, u1 *mcodeptr) *******************************************************************************/ -void dseg_addlinenumber_inline_start(codegendata *cd, - instruction *iptr, - u1 *mcodeptr) +void dseg_addlinenumber_inline_start(codegendata *cd, instruction *iptr) { linenumberref *lr; insinfo_inline *insinfo; @@ -260,7 +222,7 @@ void dseg_addlinenumber_inline_start(codegendata *cd, lr->linenumber = (-2); /* marks start of inlined method */ lr->tablepos = 0; - lr->targetmpc = (mpc = mcodeptr - cd->mcodebase); + lr->targetmpc = (mpc = (u1 *) cd->mcodeptr - cd->mcodebase); lr->next = cd->linenumberreferences; cd->linenumberreferences = lr; @@ -345,13 +307,13 @@ void dseg_createlinenumbertable(codegendata *cd) *******************************************************************************/ #if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(ENABLE_INTRP) -void dseg_adddata(codegendata *cd, u1 *mcodeptr) +void dseg_adddata(codegendata *cd) { dataref *dr; dr = DNEW(dataref); - dr->datapos = mcodeptr - cd->mcodebase; + dr->datapos = (u1 *) cd->mcodeptr - cd->mcodebase; dr->next = cd->datareferences; cd->datareferences = dr; diff --git a/src/vm/jit/dseg.h b/src/vm/jit/dseg.h index b478257c1..3781ab6a8 100644 --- a/src/vm/jit/dseg.h +++ b/src/vm/jit/dseg.h @@ -30,7 +30,7 @@ Changes: Christian Thalinger Joseph Wenninger - $Id: dseg.h 4699 2006-03-28 14:52:32Z twisti $ + $Id: dseg.h 4826 2006-04-24 16:06:16Z twisti $ */ @@ -122,31 +122,22 @@ struct linenumberref { /* function prototypes ********************************************************/ -void dseg_increase(codegendata *cd); - -s4 dseg_adds4_increase(codegendata *cd, s4 value); s4 dseg_adds4(codegendata *cd, s4 value); - -s4 dseg_adds8_increase(codegendata *cd, s8 value); s4 dseg_adds8(codegendata *cd, s8 value); - -s4 dseg_addfloat_increase(codegendata *cd, float value); s4 dseg_addfloat(codegendata *cd, float value); - -s4 dseg_adddouble_increase(codegendata *cd, double value); s4 dseg_adddouble(codegendata *cd, double value); void dseg_addtarget(codegendata *cd, basicblock *target); void dseg_addlinenumbertablesize(codegendata *cd); -void dseg_addlinenumber(codegendata *cd, u2 linenumber, u1 *ptr); -void dseg_addlinenumber_inline_start(codegendata *cd, instruction *iptr, u1 *ptr); +void dseg_addlinenumber(codegendata *cd, u2 linenumber); +void dseg_addlinenumber_inline_start(codegendata *cd, instruction *iptr); void dseg_addlinenumber_inline_end(codegendata *cd, instruction *iptr); void dseg_createlinenumbertable(codegendata *cd); #if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(ENABLE_INTRP) -void dseg_adddata(codegendata *cd, u1 *ptr); +void dseg_adddata(codegendata *cd); void dseg_resolve_datareferences(jitdata *jd); #endif diff --git a/src/vm/jit/i386/codegen.c b/src/vm/jit/i386/codegen.c index 4462610e0..ba26ec30c 100644 --- a/src/vm/jit/i386/codegen.c +++ b/src/vm/jit/i386/codegen.c @@ -31,7 +31,7 @@ Christian Ullrich Edwin Steiner - $Id: codegen.c 4760 2006-04-12 20:06:23Z edwin $ + $Id: codegen.c 4826 2006-04-24 16:06:16Z twisti $ */ @@ -350,7 +350,7 @@ bool codegen(jitdata *jd) M_ALD(REG_ITMP1, REG_SP, stackframesize * 4 + 4); M_TEST(REG_ITMP1); M_BEQ(0); - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); + codegen_add_nullpointerexception_ref(cd); M_AST(REG_ITMP1, REG_SP, s1 * 4); M_AST(REG_ITMP1, REG_SP, 0 * 4); M_MOV_IMM(BUILTIN_monitorenter, REG_ITMP1); @@ -628,7 +628,7 @@ bool codegen(jitdata *jd) } } #endif - dseg_addlinenumber_inline_start(cd, iptr, cd->mcodeptr); + dseg_addlinenumber_inline_start(cd, iptr); } break; @@ -637,7 +637,7 @@ bool codegen(jitdata *jd) insinfo_inline *insinfo = (insinfo_inline *) iptr->target; dseg_addlinenumber_inline_end(cd, iptr); - dseg_addlinenumber(cd, iptr->line, cd->mcodeptr); + dseg_addlinenumber(cd, iptr->line); #if defined(USE_THREADS) if (insinfo->synchronize) { @@ -651,7 +651,7 @@ bool codegen(jitdata *jd) else { var = &(rd->locals[insinfo->synclocal][TYPE_ADR]); if (var->flags & INMEMORY) { - i386_mov_membase_reg(cd, REG_SP, var->regoff * 4, REG_ITMP1); + M_ALD(REG_ITMP1, REG_SP, var->regoff * 4); M_AST(REG_ITMP1, REG_SP, 0 * 4); } else { @@ -679,7 +679,7 @@ bool codegen(jitdata *jd) else M_TEST(src->regoff); M_BEQ(0); - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); + codegen_add_nullpointerexception_ref(cd); break; /* constant operations ************************************************/ @@ -750,7 +750,7 @@ bool codegen(jitdata *jd) } else { disp = dseg_addfloat(cd, iptr->val.f); i386_mov_imm_reg(cd, 0, REG_ITMP1); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); i386_flds_membase(cd, REG_ITMP1, disp); fpu_st_offset++; } @@ -786,7 +786,7 @@ bool codegen(jitdata *jd) } else { disp = dseg_adddouble(cd, iptr->val.d); i386_mov_imm_reg(cd, 0, REG_ITMP1); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); i386_fldl_membase(cd, REG_ITMP1, disp); fpu_st_offset++; } @@ -802,8 +802,7 @@ bool codegen(jitdata *jd) d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1); if ((iptr->target != NULL) && (iptr->val.a == NULL)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_aconst, + codegen_addpatchref(cd, PATCHER_aconst, (unresolved_class *) iptr->target, 0); if (opt_showdisassemble) { @@ -1769,7 +1768,7 @@ bool codegen(jitdata *jd) M_OR_MEMBASE(REG_SP, src->regoff * 4 + 4, REG_ITMP2); M_TEST(REG_ITMP2); M_BEQ(0); - codegen_add_arithmeticexception_ref(cd, cd->mcodeptr); + codegen_add_arithmeticexception_ref(cd); bte = iptr->val.a; md = bte->md; @@ -2522,7 +2521,7 @@ bool codegen(jitdata *jd) } else { disp = dseg_adds4(cd, 0); i386_mov_imm_reg(cd, 0, REG_ITMP1); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); i386_mov_reg_membase(cd, src->regoff, REG_ITMP1, disp); i386_fildl_membase(cd, REG_ITMP1, disp); fpu_st_offset++; @@ -2555,7 +2554,7 @@ bool codegen(jitdata *jd) d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_NULL); i386_mov_imm_reg(cd, 0, REG_ITMP1); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); /* Round to zero, 53-bit mode, exception masked */ disp = dseg_adds4(cd, 0x0e7f); @@ -2616,7 +2615,7 @@ bool codegen(jitdata *jd) d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_NULL); i386_mov_imm_reg(cd, 0, REG_ITMP1); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); /* Round to zero, 53-bit mode, exception masked */ disp = dseg_adds4(cd, 0x0e7f); @@ -2676,7 +2675,7 @@ bool codegen(jitdata *jd) d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_NULL); i386_mov_imm_reg(cd, 0, REG_ITMP1); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); /* Round to zero, 53-bit mode, exception masked */ disp = dseg_adds4(cd, 0x0e7f); @@ -2734,7 +2733,7 @@ bool codegen(jitdata *jd) d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_NULL); i386_mov_imm_reg(cd, 0, REG_ITMP1); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); /* Round to zero, 53-bit mode, exception masked */ disp = dseg_adds4(cd, 0x0e7f); @@ -3126,7 +3125,7 @@ bool codegen(jitdata *jd) M_CALL(REG_ITMP1); M_TEST(REG_RESULT); M_BEQ(0); - codegen_add_arraystoreexception_ref(cd, cd->mcodeptr); + codegen_add_arraystoreexception_ref(cd); var_to_reg_int(s1, src->prev->prev, REG_ITMP1); var_to_reg_int(s2, src->prev, REG_ITMP2); @@ -3221,8 +3220,7 @@ bool codegen(jitdata *jd) /* EAX: S|YES ECX: S|YES EDX: S|YES OUTPUT: EAX*/ if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr), 0); if (opt_showdisassemble) { @@ -3235,8 +3233,7 @@ bool codegen(jitdata *jd) fieldinfo *fi = INSTRUCTION_RESOLVED_FIELDINFO(iptr); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_clinit, fi->class, 0); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -3289,8 +3286,7 @@ bool codegen(jitdata *jd) /* EAX: S|YES ECX: S|YES EDX: S|YES OUTPUT: REG_NULL*/ if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr), 0); if (opt_showdisassemble) { @@ -3303,8 +3299,7 @@ bool codegen(jitdata *jd) fieldinfo *fi = INSTRUCTION_RESOLVED_FIELDINFO(iptr); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_clinit, fi->class, 0); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -3357,8 +3352,7 @@ bool codegen(jitdata *jd) /* EAX: S|YES ECX: S|YES EDX: S|YES OUTPUT: REG_NULL*/ if (INSTRUCTION_IS_UNRESOLVED(iptr + 1)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr + 1), 0); if (opt_showdisassemble) { @@ -3371,8 +3365,7 @@ bool codegen(jitdata *jd) fieldinfo *fi = INSTRUCTION_RESOLVED_FIELDINFO(iptr + 1); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_clinit, fi->class, 0); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -3406,8 +3399,7 @@ bool codegen(jitdata *jd) gen_nullptr_check(s1); if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_getfield, + codegen_addpatchref(cd, PATCHER_getfield, INSTRUCTION_UNRESOLVED_FIELD(iptr), 0); if (opt_showdisassemble) { @@ -3466,8 +3458,7 @@ bool codegen(jitdata *jd) var_to_reg_flt(s2, src, REG_FTMP2); if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_putfield, + codegen_addpatchref(cd, PATCHER_putfield, INSTRUCTION_UNRESOLVED_FIELD(iptr), 0); if (opt_showdisassemble) { @@ -3510,8 +3501,7 @@ bool codegen(jitdata *jd) gen_nullptr_check(s1); if (INSTRUCTION_IS_UNRESOLVED(iptr + 1)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_putfieldconst, + codegen_addpatchref(cd, PATCHER_putfieldconst, INSTRUCTION_UNRESOLVED_FIELD(iptr + 1), 0); if (opt_showdisassemble) { @@ -3549,8 +3539,7 @@ bool codegen(jitdata *jd) #ifdef ENABLE_VERIFIER if (iptr->val.a) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_athrow_areturn, + codegen_addpatchref(cd, PATCHER_athrow_areturn, (unresolved_class *) iptr->val.a, 0); if (opt_showdisassemble) { @@ -3577,7 +3566,7 @@ bool codegen(jitdata *jd) /* EAX: YES ECX: YES EDX: YES OUTPUT: REG_NULL*/ M_JMP_IMM(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); ALIGNCODENOP; break; @@ -3587,7 +3576,7 @@ bool codegen(jitdata *jd) /* EAX: YES ECX: YES EDX: YES OUTPUT: REG_NULL*/ M_CALL_IMM(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_RET: /* ... ==> ... */ @@ -3612,7 +3601,7 @@ bool codegen(jitdata *jd) i386_test_reg_reg(cd, src->regoff, src->regoff); } i386_jcc(cd, I386_CC_E, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFNONNULL: /* ..., value ==> ... */ @@ -3627,7 +3616,7 @@ bool codegen(jitdata *jd) i386_test_reg_reg(cd, src->regoff, src->regoff); } i386_jcc(cd, I386_CC_NE, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFEQ: /* ..., value ==> ... */ @@ -3642,7 +3631,7 @@ bool codegen(jitdata *jd) i386_alu_imm_reg(cd, ALU_CMP, iptr->val.i, src->regoff); } i386_jcc(cd, I386_CC_E, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFLT: /* ..., value ==> ... */ @@ -3657,7 +3646,7 @@ bool codegen(jitdata *jd) i386_alu_imm_reg(cd, ALU_CMP, iptr->val.i, src->regoff); } i386_jcc(cd, I386_CC_L, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFLE: /* ..., value ==> ... */ @@ -3672,7 +3661,7 @@ bool codegen(jitdata *jd) i386_alu_imm_reg(cd, ALU_CMP, iptr->val.i, src->regoff); } i386_jcc(cd, I386_CC_LE, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFNE: /* ..., value ==> ... */ @@ -3687,7 +3676,7 @@ bool codegen(jitdata *jd) i386_alu_imm_reg(cd, ALU_CMP, iptr->val.i, src->regoff); } i386_jcc(cd, I386_CC_NE, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFGT: /* ..., value ==> ... */ @@ -3702,7 +3691,7 @@ bool codegen(jitdata *jd) i386_alu_imm_reg(cd, ALU_CMP, iptr->val.i, src->regoff); } i386_jcc(cd, I386_CC_G, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFGE: /* ..., value ==> ... */ @@ -3717,7 +3706,7 @@ bool codegen(jitdata *jd) i386_alu_imm_reg(cd, ALU_CMP, iptr->val.i, src->regoff); } i386_jcc(cd, I386_CC_GE, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LEQ: /* ..., value ==> ... */ @@ -3740,7 +3729,7 @@ bool codegen(jitdata *jd) } i386_test_reg_reg(cd, REG_ITMP1, REG_ITMP1); i386_jcc(cd, I386_CC_E, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LLT: /* ..., value ==> ... */ @@ -3751,7 +3740,7 @@ bool codegen(jitdata *jd) if (src->flags & INMEMORY) { i386_alu_imm_membase(cd, ALU_CMP, iptr->val.l >> 32, REG_SP, src->regoff * 4 + 4); i386_jcc(cd, I386_CC_L, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); disp = 3 + 6; CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4); @@ -3761,7 +3750,7 @@ bool codegen(jitdata *jd) i386_alu_imm_membase(cd, ALU_CMP, iptr->val.l, REG_SP, src->regoff * 4); i386_jcc(cd, I386_CC_B, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); } break; @@ -3773,7 +3762,7 @@ bool codegen(jitdata *jd) if (src->flags & INMEMORY) { i386_alu_imm_membase(cd, ALU_CMP, iptr->val.l >> 32, REG_SP, src->regoff * 4 + 4); i386_jcc(cd, I386_CC_L, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); disp = 3 + 6; CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4); @@ -3783,7 +3772,7 @@ bool codegen(jitdata *jd) i386_alu_imm_membase(cd, ALU_CMP, iptr->val.l, REG_SP, src->regoff * 4); i386_jcc(cd, I386_CC_BE, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); } break; @@ -3807,7 +3796,7 @@ bool codegen(jitdata *jd) } i386_test_reg_reg(cd, REG_ITMP1, REG_ITMP1); i386_jcc(cd, I386_CC_NE, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LGT: /* ..., value ==> ... */ @@ -3818,7 +3807,7 @@ bool codegen(jitdata *jd) if (src->flags & INMEMORY) { i386_alu_imm_membase(cd, ALU_CMP, iptr->val.l >> 32, REG_SP, src->regoff * 4 + 4); i386_jcc(cd, I386_CC_G, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); disp = 3 + 6; CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4); @@ -3828,7 +3817,7 @@ bool codegen(jitdata *jd) i386_alu_imm_membase(cd, ALU_CMP, iptr->val.l, REG_SP, src->regoff * 4); i386_jcc(cd, I386_CC_A, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); } break; @@ -3840,7 +3829,7 @@ bool codegen(jitdata *jd) if (src->flags & INMEMORY) { i386_alu_imm_membase(cd, ALU_CMP, iptr->val.l >> 32, REG_SP, src->regoff * 4 + 4); i386_jcc(cd, I386_CC_G, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); disp = 3 + 6; CALCOFFSETBYTES(disp, REG_SP, src->regoff * 4); @@ -3850,7 +3839,7 @@ bool codegen(jitdata *jd) i386_alu_imm_membase(cd, ALU_CMP, iptr->val.l, REG_SP, src->regoff * 4); i386_jcc(cd, I386_CC_AE, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); } break; @@ -3873,7 +3862,7 @@ bool codegen(jitdata *jd) i386_alu_reg_reg(cd, ALU_CMP, src->regoff, src->prev->regoff); } i386_jcc(cd, I386_CC_E, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LCMPEQ: /* ..., value, value ==> ... */ @@ -3890,7 +3879,7 @@ bool codegen(jitdata *jd) i386_test_reg_reg(cd, REG_ITMP1, REG_ITMP1); } i386_jcc(cd, I386_CC_E, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPNE: /* ..., value, value ==> ... */ @@ -3912,7 +3901,7 @@ bool codegen(jitdata *jd) i386_alu_reg_reg(cd, ALU_CMP, src->regoff, src->prev->regoff); } i386_jcc(cd, I386_CC_NE, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LCMPNE: /* ..., value, value ==> ... */ @@ -3929,7 +3918,7 @@ bool codegen(jitdata *jd) i386_test_reg_reg(cd, REG_ITMP1, REG_ITMP1); } i386_jcc(cd, I386_CC_NE, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPLT: /* ..., value, value ==> ... */ @@ -3951,7 +3940,7 @@ bool codegen(jitdata *jd) i386_alu_reg_reg(cd, ALU_CMP, src->regoff, src->prev->regoff); } i386_jcc(cd, I386_CC_L, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LCMPLT: /* ..., value, value ==> ... */ @@ -3963,7 +3952,7 @@ bool codegen(jitdata *jd) i386_mov_membase_reg(cd, REG_SP, src->prev->regoff * 4 + 4, REG_ITMP1); i386_alu_membase_reg(cd, ALU_CMP, REG_SP, src->regoff * 4 + 4, REG_ITMP1); M_BLT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); disp = 3 + 3 + 6; CALCOFFSETBYTES(disp, REG_SP, src->prev->regoff * 4); @@ -3974,7 +3963,7 @@ bool codegen(jitdata *jd) i386_mov_membase_reg(cd, REG_SP, src->prev->regoff * 4, REG_ITMP1); i386_alu_membase_reg(cd, ALU_CMP, REG_SP, src->regoff * 4, REG_ITMP1); i386_jcc(cd, I386_CC_B, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); } break; @@ -3997,7 +3986,7 @@ bool codegen(jitdata *jd) i386_alu_reg_reg(cd, ALU_CMP, src->regoff, src->prev->regoff); } M_BGT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LCMPGT: /* ..., value, value ==> ... */ @@ -4009,7 +3998,7 @@ bool codegen(jitdata *jd) i386_mov_membase_reg(cd, REG_SP, src->prev->regoff * 4 + 4, REG_ITMP1); i386_alu_membase_reg(cd, ALU_CMP, REG_SP, src->regoff * 4 + 4, REG_ITMP1); M_BGT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); disp = 3 + 3 + 6; CALCOFFSETBYTES(disp, REG_SP, src->prev->regoff * 4); @@ -4020,7 +4009,7 @@ bool codegen(jitdata *jd) i386_mov_membase_reg(cd, REG_SP, src->prev->regoff * 4, REG_ITMP1); i386_alu_membase_reg(cd, ALU_CMP, REG_SP, src->regoff * 4, REG_ITMP1); i386_jcc(cd, I386_CC_A, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); } break; @@ -4043,7 +4032,7 @@ bool codegen(jitdata *jd) i386_alu_reg_reg(cd, ALU_CMP, src->regoff, src->prev->regoff); } M_BLE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LCMPLE: /* ..., value, value ==> ... */ @@ -4055,7 +4044,7 @@ bool codegen(jitdata *jd) i386_mov_membase_reg(cd, REG_SP, src->prev->regoff * 4 + 4, REG_ITMP1); i386_alu_membase_reg(cd, ALU_CMP, REG_SP, src->regoff * 4 + 4, REG_ITMP1); M_BLT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); disp = 3 + 3 + 6; CALCOFFSETBYTES(disp, REG_SP, src->prev->regoff * 4); @@ -4066,7 +4055,7 @@ bool codegen(jitdata *jd) i386_mov_membase_reg(cd, REG_SP, src->prev->regoff * 4, REG_ITMP1); i386_alu_membase_reg(cd, ALU_CMP, REG_SP, src->regoff * 4, REG_ITMP1); M_BBE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); } break; @@ -4089,7 +4078,7 @@ bool codegen(jitdata *jd) i386_alu_reg_reg(cd, ALU_CMP, src->regoff, src->prev->regoff); } M_BGE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LCMPGE: /* ..., value, value ==> ... */ @@ -4101,7 +4090,7 @@ bool codegen(jitdata *jd) i386_mov_membase_reg(cd, REG_SP, src->prev->regoff * 4 + 4, REG_ITMP1); i386_alu_membase_reg(cd, ALU_CMP, REG_SP, src->regoff * 4 + 4, REG_ITMP1); M_BGT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); disp = 3 + 3 + 6; CALCOFFSETBYTES(disp, REG_SP, src->prev->regoff * 4); @@ -4112,7 +4101,7 @@ bool codegen(jitdata *jd) i386_mov_membase_reg(cd, REG_SP, src->prev->regoff * 4, REG_ITMP1); i386_alu_membase_reg(cd, ALU_CMP, REG_SP, src->regoff * 4, REG_ITMP1); M_BAE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); } break; @@ -4209,8 +4198,7 @@ bool codegen(jitdata *jd) #ifdef ENABLE_VERIFIER if (iptr->val.a) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_athrow_areturn, + codegen_addpatchref(cd, PATCHER_athrow_areturn, (unresolved_class *) iptr->val.a, 0); if (opt_showdisassemble) { @@ -4369,7 +4357,7 @@ nowperformreturn: i386_alu_imm_reg(cd, ALU_CMP, i - 1, REG_ITMP1); i386_jcc(cd, I386_CC_A, 0); - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); /* build jump table top down and use address of lowest entry */ @@ -4383,7 +4371,7 @@ nowperformreturn: /* length of dataseg after last dseg_addtarget is used by load */ i386_mov_imm_reg(cd, 0, REG_ITMP2); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); i386_mov_memindex_reg(cd, -(cd->dseglen), REG_ITMP2, REG_ITMP1, 2, REG_ITMP1); i386_jmp_reg(cd, REG_ITMP1); } @@ -4412,13 +4400,13 @@ nowperformreturn: val = s4ptr[0]; i386_alu_imm_reg(cd, ALU_CMP, val, s1); i386_jcc(cd, I386_CC_E, 0); - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); } i386_jmp_imm(cd, 0); tptr = (void **) iptr->target; - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); } break; @@ -4519,7 +4507,7 @@ gen_method: if (iptr->op1 == true) { M_TEST(REG_RESULT); M_BEQ(0); - codegen_add_fillinstacktrace_ref(cd, cd->mcodeptr); + codegen_add_fillinstacktrace_ref(cd); } break; @@ -4536,8 +4524,8 @@ gen_method: if (lm == NULL) { unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_invokestatic_special, um, 0); + codegen_addpatchref(cd, PATCHER_invokestatic_special, + um, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -4562,8 +4550,7 @@ gen_method: if (lm == NULL) { unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_invokevirtual, um, 0); + codegen_addpatchref(cd, PATCHER_invokevirtual, um, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -4590,8 +4577,7 @@ gen_method: if (lm == NULL) { unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_invokeinterface, um, 0); + codegen_addpatchref(cd, PATCHER_invokeinterface, um, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -4744,8 +4730,7 @@ gen_method: i386_test_reg_reg(cd, s1, s1); i386_jcc(cd, I386_CC_Z, 5 + (opt_showdisassemble ? 5 : 0) + 6 + 6 + s2 + 5 + s3); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_checkcast_instanceof_flags, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags, (constant_classref *) iptr->target, 0); if (opt_showdisassemble) { @@ -4770,7 +4755,7 @@ gen_method: REG_ITMP2); if (!super) { - codegen_addpatchref(cd, cd->mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_interface, (constant_classref *) iptr->target, 0); @@ -4785,14 +4770,14 @@ gen_method: i386_alu_imm32_reg(cd, ALU_SUB, superindex, REG_ITMP3); i386_test_reg_reg(cd, REG_ITMP3, REG_ITMP3); i386_jcc(cd, I386_CC_LE, 0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); i386_mov_membase32_reg(cd, REG_ITMP2, OFFSET(vftbl_t, interfacetable[0]) - superindex * sizeof(methodptr*), REG_ITMP3); i386_test_reg_reg(cd, REG_ITMP3, REG_ITMP3); i386_jcc(cd, I386_CC_E, 0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); if (!super) i386_jmp_imm(cd, s3); @@ -4811,9 +4796,9 @@ gen_method: REG_ITMP2); if (!super) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_checkcast_class, - (constant_classref *) iptr->target, 0); + codegen_addpatchref(cd, PATCHER_checkcast_class, + (constant_classref *) iptr->target, + 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -4852,7 +4837,7 @@ gen_method: i386_alu_reg_reg(cd, ALU_CMP, REG_ITMP3, REG_ITMP2); i386_jcc(cd, I386_CC_A, 0); /* (u) REG_ITMP2 > (u) REG_ITMP3 -> jump */ - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); } d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP3); @@ -4863,8 +4848,7 @@ gen_method: M_AST(s1, REG_SP, 0 * 4); if (iptr->val.a == NULL) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_builtin_arraycheckcast, + codegen_addpatchref(cd, PATCHER_builtin_arraycheckcast, iptr->target, 0); if (opt_showdisassemble) { @@ -4877,7 +4861,7 @@ gen_method: M_CALL(REG_ITMP3); M_TEST(REG_RESULT); M_BEQ(0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); var_to_reg_int(s1, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, s1); @@ -4972,8 +4956,7 @@ gen_method: i386_test_reg_reg(cd, s1, s1); i386_jcc(cd, I386_CC_Z, 5 + (opt_showdisassemble ? 5 : 0) + 6 + 6 + s2 + 5 + s3); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_checkcast_instanceof_flags, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags, (constant_classref *) iptr->target, 0); if (opt_showdisassemble) { @@ -4998,7 +4981,7 @@ gen_method: REG_ITMP1); if (!super) { - codegen_addpatchref(cd, cd->mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_interface, (constant_classref *) iptr->target, 0); @@ -5044,8 +5027,7 @@ gen_method: REG_ITMP1); if (!super) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_instanceof_class, + codegen_addpatchref(cd, PATCHER_instanceof_class, (constant_classref *) iptr->target, 0); if (opt_showdisassemble) { @@ -5107,8 +5089,7 @@ gen_method: /* is a patcher function set? */ if (iptr->val.a == NULL) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_builtin_multianewarray, + codegen_addpatchref(cd, PATCHER_builtin_multianewarray, (constant_classref *) iptr->target, 0); if (opt_showdisassemble) { @@ -5142,7 +5123,7 @@ gen_method: M_TEST(REG_RESULT); M_BEQ(0); - codegen_add_fillinstacktrace_ref(cd, cd->mcodeptr); + codegen_add_fillinstacktrace_ref(cd); s1 = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT); M_INTMOVE(REG_RESULT, s1); @@ -5251,7 +5232,7 @@ gen_method: /* calcuate exception address */ M_MOV_IMM(0, REG_ITMP2_XPC); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); M_AADD_IMM32(eref->branchpos - 6, REG_ITMP2_XPC); /* move function to call into REG_ITMP3 */ @@ -5271,7 +5252,7 @@ gen_method: M_AST(REG_ITMP1, REG_SP, 4 * 4); /* for AIOOBE */ M_AST_IMM(0, REG_SP, 0 * 4); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); M_MOV(REG_SP, REG_ITMP1); M_AADD_IMM(5 * 4, REG_ITMP1); M_AST(REG_ITMP1, REG_SP, 1 * 4); @@ -5323,7 +5304,7 @@ gen_method: off = dseg_addaddress(cd, NULL); /* vftbl */ M_MOV_IMM(0, REG_ITMP3); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); M_AADD_IMM(off, REG_ITMP3); M_PUSH(REG_ITMP3); #else @@ -5374,7 +5355,7 @@ gen_method: } } - codegen_finish(jd, (s4) (cd->mcodeptr - cd->mcodebase)); + codegen_finish(jd); /* everything's ok */ @@ -5582,7 +5563,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) #if !defined(WITH_STATIC_CLASSPATH) if (f == NULL) { - codegen_addpatchref(cd, cd->mcodeptr, PATCHER_resolve_native, m, 0); + codegen_addpatchref(cd, PATCHER_resolve_native, m, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -5611,7 +5592,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) M_AST(REG_ITMP1, REG_SP, 0 * 4); M_IST_IMM(0, REG_SP, 1 * 4); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); M_MOV(REG_SP, REG_ITMP2); M_AADD_IMM(stackframesize * 4 + SIZEOF_VOID_P, REG_ITMP2); @@ -5802,7 +5783,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) disp = dseg_addaddress(cd, NULL); /* vftbl */ M_MOV_IMM(0, REG_ITMP3); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); M_AADD_IMM(disp, REG_ITMP3); M_PUSH(REG_ITMP3); #else @@ -5821,7 +5802,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) } } - codegen_finish(jd, (s4) (cd->mcodeptr - cd->mcodebase)); + codegen_finish(jd); return jd->code->entrypoint; } diff --git a/src/vm/jit/i386/codegen.h b/src/vm/jit/i386/codegen.h index faa2f8764..1bbaf96fb 100644 --- a/src/vm/jit/i386/codegen.h +++ b/src/vm/jit/i386/codegen.h @@ -29,7 +29,7 @@ Changes: - $Id: codegen.h 4702 2006-03-28 15:41:58Z twisti $ + $Id: codegen.h 4826 2006-04-24 16:06:16Z twisti $ */ @@ -79,14 +79,14 @@ if (checknull) { \ M_TEST(objreg); \ M_BEQ(0); \ - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); \ + codegen_add_nullpointerexception_ref(cd); \ } #define gen_bound_check \ if (checkbounds) { \ M_CMP_MEMBASE(s1, OFFSET(java_arrayheader, size), s2); \ M_BAE(0); \ - codegen_add_arrayindexoutofboundsexception_ref(cd, cd->mcodeptr, s2); \ + codegen_add_arrayindexoutofboundsexception_ref(cd, s2); \ } #define gen_div_check(v) \ @@ -96,15 +96,17 @@ else \ M_TEST(src->regoff); \ M_BEQ(0); \ - codegen_add_arithmeticexception_ref(cd, cd->mcodeptr); \ + codegen_add_arithmeticexception_ref(cd); \ } /* MCODECHECK(icnt) */ #define MCODECHECK(icnt) \ - if ((cd->mcodeptr + (icnt)) > (u1 *) cd->mcodeend) \ - cd->mcodeptr = (u1 *) codegen_increase(cd, cd->mcodeptr) + do { \ + if ((cd->mcodeptr + (icnt)) > (u1 *) cd->mcodeend) \ + codegen_increase(cd); \ + } while (0) /* M_INTMOVE: diff --git a/src/vm/jit/intrp/codegen.c b/src/vm/jit/intrp/codegen.c index 85f4c76d7..497df92d2 100644 --- a/src/vm/jit/intrp/codegen.c +++ b/src/vm/jit/intrp/codegen.c @@ -29,7 +29,7 @@ Changes: Edwin Steiner - $Id: codegen.c 4782 2006-04-17 15:49:06Z edwin $ + $Id: codegen.c 4826 2006-04-24 16:06:16Z twisti $ */ @@ -72,7 +72,7 @@ #define gen_branch(_inst) { \ gen_##_inst(cd, 0); \ - codegen_addreference(cd, (basicblock *) (iptr->target), cd->mcodeptr); \ + codegen_addreference(cd, (basicblock *) (iptr->target)); \ } #define index2offset(_i) (-(_i) * SIZEOF_VOID_P) @@ -368,7 +368,7 @@ bool intrp_codegen(jitdata *jd) for (bptr = m->basicblocks; bptr != NULL; bptr = bptr->next) { - bptr->mpc = (s4) ((u1*)cd->mcodeptr - cd->mcodebase); + bptr->mpc = (s4) ((u1 *) cd->mcodeptr - cd->mcodebase); if (bptr->flags >= BBREACHED) { @@ -381,7 +381,7 @@ bool intrp_codegen(jitdata *jd) for (iptr = bptr->iinstr; len > 0; src = iptr->dst, len--, iptr++) { if (iptr->line != currentline) { - dseg_addlinenumber(cd, iptr->line, cd->mcodeptr); + dseg_addlinenumber(cd, iptr->line); currentline = iptr->line; } @@ -1612,8 +1612,11 @@ bool intrp_codegen(jitdata *jd) /* actually -3 cells offset */ - dseg_adddata(cd, ((u1*)cd->mcodeptr - 2 * sizeof(Inst))); - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + cd->mcodeptr = (u1 *) cd->mcodeptr - 2 * sizeof(Inst); + dseg_adddata(cd); + cd->mcodeptr = (u1 *) cd->mcodeptr + 2 * sizeof(Inst); + + codegen_addreference(cd, (basicblock *) tptr[0]); /* build jump table top down and use address of lowest entry */ @@ -1645,8 +1648,14 @@ bool intrp_codegen(jitdata *jd) /* arguments: count, datasegment address, table offset in */ /* datasegment, default target */ gen_LOOKUPSWITCH(cd, i, NULL, 0, NULL); - dseg_adddata(cd, ((u1*)cd->mcodeptr - 2*sizeof(Inst))); /* actually -3 cells offset*/ - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + + /* actually -3 cells offset */ + + cd->mcodeptr = (u1 *) cd->mcodeptr - 2 * sizeof(Inst); + dseg_adddata(cd); + cd->mcodeptr = (u1 *) cd->mcodeptr + 2 * sizeof(Inst); + + codegen_addreference(cd, (basicblock *) tptr[0]); /* build jump table top down and use address of lowest entry */ @@ -1800,7 +1809,7 @@ bool intrp_codegen(jitdata *jd) dseg_createlinenumbertable(cd); - codegen_finish(jd, (s4) ((u1*)cd->mcodeptr - cd->mcodebase)); + codegen_finish(jd); #ifdef VM_PROFILING vm_block_insert(jd->code->mcode + jd->code->mcodelength); @@ -2034,7 +2043,7 @@ u1 *intrp_createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) gen_BBEND; - codegen_finish(jd, (s4) ((u1*)cd->mcodeptr - cd->mcodebase)); + codegen_finish(jd); #ifdef VM_PROFILING vm_block_insert(jd->code->mcode + jd->code->mcodelength); @@ -2258,7 +2267,7 @@ u1 *createcalljavafunction(methodinfo *m) gen_BBEND; - codegen_finish(jd, (s4) ((u1*)cd->mcodeptr - cd->mcodebase)); + codegen_finish(jd); #ifdef VM_PROFILING vm_block_insert(jd->code->mcode + jd->code->mcodelength); diff --git a/src/vm/jit/intrp/codegen.h b/src/vm/jit/intrp/codegen.h index a0b55c472..5e68085f9 100644 --- a/src/vm/jit/intrp/codegen.h +++ b/src/vm/jit/intrp/codegen.h @@ -29,7 +29,7 @@ Changes: Christian Thalinger - $Id: codegen.h 4760 2006-04-12 20:06:23Z edwin $ + $Id: codegen.h 4826 2006-04-24 16:06:16Z twisti $ */ @@ -51,9 +51,10 @@ /* MCODECHECK(icnt) */ #define MCODECHECK(icnt) \ - if ((cd->mcodeptr + (icnt)) > (u1 *) cd->mcodeend) { \ - cd->mcodeptr = (u1 *) codegen_increase(cd, cd->mcodeptr); \ - } + do { \ + if ((cd->mcodeptr + (icnt)) > (u1 *) cd->mcodeend) \ + codegen_increase(cd); \ + } while (0) /* gen_resolvebranch *********************************************************** diff --git a/src/vm/jit/mips/codegen.c b/src/vm/jit/mips/codegen.c index ee940c584..5ff1ebf57 100644 --- a/src/vm/jit/mips/codegen.c +++ b/src/vm/jit/mips/codegen.c @@ -35,7 +35,7 @@ This module generates MIPS machine code for a sequence of intermediate code commands (ICMDs). - $Id: codegen.c 4783 2006-04-18 13:36:15Z twisti $ + $Id: codegen.c 4826 2006-04-24 16:06:16Z twisti $ */ @@ -271,7 +271,7 @@ bool codegen(jitdata *jd) } else { M_BEQZ(rd->argintregs[0], 0); - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); + codegen_add_nullpointerexception_ref(cd); p = dseg_addaddress(cd, BUILTIN_monitorenter); M_ALD(REG_ITMP3, REG_PV, p); M_JSR(REG_RA, REG_ITMP3); @@ -491,7 +491,7 @@ bool codegen(jitdata *jd) for (iptr = bptr->iinstr; len > 0; src = iptr->dst, len--, iptr++) { if (iptr->line != currentline) { - dseg_addlinenumber(cd, iptr->line, (u1 *) cd->mcodeptr); + dseg_addlinenumber(cd, iptr->line); currentline = iptr->line; } @@ -506,7 +506,7 @@ bool codegen(jitdata *jd) s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); M_BEQZ(s1, 0); - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); + codegen_add_nullpointerexception_ref(cd); M_NOP; break; @@ -554,8 +554,7 @@ bool codegen(jitdata *jd) if ((iptr->target != NULL) && (iptr->val.a == NULL)) { disp = dseg_addaddress(cd, iptr->val.a); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_aconst, + codegen_addpatchref(cd, PATCHER_aconst, (unresolved_class *) iptr->target, disp); if (opt_showdisassemble) { @@ -1868,7 +1867,7 @@ bool codegen(jitdata *jd) M_NOP; M_BEQZ(REG_RESULT, 0); - codegen_add_arraystoreexception_ref(cd, cd->mcodeptr); + codegen_add_arraystoreexception_ref(cd); M_NOP; s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1); @@ -1952,8 +1951,7 @@ bool codegen(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { disp = dseg_addaddress(cd, NULL); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr), disp); if (opt_showdisassemble) { @@ -1966,8 +1964,7 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, &(fi->value)); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_clinit, fi->class, 0); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); if (opt_showdisassemble) { M_NOP; M_NOP; @@ -2011,8 +2008,7 @@ bool codegen(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { disp = dseg_addaddress(cd, NULL); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr), disp); if (opt_showdisassemble) { @@ -2025,8 +2021,7 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, &(fi->value)); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_clinit, fi->class, 0); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); if (opt_showdisassemble) { M_NOP; M_NOP; @@ -2067,8 +2062,7 @@ bool codegen(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr + 1)) { disp = dseg_addaddress(cd, NULL); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr + 1), disp); if (opt_showdisassemble) { @@ -2081,8 +2075,7 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, &(fi->value)); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_clinit, fi->class, 0); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); if (opt_showdisassemble) { M_NOP; M_NOP; @@ -2118,8 +2111,7 @@ bool codegen(jitdata *jd) gen_nullptr_check(s1); if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putfield, + codegen_addpatchref(cd, PATCHER_get_putfield, INSTRUCTION_UNRESOLVED_FIELD(iptr), 0); if (opt_showdisassemble) { @@ -2174,8 +2166,7 @@ bool codegen(jitdata *jd) } if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putfield, + codegen_addpatchref(cd, PATCHER_get_putfield, INSTRUCTION_UNRESOLVED_FIELD(iptr), 0); if (opt_showdisassemble) { @@ -2216,8 +2207,7 @@ bool codegen(jitdata *jd) gen_nullptr_check(s1); if (INSTRUCTION_IS_UNRESOLVED(iptr + 1)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putfield, + codegen_addpatchref(cd, PATCHER_get_putfield, INSTRUCTION_UNRESOLVED_FIELD(iptr + 1), 0); if (opt_showdisassemble) { @@ -2259,8 +2249,7 @@ bool codegen(jitdata *jd) #ifdef ENABLE_VERIFIER if (iptr->val.a) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_athrow_areturn, + codegen_addpatchref(cd, PATCHER_athrow_areturn, (unresolved_class *) iptr->val.a, 0); if (opt_showdisassemble) { @@ -2281,7 +2270,7 @@ bool codegen(jitdata *jd) case ICMD_GOTO: /* ... ==> ... */ /* op1 = target JavaVM pc */ M_BR(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; ALIGNCODENOP; break; @@ -2312,7 +2301,7 @@ bool codegen(jitdata *jd) s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); M_BEQZ(s1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2321,7 +2310,7 @@ bool codegen(jitdata *jd) s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); M_BNEZ(s1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2335,7 +2324,7 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP2, iptr->val.i); M_BEQ(s1, REG_ITMP2, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2354,7 +2343,7 @@ bool codegen(jitdata *jd) } M_BNEZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2376,7 +2365,7 @@ bool codegen(jitdata *jd) M_BEQZ(REG_ITMP1, 0); } } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2391,7 +2380,7 @@ bool codegen(jitdata *jd) ICONST(REG_ITMP2, iptr->val.i); M_BNE(s1, REG_ITMP2, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2413,7 +2402,7 @@ bool codegen(jitdata *jd) M_BNEZ(REG_ITMP1, 0); } } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2434,7 +2423,7 @@ bool codegen(jitdata *jd) } M_BEQZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2449,7 +2438,7 @@ bool codegen(jitdata *jd) LCONST(REG_ITMP2, iptr->val.l); M_BEQ(s1, REG_ITMP2, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2470,7 +2459,7 @@ bool codegen(jitdata *jd) } M_BNEZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2492,7 +2481,7 @@ bool codegen(jitdata *jd) M_BEQZ(REG_ITMP1, 0); } } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2507,7 +2496,7 @@ bool codegen(jitdata *jd) LCONST(REG_ITMP2, iptr->val.l); M_BNE(s1, REG_ITMP2, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2529,7 +2518,7 @@ bool codegen(jitdata *jd) M_BNEZ(REG_ITMP1, 0); } } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2550,7 +2539,7 @@ bool codegen(jitdata *jd) } M_BEQZ(REG_ITMP1, 0); } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2561,7 +2550,7 @@ bool codegen(jitdata *jd) s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_BEQ(s1, s2, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2572,7 +2561,7 @@ bool codegen(jitdata *jd) s1 = emit_load_s1(jd, iptr, src->prev, REG_ITMP1); s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_BNE(s1, s2, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2583,7 +2572,7 @@ bool codegen(jitdata *jd) s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMPLT(s1, s2, REG_ITMP1); M_BNEZ(REG_ITMP1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2594,7 +2583,7 @@ bool codegen(jitdata *jd) s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMPGT(s1, s2, REG_ITMP1); M_BNEZ(REG_ITMP1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2605,7 +2594,7 @@ bool codegen(jitdata *jd) s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMPGT(s1, s2, REG_ITMP1); M_BEQZ(REG_ITMP1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2616,7 +2605,7 @@ bool codegen(jitdata *jd) s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMPLT(s1, s2, REG_ITMP1); M_BEQZ(REG_ITMP1, 0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_NOP; break; @@ -2836,8 +2825,7 @@ bool codegen(jitdata *jd) #ifdef ENABLE_VERIFIER if (iptr->val.a) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_athrow_areturn, + codegen_addpatchref(cd, PATCHER_athrow_areturn, (unresolved_class *) iptr->val.a, 0); if (opt_showdisassemble) { @@ -3006,7 +2994,7 @@ nowperformreturn: M_CMPULT_IMM(REG_ITMP1, i, REG_ITMP2); M_BEQZ(REG_ITMP2, 0); - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); M_ASLL_IMM(REG_ITMP1, POINTERSHIFT, REG_ITMP1); /* delay slot*/ /* build jump table top down and use address of lowest entry */ @@ -3051,13 +3039,13 @@ nowperformreturn: val = s4ptr[0]; ICONST(REG_ITMP2, val); M_BEQ(s1, REG_ITMP2, 0); - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); M_NOP; - } + } M_BR(0); tptr = (void **) iptr->target; - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); M_NOP; ALIGNCODENOP; break; @@ -3141,14 +3129,14 @@ gen_method: if (iptr->op1 == true) { M_BEQZ(REG_RESULT, 0); - codegen_add_fillinstacktrace_ref(cd, cd->mcodeptr); + codegen_add_fillinstacktrace_ref(cd); M_NOP; } break; case ICMD_INVOKESPECIAL: M_BEQZ(rd->argintregs[0], 0); - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); + codegen_add_nullpointerexception_ref(cd); M_NOP; /* fall through */ @@ -3158,8 +3146,8 @@ gen_method: disp = dseg_addaddress(cd, NULL); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_invokestatic_special, um, disp); + codegen_addpatchref(cd, PATCHER_invokestatic_special, + um, disp); if (opt_showdisassemble) { M_NOP; M_NOP; @@ -3185,8 +3173,7 @@ gen_method: if (lm == NULL) { unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_invokevirtual, um, 0); + codegen_addpatchref(cd, PATCHER_invokevirtual, um, 0); if (opt_showdisassemble) { M_NOP; M_NOP; @@ -3216,8 +3203,7 @@ gen_method: if (lm == NULL) { unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_invokeinterface, um, 0); + codegen_addpatchref(cd, PATCHER_invokeinterface, um, 0); if (opt_showdisassemble) { M_NOP; M_NOP; @@ -3324,8 +3310,7 @@ gen_method: disp = dseg_adds4(cd, 0); /* super->flags */ - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_checkcast_instanceof_flags, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags, (constant_classref *) iptr->target, disp); @@ -3348,7 +3333,7 @@ gen_method: M_NOP; } else { - codegen_addpatchref(cd, cd->mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_interface, (constant_classref *) iptr->target, 0); @@ -3362,13 +3347,13 @@ gen_method: M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetablelength)); M_IADD_IMM(REG_ITMP3, -superindex, REG_ITMP3); M_BLEZ(REG_ITMP3, 0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); M_NOP; M_ALD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetable[0]) - superindex * sizeof(methodptr*)); M_BEQZ(REG_ITMP3, 0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); M_NOP; if (!super) { @@ -3387,7 +3372,7 @@ gen_method: M_NOP; } else { - codegen_addpatchref(cd, cd->mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_class, (constant_classref *) iptr->target, disp); @@ -3421,7 +3406,7 @@ gen_method: /* } */ M_CMPULT(REG_ITMP3, REG_ITMP2, REG_ITMP3); M_BNEZ(REG_ITMP3, 0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); M_NOP; } d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, s1); @@ -3433,8 +3418,7 @@ gen_method: disp = dseg_addaddress(cd, iptr->val.a); if (iptr->val.a == NULL) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_builtin_arraycheckcast, + codegen_addpatchref(cd, PATCHER_builtin_arraycheckcast, (constant_classref *) iptr->target, disp); @@ -3450,7 +3434,7 @@ gen_method: M_NOP; M_BEQZ(REG_RESULT, 0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); M_NOP; s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); @@ -3526,8 +3510,7 @@ gen_method: disp = dseg_adds4(cd, 0); /* super->flags */ - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_checkcast_instanceof_flags, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags, (constant_classref *) iptr->target, disp); if (opt_showdisassemble) { @@ -3549,7 +3532,7 @@ gen_method: M_NOP; } else { - codegen_addpatchref(cd, cd->mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_interface, (constant_classref *) iptr->target, 0); @@ -3584,8 +3567,7 @@ gen_method: M_NOP; } else { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_checkcast_instanceof_class, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_class, (constant_classref *) iptr->target, disp); @@ -3638,10 +3620,8 @@ gen_method: if (iptr->val.a == NULL) { disp = dseg_addaddress(cd, NULL); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_builtin_multianewarray, - (constant_classref *) iptr->target, - disp); + codegen_addpatchref(cd, PATCHER_builtin_multianewarray, + (constant_classref *) iptr->target, disp); if (opt_showdisassemble) { M_NOP; M_NOP; @@ -3667,7 +3647,7 @@ gen_method: /* check for exception before result assignment */ M_BEQZ(REG_RESULT, 0); - codegen_add_fillinstacktrace_ref(cd, cd->mcodeptr); + codegen_add_fillinstacktrace_ref(cd); M_NOP; d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT); @@ -3959,7 +3939,7 @@ gen_method: } } - codegen_finish(jd, (s4) ((u1 *) cd->mcodeptr - cd->mcodebase)); + codegen_finish(jd); /* everything's ok */ @@ -4144,7 +4124,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) #if !defined(WITH_STATIC_CLASSPATH) if (f == NULL) { - codegen_addpatchref(cd, cd->mcodeptr, PATCHER_resolve_native, m, funcdisp); + codegen_addpatchref(cd, PATCHER_resolve_native, m, funcdisp); if (opt_showdisassemble) { M_NOP; M_NOP; @@ -4429,7 +4409,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) } } - codegen_finish(jd, (s4) ((u1 *) cd->mcodeptr - cd->mcodebase)); + codegen_finish(jd); return jd->code->entrypoint; } diff --git a/src/vm/jit/mips/codegen.h b/src/vm/jit/mips/codegen.h index e51fbe8cf..f9991e722 100644 --- a/src/vm/jit/mips/codegen.h +++ b/src/vm/jit/mips/codegen.h @@ -26,7 +26,7 @@ Authors: Andreas Krall - $Id: codegen.h 4783 2006-04-18 13:36:15Z twisti $ + $Id: codegen.h 4826 2006-04-24 16:06:16Z twisti $ */ @@ -50,7 +50,7 @@ #define gen_nullptr_check(objreg) \ if (checknull) { \ M_BEQZ(objreg, 0); \ - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); \ + codegen_add_nullpointerexception_ref(cd); \ M_NOP; \ } @@ -59,14 +59,14 @@ M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size)); \ M_CMPULT(s2, REG_ITMP3, REG_ITMP3); \ M_BEQZ(REG_ITMP3, 0); \ - codegen_add_arrayindexoutofboundsexception_ref(cd, cd->mcodeptr, s2); \ + codegen_add_arrayindexoutofboundsexception_ref(cd, s2); \ M_NOP; \ } #define gen_div_check(r) \ do { \ M_BEQZ((r), 0); \ - codegen_add_arithmeticexception_ref(cd, cd->mcodeptr); \ + codegen_add_arithmeticexception_ref(cd); \ M_NOP; \ } while (0) @@ -74,8 +74,10 @@ /* MCODECHECK(icnt) */ #define MCODECHECK(icnt) \ - if ((cd->mcodeptr + (icnt)) > (u4 *) cd->mcodeend) \ - cd->mcodeptr = (u4 *) codegen_increase(cd, (u1 *) cd->mcodeptr) + do { \ + if ((cd->mcodeptr + (icnt)) > (u4 *) cd->mcodeend) \ + codegen_increase(cd); \ + } while (0) #define ALIGNCODENOP \ diff --git a/src/vm/jit/powerpc/codegen.c b/src/vm/jit/powerpc/codegen.c index f3beb1966..1da2049bc 100644 --- a/src/vm/jit/powerpc/codegen.c +++ b/src/vm/jit/powerpc/codegen.c @@ -31,7 +31,7 @@ Christian Ullrich Edwin Steiner - $Id: codegen.c 4819 2006-04-24 09:58:04Z twisti $ + $Id: codegen.c 4826 2006-04-24 16:06:16Z twisti $ */ @@ -333,7 +333,7 @@ bool codegen(jitdata *jd) M_MTCTR(REG_ITMP3); M_TST(rd->argintregs[0]); M_BEQ(0); - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); + codegen_add_nullpointerexception_ref(cd); M_AST(rd->argintregs[0], REG_SP, s1 * 4); M_JSR; } @@ -475,7 +475,7 @@ bool codegen(jitdata *jd) for (iptr = bptr->iinstr; len > 0; src = iptr->dst, len--, iptr++) { if (iptr->line != currentline) { - dseg_addlinenumber(cd, iptr->line, (u1 *) cd->mcodeptr); + dseg_addlinenumber(cd, iptr->line); currentline = iptr->line; } @@ -492,7 +492,7 @@ bool codegen(jitdata *jd) s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); M_TST(s1); M_BEQ(0); - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); + codegen_add_nullpointerexception_ref(cd); break; /* constant operations ************************************************/ @@ -538,8 +538,7 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, iptr->val.a); if ((iptr->target != NULL) && (iptr->val.a == NULL)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_aconst, + codegen_addpatchref(cd, PATCHER_aconst, (unresolved_class *) iptr->target, disp); if (opt_showdisassemble) @@ -922,7 +921,7 @@ bool codegen(jitdata *jd) d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1); M_TST(s2); M_BEQ(0); - codegen_add_arithmeticexception_ref(cd, cd->mcodeptr); + codegen_add_arithmeticexception_ref(cd); M_LDAH(REG_ITMP3, REG_ZERO, 0x8000); M_CMP(REG_ITMP3, s1); M_BNE(3 + (s1 != d)); @@ -941,7 +940,7 @@ bool codegen(jitdata *jd) d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP2); M_TST(s2); M_BEQ(0); - codegen_add_arithmeticexception_ref(cd, cd->mcodeptr); + codegen_add_arithmeticexception_ref(cd); M_LDAH(REG_ITMP3, REG_ZERO, 0x8000); M_CMP(REG_ITMP3, s1); M_BNE(4); @@ -964,7 +963,7 @@ bool codegen(jitdata *jd) s2 = emit_load_s2(jd, iptr, src, PACK_REGS(REG_ITMP2, REG_ITMP1)); M_OR_TST(GET_HIGH_REG(s2), GET_LOW_REG(s2), REG_ITMP3); M_BEQ(0); - codegen_add_arithmeticexception_ref(cd, cd->mcodeptr); + codegen_add_arithmeticexception_ref(cd); disp = dseg_addaddress(cd, bte->fp); M_ALD(REG_ITMP1, REG_PV, disp); @@ -1762,7 +1761,7 @@ bool codegen(jitdata *jd) M_JSR; M_TST(REG_RESULT); M_BEQ(0); - codegen_add_arraystoreexception_ref(cd, cd->mcodeptr); + codegen_add_arraystoreexception_ref(cd); s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1); s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2); @@ -1779,8 +1778,7 @@ bool codegen(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { disp = dseg_addaddress(cd, NULL); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr), disp); if (opt_showdisassemble) @@ -1792,8 +1790,7 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, &(fi->value)); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_clinit, fi->class, disp); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, disp); if (opt_showdisassemble) M_NOP; @@ -1834,8 +1831,7 @@ bool codegen(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { disp = dseg_addaddress(cd, NULL); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr), disp); if (opt_showdisassemble) @@ -1847,8 +1843,7 @@ bool codegen(jitdata *jd) disp = dseg_addaddress(cd, &(fi->value)); if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_clinit, fi->class, disp); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, disp); if (opt_showdisassemble) M_NOP; @@ -1888,8 +1883,7 @@ bool codegen(jitdata *jd) gen_nullptr_check(s1); if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putfield, + codegen_addpatchref(cd, PATCHER_get_putfield, INSTRUCTION_UNRESOLVED_FIELD(iptr), 0); if (opt_showdisassemble) @@ -1949,8 +1943,7 @@ bool codegen(jitdata *jd) } if (INSTRUCTION_IS_UNRESOLVED(iptr)) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putfield, + codegen_addpatchref(cd, PATCHER_get_putfield, INSTRUCTION_UNRESOLVED_FIELD(iptr), 0); if (opt_showdisassemble) @@ -1992,8 +1985,7 @@ bool codegen(jitdata *jd) #ifdef ENABLE_VERIFIER if (iptr->val.a) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_athrow_areturn, + codegen_addpatchref(cd, PATCHER_athrow_areturn, (unresolved_class *) iptr->val.a, 0); if (opt_showdisassemble) @@ -2017,20 +2009,22 @@ bool codegen(jitdata *jd) case ICMD_GOTO: /* ... ==> ... */ /* op1 = target JavaVM pc */ M_BR(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); ALIGNCODENOP; break; case ICMD_JSR: /* ... ==> ... */ /* op1 = target JavaVM pc */ - if (m->isleafmethod) M_MFLR(REG_ITMP2); + if (m->isleafmethod) + M_MFLR(REG_ITMP2); M_BL(0); M_MFLR(REG_ITMP1); - M_IADD_IMM(REG_ITMP1, m->isleafmethod ? 16 : 12, REG_ITMP1); - if (m->isleafmethod) M_MTLR(REG_ITMP2); + M_IADD_IMM(REG_ITMP1, m->isleafmethod ? 4*4 : 3*4, REG_ITMP1); + if (m->isleafmethod) + M_MTLR(REG_ITMP2); M_BR(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_RET: /* ... ==> ... */ @@ -2053,7 +2047,7 @@ bool codegen(jitdata *jd) s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); M_TST(s1); M_BEQ(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFNONNULL: /* ..., value ==> ... */ @@ -2062,7 +2056,7 @@ bool codegen(jitdata *jd) s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); M_TST(s1); M_BNE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IFLT: @@ -2100,7 +2094,7 @@ bool codegen(jitdata *jd) M_BEQ(0); break; } - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; @@ -2123,7 +2117,7 @@ bool codegen(jitdata *jd) M_OR_TST(REG_ITMP1, REG_ITMP2, REG_ITMP3); } M_BEQ(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LLT: /* ..., value ==> ... */ @@ -2136,20 +2130,20 @@ bool codegen(jitdata *jd) } else if ((iptr->val.l >= 0) && (iptr->val.l <= 0xffff)) { M_CMPI(s2, 0); M_BLT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_BGT(2); M_CMPUI(s1, iptr->val.l & 0xffff); } else { ICONST(REG_ITMP3, iptr->val.l >> 32); M_CMP(s2, REG_ITMP3); M_BLT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_BGT(3); ICONST(REG_ITMP3, iptr->val.l & 0xffffffff); M_CMPU(s1, REG_ITMP3); } M_BLT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LLE: /* ..., value ==> ... */ @@ -2165,20 +2159,20 @@ bool codegen(jitdata *jd) if ((iptr->val.l >= 0) && (iptr->val.l <= 0xffff)) { M_CMPI(s2, 0); M_BLT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_BGT(2); M_CMPUI(s1, iptr->val.l & 0xffff); } else { ICONST(REG_ITMP3, iptr->val.l >> 32); M_CMP(s2, REG_ITMP3); M_BLT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_BGT(3); ICONST(REG_ITMP3, iptr->val.l & 0xffffffff); M_CMPU(s1, REG_ITMP3); } M_BLE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LNE: /* ..., value ==> ... */ @@ -2200,7 +2194,7 @@ bool codegen(jitdata *jd) M_OR_TST(REG_ITMP1, REG_ITMP2, REG_ITMP3); } M_BNE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LGT: /* ..., value ==> ... */ @@ -2216,20 +2210,20 @@ bool codegen(jitdata *jd) if ((iptr->val.l >= 0) && (iptr->val.l <= 0xffff)) { M_CMPI(s2, 0); M_BGT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_BLT(2); M_CMPUI(s1, iptr->val.l & 0xffff); } else { ICONST(REG_ITMP3, iptr->val.l >> 32); M_CMP(s2, REG_ITMP3); M_BGT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_BLT(3); ICONST(REG_ITMP3, iptr->val.l & 0xffffffff); M_CMPU(s1, REG_ITMP3); } M_BGT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LGE: /* ..., value ==> ... */ @@ -2243,20 +2237,20 @@ bool codegen(jitdata *jd) } else if ((iptr->val.l >= 0) && (iptr->val.l <= 0xffff)) { M_CMPI(s2, 0); M_BGT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_BLT(2); M_CMPUI(s1, iptr->val.l & 0xffff); } else { ICONST(REG_ITMP3, iptr->val.l >> 32); M_CMP(s2, REG_ITMP3); M_BGT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); M_BLT(3); ICONST(REG_ITMP3, iptr->val.l & 0xffffffff); M_CMPU(s1, REG_ITMP3); } M_BGE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPEQ: /* ..., value, value ==> ... */ @@ -2266,7 +2260,7 @@ bool codegen(jitdata *jd) s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMP(s1, s2); M_BEQ(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LCMPEQ: /* ..., value, value ==> ... */ @@ -2281,7 +2275,7 @@ bool codegen(jitdata *jd) M_BNE(2); M_CMP(s1, s2); M_BEQ(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPNE: /* ..., value, value ==> ... */ @@ -2291,7 +2285,7 @@ bool codegen(jitdata *jd) s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMP(s1, s2); M_BNE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LCMPNE: /* ..., value, value ==> ... */ @@ -2301,12 +2295,12 @@ bool codegen(jitdata *jd) s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP2); M_CMP(s1, s2); M_BNE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1); s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2); M_CMP(s1, s2); M_BNE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPLT: /* ..., value, value ==> ... */ @@ -2316,7 +2310,7 @@ bool codegen(jitdata *jd) s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMP(s1, s2); M_BLT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LCMPLT: /* ..., value, value ==> ... */ @@ -2326,14 +2320,14 @@ bool codegen(jitdata *jd) s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP2); M_CMP(s1, s2); M_BLT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); /* load low-bits before the branch, so we know the distance */ s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1); s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2); M_BGT(2); M_CMPU(s1, s2); M_BLT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPGT: /* ..., value, value ==> ... */ @@ -2343,7 +2337,7 @@ bool codegen(jitdata *jd) s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMP(s1, s2); M_BGT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LCMPGT: /* ..., value, value ==> ... */ @@ -2353,14 +2347,14 @@ bool codegen(jitdata *jd) s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP2); M_CMP(s1, s2); M_BGT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); /* load low-bits before the branch, so we know the distance */ s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1); s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2); M_BLT(2); M_CMPU(s1, s2); M_BGT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPLE: /* ..., value, value ==> ... */ @@ -2370,7 +2364,7 @@ bool codegen(jitdata *jd) s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMP(s1, s2); M_BLE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LCMPLE: /* ..., value, value ==> ... */ @@ -2380,14 +2374,14 @@ bool codegen(jitdata *jd) s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP2); M_CMP(s1, s2); M_BLT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); /* load low-bits before the branch, so we know the distance */ s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1); s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2); M_BGT(2); M_CMPU(s1, s2); M_BLE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_ICMPGE: /* ..., value, value ==> ... */ @@ -2397,7 +2391,7 @@ bool codegen(jitdata *jd) s2 = emit_load_s2(jd, iptr, src, REG_ITMP2); M_CMP(s1, s2); M_BGE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IF_LCMPGE: /* ..., value, value ==> ... */ @@ -2407,14 +2401,14 @@ bool codegen(jitdata *jd) s2 = emit_load_s2_high(jd, iptr, src, REG_ITMP2); M_CMP(s1, s2); M_BGT(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); /* load low-bits before the branch, so we know the distance */ s1 = emit_load_s1_low(jd, iptr, src->prev, REG_ITMP1); s2 = emit_load_s2_low(jd, iptr, src, REG_ITMP2); M_BLT(2); M_CMPU(s1, s2); M_BGE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_IRETURN: /* ..., retvalue ==> ... */ @@ -2430,8 +2424,7 @@ bool codegen(jitdata *jd) #ifdef ENABLE_VERIFIER if (iptr->val.a) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_athrow_areturn, + codegen_addpatchref(cd, PATCHER_athrow_areturn, (unresolved_class *) iptr->val.a, 0); if (opt_showdisassemble) @@ -2616,7 +2609,7 @@ nowperformreturn: M_CMPUI(REG_ITMP1, i - 1); M_BGT(0); - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); /* build jump table top down and use address of lowest entry */ @@ -2666,12 +2659,12 @@ nowperformreturn: M_CMP(s1, REG_ITMP2); } M_BEQ(0); - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); } M_BR(0); tptr = (void **) iptr->target; - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); ALIGNCODENOP; break; @@ -2768,7 +2761,7 @@ gen_method: if (iptr->op1 == true) { M_CMPI(REG_RESULT, 0); M_BEQ(0); - codegen_add_fillinstacktrace_ref(cd, cd->mcodeptr); + codegen_add_fillinstacktrace_ref(cd); } break; @@ -2783,8 +2776,8 @@ gen_method: disp = dseg_addaddress(cd, NULL); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_invokestatic_special, um, disp); + codegen_addpatchref(cd, PATCHER_invokestatic_special, + um, disp); if (opt_showdisassemble) M_NOP; @@ -2810,8 +2803,7 @@ gen_method: if (lm == NULL) { unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_invokevirtual, um, 0); + codegen_addpatchref(cd, PATCHER_invokevirtual, um, 0); if (opt_showdisassemble) M_NOP; @@ -2841,8 +2833,7 @@ gen_method: if (lm == NULL) { unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_invokeinterface, um, 0); + codegen_addpatchref(cd, PATCHER_invokeinterface, um, 0); if (opt_showdisassemble) M_NOP; @@ -2953,9 +2944,10 @@ gen_method: disp = dseg_adds4(cd, 0); /* super->flags */ - codegen_addpatchref(cd, cd->mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags, - (constant_classref *) iptr->target, disp); + (constant_classref *) iptr->target, + disp); if (opt_showdisassemble) M_NOP; @@ -2973,9 +2965,10 @@ gen_method: M_BEQ(s2); } else { - codegen_addpatchref(cd, cd->mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_interface, - (constant_classref *) iptr->target, 0); + (constant_classref *) iptr->target, + 0); if (opt_showdisassemble) M_NOP; @@ -2985,13 +2978,13 @@ gen_method: M_ILD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetablelength)); M_LDATST(REG_ITMP3, REG_ITMP3, -superindex); M_BLE(0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); M_ALD(REG_ITMP3, REG_ITMP2, OFFSET(vftbl_t, interfacetable[0]) - superindex * sizeof(methodptr*)); M_TST(REG_ITMP3); M_BEQ(0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); if (!super) M_BR(s3); @@ -3007,8 +3000,7 @@ gen_method: M_BEQ(s3); } else { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_checkcast_class, + codegen_addpatchref(cd, PATCHER_checkcast_class, (constant_classref *) iptr->target, disp); @@ -3040,7 +3032,7 @@ gen_method: } M_CMPU(REG_ITMP3, REG_ITMP2); M_BGT(0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); } d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, s1); @@ -3053,8 +3045,7 @@ gen_method: disp = dseg_addaddress(cd, iptr->val.a); if (iptr->val.a == NULL) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_builtin_arraycheckcast, + codegen_addpatchref(cd, PATCHER_builtin_arraycheckcast, (constant_classref *) iptr->target, disp); @@ -3069,7 +3060,7 @@ gen_method: M_JSR; M_TST(REG_RESULT); M_BEQ(0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, s1); @@ -3142,8 +3133,7 @@ gen_method: disp = dseg_adds4(cd, 0); /* super->flags */ - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_checkcast_instanceof_flags, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags, (constant_classref *) iptr->target, disp); if (opt_showdisassemble) @@ -3162,7 +3152,7 @@ gen_method: M_BEQ(s2); } else { - codegen_addpatchref(cd, cd->mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_interface, (constant_classref *) iptr->target, 0); @@ -3195,8 +3185,7 @@ gen_method: M_BEQ(s3); } else { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_instanceof_class, + codegen_addpatchref(cd, PATCHER_instanceof_class, (constant_classref *) iptr->target, disp); @@ -3255,10 +3244,8 @@ gen_method: if (iptr->val.a == NULL) { disp = dseg_addaddress(cd, NULL); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_builtin_multianewarray, - (constant_classref *) iptr->target, - disp); + codegen_addpatchref(cd, PATCHER_builtin_multianewarray, + (constant_classref *) iptr->target, disp); if (opt_showdisassemble) M_NOP; @@ -3288,7 +3275,7 @@ gen_method: M_CMPI(REG_RESULT, 0); M_BEQ(0); - codegen_add_fillinstacktrace_ref(cd, cd->mcodeptr); + codegen_add_fillinstacktrace_ref(cd); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT); M_INTMOVE(REG_RESULT, d); @@ -3554,7 +3541,7 @@ gen_method: } } - codegen_finish(jd, (s4) ((u1 *) cd->mcodeptr - cd->mcodebase)); + codegen_finish(jd); /* everything's ok */ @@ -3689,7 +3676,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) #if !defined(WITH_STATIC_CLASSPATH) if (f == NULL) { - codegen_addpatchref(cd, cd->mcodeptr, PATCHER_resolve_native, m, funcdisp); + codegen_addpatchref(cd, PATCHER_resolve_native, m, funcdisp); if (opt_showdisassemble) M_NOP; @@ -4059,7 +4046,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) } } - codegen_finish(jd, (s4) ((u1 *) cd->mcodeptr - cd->mcodebase)); + codegen_finish(jd); return jd->code->entrypoint; } diff --git a/src/vm/jit/powerpc/codegen.h b/src/vm/jit/powerpc/codegen.h index 323a73928..ceb259575 100644 --- a/src/vm/jit/powerpc/codegen.h +++ b/src/vm/jit/powerpc/codegen.h @@ -31,7 +31,7 @@ Changes: Christian Thalinger Christian Ullrich - $Id: codegen.h 4819 2006-04-24 09:58:04Z twisti $ + $Id: codegen.h 4826 2006-04-24 16:06:16Z twisti $ */ @@ -56,7 +56,7 @@ if (checknull) { \ M_TST((objreg)); \ M_BEQ(0); \ - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); \ + codegen_add_nullpointerexception_ref(cd); \ } #define gen_bound_check \ @@ -64,15 +64,17 @@ M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));\ M_CMPU(s2, REG_ITMP3);\ M_BGE(0);\ - codegen_add_arrayindexoutofboundsexception_ref(cd, cd->mcodeptr, s2); \ + codegen_add_arrayindexoutofboundsexception_ref(cd, s2); \ } /* MCODECHECK(icnt) */ #define MCODECHECK(icnt) \ - if ((cd->mcodeptr + (icnt)) > (u4 *) cd->mcodeend) \ - cd->mcodeptr = (u4 *) codegen_increase(cd, (u1 *) cd->mcodeptr) + do { \ + if ((cd->mcodeptr + (icnt)) > (u4 *) cd->mcodeend) \ + codegen_increase(cd); \ + } while (0) /* M_INTMOVE: diff --git a/src/vm/jit/x86_64/codegen.c b/src/vm/jit/x86_64/codegen.c index 0f39dc038..ef24f8771 100644 --- a/src/vm/jit/x86_64/codegen.c +++ b/src/vm/jit/x86_64/codegen.c @@ -30,7 +30,7 @@ Changes: Christian Ullrich Edwin Steiner - $Id: codegen.c 4805 2006-04-21 10:54:24Z twisti $ + $Id: codegen.c 4826 2006-04-24 16:06:16Z twisti $ */ @@ -286,7 +286,7 @@ bool codegen(jitdata *jd) } else { M_TEST(rd->argintregs[0]); M_BEQ(0); - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); + codegen_add_nullpointerexception_ref(cd); M_AST(rd->argintregs[0], REG_SP, s1 * 8); M_MOV_IMM(BUILTIN_monitorenter, REG_ITMP1); M_CALL(REG_ITMP1); @@ -513,7 +513,7 @@ bool codegen(jitdata *jd) for (iptr = bptr->iinstr; len > 0; src = iptr->dst, len--, iptr++) { if (iptr->line != currentline) { - dseg_addlinenumber(cd, iptr->line, cd->mcodeptr); + dseg_addlinenumber(cd, iptr->line); currentline = iptr->line; } @@ -534,7 +534,7 @@ bool codegen(jitdata *jd) else M_TEST(src->regoff); M_BEQ(0); - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); + codegen_add_nullpointerexception_ref(cd); break; /* constant operations ************************************************/ @@ -581,8 +581,7 @@ bool codegen(jitdata *jd) if ((iptr->target != NULL) && (iptr->val.a == NULL)) { /* PROFILE_CYCLE_STOP; */ - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_aconst, + codegen_addpatchref(cd, PATCHER_aconst, (unresolved_class *) iptr->target, 0); if (opt_showdisassemble) { @@ -2202,7 +2201,7 @@ bool codegen(jitdata *jd) M_CALL(REG_ITMP1); M_TEST(REG_RESULT); M_BEQ(0); - codegen_add_arraystoreexception_ref(cd, cd->mcodeptr); + codegen_add_arraystoreexception_ref(cd); s1 = emit_load_s1(jd, iptr, src->prev->prev, REG_ITMP1); s2 = emit_load_s2(jd, iptr, src->prev, REG_ITMP2); @@ -2292,8 +2291,7 @@ bool codegen(jitdata *jd) /* PROFILE_CYCLE_STOP; */ - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr), disp); if (opt_showdisassemble) { @@ -2310,8 +2308,7 @@ bool codegen(jitdata *jd) if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { PROFILE_CYCLE_STOP; - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_clinit, fi->class, 0); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -2360,8 +2357,7 @@ bool codegen(jitdata *jd) /* PROFILE_CYCLE_STOP; */ - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr), disp); if (opt_showdisassemble) { @@ -2378,8 +2374,7 @@ bool codegen(jitdata *jd) if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { PROFILE_CYCLE_STOP; - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_clinit, fi->class, 0); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -2426,8 +2421,7 @@ bool codegen(jitdata *jd) /* PROFILE_CYCLE_STOP; */ - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putstatic, + codegen_addpatchref(cd, PATCHER_get_putstatic, INSTRUCTION_UNRESOLVED_FIELD(iptr + 1), disp); if (opt_showdisassemble) { @@ -2444,8 +2438,7 @@ bool codegen(jitdata *jd) if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) { PROFILE_CYCLE_STOP; - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_clinit, fi->class, 0); + codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -2488,8 +2481,7 @@ bool codegen(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { /* PROFILE_CYCLE_STOP; */ - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putfield, + codegen_addpatchref(cd, PATCHER_get_putfield, INSTRUCTION_UNRESOLVED_FIELD(iptr), 0); if (opt_showdisassemble) { @@ -2544,8 +2536,7 @@ bool codegen(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr)) { /* PROFILE_CYCLE_STOP; */ - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_get_putfield, + codegen_addpatchref(cd, PATCHER_get_putfield, INSTRUCTION_UNRESOLVED_FIELD(iptr), 0); if (opt_showdisassemble) { @@ -2588,8 +2579,7 @@ bool codegen(jitdata *jd) if (INSTRUCTION_IS_UNRESOLVED(iptr + 1)) { /* PROFILE_CYCLE_STOP; */ - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_putfieldconst, + codegen_addpatchref(cd, PATCHER_putfieldconst, INSTRUCTION_UNRESOLVED_FIELD(iptr + 1), 0); if (opt_showdisassemble) { @@ -2630,8 +2620,7 @@ bool codegen(jitdata *jd) #ifdef ENABLE_VERIFIER if (iptr->val.a) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_athrow_areturn, + codegen_addpatchref(cd, PATCHER_athrow_areturn, (unresolved_class *) iptr->val.a, 0); if (opt_showdisassemble) { @@ -2651,14 +2640,14 @@ bool codegen(jitdata *jd) /* op1 = target JavaVM pc */ M_JMP_IMM(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_JSR: /* ... ==> ... */ /* op1 = target JavaVM pc */ M_CALL_IMM(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); break; case ICMD_RET: /* ... ==> ... */ @@ -2685,7 +2674,7 @@ bool codegen(jitdata *jd) if ((iptr->opc & ICMD_CONDITION_MASK) == 0) { M_BEQ(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); } break; @@ -2702,7 +2691,7 @@ bool codegen(jitdata *jd) if ((iptr->opc & ICMD_CONDITION_MASK) == 0) { M_BNE(0); - codegen_addreference(cd, (basicblock *) iptr->target, cd->mcodeptr); + codegen_addreference(cd, (basicblock *) iptr->target); } break; @@ -2921,8 +2910,7 @@ bool codegen(jitdata *jd) if (iptr->val.a) { PROFILE_CYCLE_STOP; - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_athrow_areturn, + codegen_addpatchref(cd, PATCHER_athrow_areturn, (unresolved_class *) iptr->val.a, 0); if (opt_showdisassemble) { @@ -3053,8 +3041,7 @@ nowperformreturn: x86_64_alul_imm_reg(cd, X86_64_CMP, i - 1, REG_ITMP1); x86_64_jcc(cd, X86_64_CC_A, 0); - /* codegen_addreference(cd, BlockPtrOfPC(s4ptr[0]), cd->mcodeptr); */ - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); /* build jump table top down and use address of lowest entry */ @@ -3066,10 +3053,11 @@ nowperformreturn: --tptr; } - /* length of dataseg after last dseg_addtarget is used by load */ + /* length of dataseg after last dseg_addtarget is used + by load */ - x86_64_mov_imm_reg(cd, 0, REG_ITMP2); - dseg_adddata(cd, cd->mcodeptr); + M_MOV_IMM(0, REG_ITMP2); + dseg_adddata(cd); x86_64_mov_memindex_reg(cd, -(cd->dseglen), REG_ITMP2, REG_ITMP1, 3, REG_ITMP1); x86_64_jmp_reg(cd, REG_ITMP1); } @@ -3096,13 +3084,13 @@ nowperformreturn: val = s4ptr[0]; x86_64_alul_imm_reg(cd, X86_64_CMP, val, s1); x86_64_jcc(cd, X86_64_CC_E, 0); - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); } x86_64_jmp_imm(cd, 0); tptr = (void **) iptr->target; - codegen_addreference(cd, (basicblock *) tptr[0], cd->mcodeptr); + codegen_addreference(cd, (basicblock *) tptr[0]); } break; @@ -3179,14 +3167,14 @@ gen_method: if (iptr->op1 == true) { M_TEST(REG_RESULT); M_BEQ(0); - codegen_add_fillinstacktrace_ref(cd, cd->mcodeptr); + codegen_add_fillinstacktrace_ref(cd); } break; case ICMD_INVOKESPECIAL: M_TEST(rd->argintregs[0]); M_BEQ(0); - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); + codegen_add_nullpointerexception_ref(cd); /* first argument contains pointer */ /* gen_nullptr_check(rd->argintregs[0]); */ @@ -3200,8 +3188,8 @@ gen_method: if (lm == NULL) { unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_invokestatic_special, um, 0); + codegen_addpatchref(cd, PATCHER_invokestatic_special, + um, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -3225,8 +3213,7 @@ gen_method: if (lm == NULL) { unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_invokevirtual, um, 0); + codegen_addpatchref(cd, PATCHER_invokevirtual, um, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -3253,8 +3240,7 @@ gen_method: if (lm == NULL) { unresolved_method *um = INSTRUCTION_UNRESOLVED_METHOD(iptr); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_invokeinterface, um, 0); + codegen_addpatchref(cd, PATCHER_invokeinterface, um, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -3387,8 +3373,7 @@ gen_method: M_TEST(s1); M_BEQ(6 + (opt_showdisassemble ? 5 : 0) + 7 + 6 + s2 + 5 + s3); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_checkcast_instanceof_flags, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags, (constant_classref *) iptr->target, 0); if (opt_showdisassemble) { @@ -3411,9 +3396,10 @@ gen_method: M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); if (!super) { - codegen_addpatchref(cd, cd->mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_interface, - (constant_classref *) iptr->target, 0); + (constant_classref *) iptr->target, + 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -3427,14 +3413,14 @@ gen_method: M_LSUB_IMM32(superindex, REG_ITMP3); M_TEST(REG_ITMP3); M_BLE(0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); x86_64_mov_membase32_reg(cd, REG_ITMP2, OFFSET(vftbl_t, interfacetable[0]) - superindex * sizeof(methodptr*), REG_ITMP3); M_TEST(REG_ITMP3); M_BEQ(0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); if (!super) M_JMP_IMM(s3); @@ -3451,8 +3437,7 @@ gen_method: M_ALD(REG_ITMP2, s1, OFFSET(java_objectheader, vftbl)); if (!super) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_checkcast_class, + codegen_addpatchref(cd, PATCHER_checkcast_class, (constant_classref *) iptr->target, 0); @@ -3493,7 +3478,7 @@ gen_method: #endif M_CMP(REG_ITMP3, REG_ITMP2); M_BA(0); /* (u) REG_ITMP1 > (u) REG_ITMP2 -> jump */ - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); } d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP3); @@ -3504,8 +3489,7 @@ gen_method: M_INTMOVE(s1, rd->argintregs[0]); if (iptr->val.a == NULL) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_builtin_arraycheckcast, + codegen_addpatchref(cd, PATCHER_builtin_arraycheckcast, (constant_classref *) iptr->target, 0); if (opt_showdisassemble) { @@ -3518,7 +3502,7 @@ gen_method: M_CALL(REG_ITMP1); M_TEST(REG_RESULT); M_BEQ(0); - codegen_add_classcastexception_ref(cd, cd->mcodeptr); + codegen_add_classcastexception_ref(cd); s1 = emit_load_s1(jd, iptr, src, REG_ITMP1); d = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_ITMP1); @@ -3608,8 +3592,7 @@ gen_method: x86_64_jcc(cd, X86_64_CC_Z, (6 + (opt_showdisassemble ? 5 : 0) + 7 + 6 + s2 + 5 + s3)); - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_checkcast_instanceof_flags, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags, (constant_classref *) iptr->target, 0); if (opt_showdisassemble) { @@ -3633,7 +3616,7 @@ gen_method: OFFSET(java_objectheader, vftbl), REG_ITMP1); if (!super) { - codegen_addpatchref(cd, cd->mcodeptr, + codegen_addpatchref(cd, PATCHER_checkcast_instanceof_interface, (constant_classref *) iptr->target, 0); @@ -3675,8 +3658,7 @@ gen_method: REG_ITMP1); if (!super) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_instanceof_class, + codegen_addpatchref(cd, PATCHER_instanceof_class, (constant_classref *) iptr->target, 0); if (opt_showdisassemble) { @@ -3728,8 +3710,7 @@ gen_method: /* is a patcher function set? */ if (iptr->val.a == NULL) { - codegen_addpatchref(cd, cd->mcodeptr, - PATCHER_builtin_multianewarray, + codegen_addpatchref(cd, PATCHER_builtin_multianewarray, (constant_classref *) iptr->target, 0); if (opt_showdisassemble) { @@ -3761,7 +3742,7 @@ gen_method: M_TEST(REG_RESULT); M_BEQ(0); - codegen_add_fillinstacktrace_ref(cd, cd->mcodeptr); + codegen_add_fillinstacktrace_ref(cd); s1 = codegen_reg_of_var(rd, iptr->opc, iptr->dst, REG_RESULT); M_INTMOVE(REG_RESULT, s1); @@ -3856,7 +3837,7 @@ gen_method: /* calcuate exception address */ M_MOV_IMM(0, rd->argintregs[3]); - dseg_adddata(cd, cd->mcodeptr); + dseg_adddata(cd); M_AADD_IMM32(eref->branchpos - 6, rd->argintregs[3]); /* move function to call into REG_ITMP3 */ @@ -3973,7 +3954,7 @@ gen_method: } } - codegen_finish(jd, (s4) (cd->mcodeptr - cd->mcodebase)); + codegen_finish(jd); /* everything's ok */ @@ -4153,7 +4134,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) #if !defined(WITH_STATIC_CLASSPATH) if (f == NULL) { - codegen_addpatchref(cd, cd->mcodeptr, PATCHER_resolve_native, m, 0); + codegen_addpatchref(cd, PATCHER_resolve_native, m, 0); if (opt_showdisassemble) { M_NOP; M_NOP; M_NOP; M_NOP; M_NOP; @@ -4400,7 +4381,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd) } } - codegen_finish(jd, (s4) (cd->mcodeptr - cd->mcodebase)); + codegen_finish(jd); return jd->code->entrypoint; } diff --git a/src/vm/jit/x86_64/codegen.h b/src/vm/jit/x86_64/codegen.h index 4cae1789a..ebf79d2f3 100644 --- a/src/vm/jit/x86_64/codegen.h +++ b/src/vm/jit/x86_64/codegen.h @@ -29,7 +29,7 @@ Changes: - $Id: codegen.h 4795 2006-04-20 10:55:11Z twisti $ + $Id: codegen.h 4826 2006-04-24 16:06:16Z twisti $ */ @@ -281,7 +281,7 @@ typedef enum { if (checknull) { \ M_TEST(objreg); \ M_BEQ(0); \ - codegen_add_nullpointerexception_ref(cd, cd->mcodeptr); \ + codegen_add_nullpointerexception_ref(cd); \ } @@ -289,7 +289,7 @@ typedef enum { if (checkbounds) { \ M_CMP_MEMBASE(s1, OFFSET(java_arrayheader, size), s2); \ M_BAE(0); \ - codegen_add_arrayindexoutofboundsexception_ref(cd, cd->mcodeptr, s2); \ + codegen_add_arrayindexoutofboundsexception_ref(cd, s2); \ } @@ -301,15 +301,17 @@ typedef enum { M_TEST(src->regoff); \ } \ M_BEQ(0); \ - codegen_add_arithmeticexception_ref(cd, cd->mcodeptr); \ + codegen_add_arithmeticexception_ref(cd); \ } /* MCODECHECK(icnt) */ #define MCODECHECK(icnt) \ - if ((cd->mcodeptr + (icnt)) > (u1 *) cd->mcodeend) \ - cd->mcodeptr = (u1 *) codegen_increase(cd, cd->mcodeptr) + do { \ + if ((cd->mcodeptr + (icnt)) > cd->mcodeend) \ + codegen_increase(cd); \ + } while (0) #define ALIGNCODENOP \ -- 2.25.1