#include "vm/jit/emit-common.h"
#include "vm/jit/jit.h"
#include "vm/jit/parse.h"
-#include "vm/jit/patcher.h"
+#include "vm/jit/patcher-common.h"
#include "vm/jit/reg.h"
#include "vm/jit/replace.h"
#include "vm/jit/stacktrace.h"
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
disp = dseg_add_unique_address(cd, iptr->sx.val.c.ref);
- codegen_addpatchref(cd, PATCHER_aconst,
+ patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo,
iptr->sx.val.c.ref,
disp);
} else {
fieldtype = uf->fieldref->parseddesc.fd->type;
disp = dseg_add_unique_address(cd, NULL);
- codegen_addpatchref(cd, PATCHER_get_putstatic,
+ patcher_add_patch_ref(jd, PATCHER_get_putstatic,
iptr->sx.s23.s3.uf, disp);
}
disp = dseg_add_address(cd, fi->value);
if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
- codegen_addpatchref(cd, PATCHER_clinit, fi->class, disp);
+ patcher_add_patch_ref(jd, PATCHER_initialize_class, fi->class, disp);
}
}
fieldtype = uf->fieldref->parseddesc.fd->type;
disp = dseg_add_unique_address(cd, NULL);
- codegen_addpatchref(cd, PATCHER_get_putstatic,
+ patcher_add_patch_ref(jd, PATCHER_get_putstatic,
iptr->sx.s23.s3.uf, disp);
}
else {
disp = dseg_add_address(cd, fi->value);
if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
- codegen_addpatchref(cd, PATCHER_clinit, fi->class, disp);
+ patcher_add_patch_ref(jd, PATCHER_initialize_class, fi->class, disp);
}
}
fieldtype = uf->fieldref->parseddesc.fd->type;
disp = 0;
- codegen_addpatchref(cd, PATCHER_get_putfield, uf, 0);
+ patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0);
}
else {
fi = iptr->sx.s23.s3.fmiref->p.field;
s2 = emit_load_s2(jd, iptr, REG_FTMP2);
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
- codegen_addpatchref(cd, PATCHER_get_putfield, uf, 0);
+ patcher_add_patch_ref(jd, PATCHER_get_putfield, uf, 0);
}
#ifdef ENABLE_VERIFIER
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
- codegen_addpatchref(cd, PATCHER_athrow_areturn,
+ patcher_add_patch_ref(jd, PATCHER_athrow_areturn,
iptr->sx.s23.s2.uc, 0);
}
#endif /* ENABLE_VERIFIER */
#ifdef ENABLE_VERIFIER
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
- codegen_addpatchref(cd, PATCHER_athrow_areturn,
+ patcher_add_patch_ref(jd, PATCHER_athrow_areturn,
iptr->sx.s23.s2.uc, 0);
}
#endif /* ENABLE_VERIFIER */
if (lm == NULL) {
disp = dseg_add_unique_address(cd, um);
- codegen_addpatchref(cd, PATCHER_invokestatic_special,
+ patcher_add_patch_ref(jd, PATCHER_invokestatic_special,
um, disp);
} else {
disp = dseg_add_address(cd, lm->stubroutine);
break;
case ICMD_INVOKEVIRTUAL:
if (lm == NULL) {
- codegen_addpatchref(cd, PATCHER_invokevirtual, um, 0);
+ patcher_add_patch_ref(jd, PATCHER_invokevirtual, um, 0);
s1 = 0;
} else {
s1 = OFFSET(vftbl_t, table[0]) +
case ICMD_INVOKEINTERFACE:
if (lm == NULL) {
- codegen_addpatchref(cd, PATCHER_invokeinterface, um, 0);
+ patcher_add_patch_ref(jd, PATCHER_invokeinterface, um, 0);
s1 = 0;
s2 = 0;
emit_label_beq(cd, BRANCH_LABEL_1);
disp = dseg_add_unique_s4(cd, 0); /* super->flags */
- codegen_addpatchref(cd,
+ patcher_add_patch_ref(jd,
PATCHER_checkcast_instanceof_flags,
iptr->sx.s23.s3.c.ref,
disp);
if ((super == NULL) || (super->flags & ACC_INTERFACE)) {
if (super == NULL) {
- codegen_addpatchref(cd,
+ patcher_add_patch_ref(jd,
PATCHER_checkcast_interface,
iptr->sx.s23.s3.c.ref,
0);
emit_label(cd, BRANCH_LABEL_2);
disp = dseg_add_unique_address(cd, NULL);
- codegen_addpatchref(cd, PATCHER_checkcast_class,
+ patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_vftbl,
iptr->sx.s23.s3.c.ref,
disp);
} else {
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
disp = dseg_add_unique_address(cd, NULL);
- codegen_addpatchref(cd, PATCHER_builtin_arraycheckcast,
+ patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo,
iptr->sx.s23.s3.c.ref,
disp);
} else {
emit_label_beq(cd, BRANCH_LABEL_1);
disp = dseg_add_unique_s4(cd, 0); /* super->flags */
- codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags,
+ patcher_add_patch_ref(jd, PATCHER_checkcast_instanceof_flags,
iptr->sx.s23.s3.c.ref, disp);
M_ILD(REG_ITMP3, REG_PV, disp);
if ((super == NULL) || (super->flags & ACC_INTERFACE)) {
if (super == NULL) {
- codegen_addpatchref(cd,
+ patcher_add_patch_ref(jd,
PATCHER_instanceof_interface,
iptr->sx.s23.s3.c.ref, 0);
emit_label(cd, BRANCH_LABEL_2);
disp = dseg_add_unique_address(cd, NULL);
- codegen_addpatchref(cd, PATCHER_instanceof_class,
+ patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_vftbl,
iptr->sx.s23.s3.c.ref,
disp);
if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
disp = dseg_add_unique_address(cd, NULL);
- codegen_addpatchref(cd, PATCHER_builtin_multianewarray,
+ patcher_add_patch_ref(jd, PATCHER_resolve_classref_to_classinfo,
iptr->sx.s23.s3.c.ref, disp);
} else {
disp = dseg_add_address(cd, iptr->sx.s23.s3.c.cls);
dseg_createlinenumbertable(cd);
- /* generate stubs */
+ /* generate traps */
- emit_patcher_stubs(jd);
+ emit_patcher_traps(jd);
/* everything's ok */
funcdisp = dseg_add_functionptr(cd, f);
if (f == NULL)
- codegen_addpatchref(cd, PATCHER_resolve_native, m, funcdisp);
+ patcher_add_patch_ref(jd, PATCHER_resolve_native_function, m, funcdisp);
/* save integer and float argument registers */
M_MTCTR(REG_ITMP3);
M_RTS;
- /* generate patcher stub call code */
+ /* generate patcher traps */
- emit_patcher_stubs(jd);
+ emit_patcher_traps(jd);
}
}
-/* emit_patcher_stubs **********************************************************
-
- Generates the code for the patcher stubs.
-
-*******************************************************************************/
-void emit_patcher_stubs(jitdata *jd)
-{
- codegendata *cd;
- patchref *pref;
- u4 mcode;
- u1 *savedmcodeptr;
- u1 *tmpmcodeptr;
- s4 targetdisp;
- s4 disp;
-
- cd = jd->cd;
-
- /* generate code patching stub call code */
-
- targetdisp = 0;
-
- for (pref = cd->patchrefs; pref != NULL; pref = pref->next) {
- /* check code segment size */
-
- MCODECHECK(32);
-
- /* Get machine code which is patched back in later. The
- call is 1 instruction word long. */
-
- tmpmcodeptr = (u1 *) (cd->mcodebase + pref->branchpos);
-
- mcode = *((u4 *) tmpmcodeptr);
-
- /* Patch in the call to call the following code (done at
- compile time). */
-
- savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */
- cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */
-
- disp = ((u4 *) savedmcodeptr) - (((u4 *) tmpmcodeptr) + 1);
- M_BR(disp);
-
- cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */
-
- /* create stack frame - keep stack 16-byte aligned */
- M_AADD_IMM(REG_SP, -8 * 8, REG_SP);
-
- /* calculate return address and move it onto the stack */
- M_LDA(REG_ITMP3, REG_PV, pref->branchpos);
- M_AST_INTERN(REG_ITMP3, REG_SP, 5 * 8);
-
- /* move pointer to java_objectheader onto stack */
-
-#if defined(ENABLE_THREADS)
- /* order reversed because of data segment layout */
-
- (void) dseg_add_unique_address(cd, NULL); /* flcword */
- (void) dseg_add_unique_address(cd, lock_get_initial_lock_word()); /* monitorPtr */
- disp = dseg_add_unique_address(cd, NULL); /* vftbl */
-
- M_LDA(REG_ITMP3, REG_PV, disp);
- M_AST_INTERN(REG_ITMP3, REG_SP, 4 * 8);
-#else
- /* do nothing */
-#endif
-
- /* move machine code onto stack */
- disp = dseg_add_s4(cd, mcode);
- M_ILD(REG_ITMP3, REG_PV, disp);
- M_IST_INTERN(REG_ITMP3, REG_SP, 3 * 8);
-
- /* move class/method/field reference onto stack */
- disp = dseg_add_address(cd, pref->ref);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_AST_INTERN(REG_ITMP3, REG_SP, 2 * 8);
-
- /* move data segment displacement onto stack */
- disp = dseg_add_s4(cd, pref->disp);
- M_ILD(REG_ITMP3, REG_PV, disp);
- M_IST_INTERN(REG_ITMP3, REG_SP, 1 * 8);
-
- /* move patcher function pointer onto stack */
- disp = dseg_add_functionptr(cd, pref->patcher);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_AST_INTERN(REG_ITMP3, REG_SP, 0 * 8);
-
- if (targetdisp == 0) {
- targetdisp = ((u4 *) cd->mcodeptr) - ((u4 *) cd->mcodebase);
-
- disp = dseg_add_functionptr(cd, asm_patcher_wrapper);
- M_ALD(REG_ITMP3, REG_PV, disp);
- M_MTCTR(REG_ITMP3);
- M_RTS;
- }
- else {
- disp = (((u4 *) cd->mcodebase) + targetdisp) -
- (((u4 *) cd->mcodeptr) + 1);
- M_BR(disp);
- }
- }
-}
-
-
/* emit_trap *******************************************************************
Emit a trap instruction and return the original machine code.
mcode = *((uint32_t *) cd->mcodeptr);
- M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
+ /* ALD is 4 byte aligned, ILD 2, onyl LWZ is byte aligned */
+ M_LWZ(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
return mcode;
}
#include "vm/jit/asmpart.h"
#include "vm/jit/md.h"
#include "vm/jit/methodheader.h"
-#include "vm/jit/patcher.h"
+#include "vm/jit/patcher-common.h"
#include "vm/jit/stacktrace.h"
#include "vmcore/class.h"
#include "vm/resolve.h"
-/* patcher_wrapper *************************************************************
-
- Wrapper for all patchers. It also creates the stackframe info
- structure.
-
- If the return value of the patcher function is false, it gets the
- exception object, clears the exception pointer and returns the
- exception.
-
-*******************************************************************************/
-
-java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
-{
- stackframeinfo sfi;
- u1 *xpc;
- java_objectheader *o;
- functionptr f;
- bool result;
- java_objectheader *e;
-
- /* define the patcher function */
-
- bool (*patcher_function)(u1 *);
-
- assert(pv != NULL);
-
- /* get stuff from the stack */
-
- xpc = (u1 *) *((ptrint *) (sp + 5 * 8));
- o = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
- f = (functionptr) *((ptrint *) (sp + 0 * 8));
-
- /* store PV into the patcher function position */
-
- *((ptrint *) (sp + 0 * 8)) = (ptrint) pv;
-
- /* cast the passed function to a patcher function */
-
- patcher_function = (bool (*)(u1 *)) (ptrint) f;
-
- /* enter a monitor on the patching position */
-
- PATCHER_MONITORENTER;
-
- /* create the stackframeinfo */
-
- stacktrace_create_extern_stackframeinfo(&sfi, pv, sp + 8 * 8, ra, xpc);
-
- /* call the proper patcher function */
-
- result = (patcher_function)(sp);
-
- /* remove the stackframeinfo */
-
- stacktrace_remove_stackframeinfo(&sfi);
-
- /* check for return value and exit accordingly */
-
- if (result == false) {
- e = exceptions_get_and_clear_exception();
-
- PATCHER_MONITOREXIT;
-
- return e;
- }
-
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
- return NULL;
-}
-
-
/* patcher_get_putstatic *******************************************************
Machine code:
*******************************************************************************/
-bool patcher_get_putstatic(u1 *sp)
+bool patcher_get_putstatic(patchref_t *pr)
{
u1 *ra;
u4 mcode;
unresolved_field *uf;
- s4 disp;
- u1 *pv;
+ u1 *datap;
fieldinfo *fi;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- uf = (unresolved_field *) *((ptrint *) (sp + 2 * 8));
- disp = *((s4 *) (sp + 1 * 8));
- pv = (u1 *) *((ptrint *) (sp + 0 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ uf = (unresolved_field *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the fieldinfo */
/* patch the field value's address */
- *((intptr_t *) (pv + disp)) = (intptr_t) fi->value;
+ *((intptr_t *) datap) = (intptr_t) fi->value;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
*******************************************************************************/
-bool patcher_get_putfield(u1 *sp)
+bool patcher_get_putfield(patchref_t *pr)
{
u1 *ra;
u4 mcode;
unresolved_field *uf;
- u1 *pv;
fieldinfo *fi;
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- uf = (unresolved_field *) *((ptrint *) (sp + 2 * 8));
- pv = (u1 *) *((ptrint *) (sp + 1 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ uf = (unresolved_field *) pr->ref;
/* get the fieldinfo */
*((u4 *) ra) = mcode;
+ /* synchronize instruction cache */
+
+ md_icacheflush(ra, 4);
+
/* if we show disassembly, we have to skip the nop */
if (opt_shownops)
}
-/* patcher_aconst **************************************************************
-
- Machine code:
-
- <patched call postition>
- -------- ld r3,-64(r14)
- -------- ld r14,-72(r14)
- -------- mtcr r14
- -------- bctrl
-
-*******************************************************************************/
-
-bool patcher_aconst(u1 *sp)
-{
- u1 *ra;
- u4 mcode;
- constant_classref *cr;
- s4 disp;
- u1 *pv;
- classinfo *c;
-
- /* get stuff from the stack */
-
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 8));
- disp = *((s4 *) (sp + 1 * 8));
- pv = (u1 *) *((ptrint *) (sp + 0 * 8));
-
- /* get the classinfo */
-
- if (!(c = resolve_classref_eager(cr)))
- return false;
-
- /* patch back original code */
-
- *((u4 *) ra) = mcode;
-
- /* synchronize instruction cache */
-
- md_icacheflush(ra, 4);
-
- /* patch the classinfo pointer */
-
- *((ptrint *) (pv + disp)) = (ptrint) c;
-
- /* synchronize data cache */
-
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
-
- return true;
-}
-
-
-/* patcher_builtin_multianewarray **********************************************
-
- Machine code:
-
- <patched call position>
- 808dffc0 lwz r4,-64(r13)
- 38a10038 addi r5,r1,56
- 81adffbc lwz r13,-68(r13)
- 7da903a6 mtctr r13
- 4e800421 bctrl
-
-*******************************************************************************/
-
-bool patcher_builtin_multianewarray(u1 *sp)
-{
- u1 *ra;
- u4 mcode;
- constant_classref *cr;
- s4 disp;
- u1 *pv;
- classinfo *c;
-
- /* get stuff from the stack */
-
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 8));
- disp = *((s4 *) (sp + 1 * 8));
- pv = (u1 *) *((ptrint *) (sp + 0 * 8));
-
- /* get the classinfo */
-
- if (!(c = resolve_classref_eager(cr)))
- return false;
-
- /* patch back original code */
-
- *((u4 *) ra) = mcode;
-
- /* synchronize instruction cache */
-
- md_icacheflush(ra, 4);
-
- /* patch the classinfo pointer */
-
- *((ptrint *) (pv + disp)) = (ptrint) c;
-
- /* synchronize data cache */
-
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
-
- return true;
-}
-
-
-/* patcher_builtin_arraycheckcast **********************************************
-
- Machine code:
-
- <patched call position>
- 808dffd8 lwz r4,-40(r13)
- 81adffd4 lwz r13,-44(r13)
- 7da903a6 mtctr r13
- 4e800421 bctrl
-
-*******************************************************************************/
-
-bool patcher_builtin_arraycheckcast(u1 *sp)
-{
- u1 *ra;
- u4 mcode;
- constant_classref *cr;
- s4 disp;
- u1 *pv;
- classinfo *c;
-
- /* get stuff from the stack */
-
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 8));
- disp = *((s4 *) (sp + 1 * 8));
- pv = (u1 *) *((ptrint *) (sp + 0 * 8));
-
- /* get the classinfo */
-
- if (!(c = resolve_classref_eager(cr)))
- return false;
-
- /* patch back original code */
-
- *((u4 *) ra) = mcode;
-
- /* synchronize instruction cache */
-
- md_icacheflush(ra, 4);
-
- /* patch the classinfo pointer */
-
- *((ptrint *) (pv + disp)) = (ptrint) c;
-
- /* synchronize data cache */
-
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
-
- return true;
-}
-
-
/* patcher_invokestatic_special ************************************************
Machine code:
******************************************************************************/
-bool patcher_invokestatic_special(u1 *sp)
+bool patcher_invokestatic_special(patchref_t *pr)
{
u1 *ra;
u4 mcode;
unresolved_method *um;
- s4 disp;
- u1 *pv;
+ u1 *datap;
methodinfo *m;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- um = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
- disp = *((s4 *) (sp + 1 * 8));
- pv = (u1 *) *((ptrint *) (sp + 0 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ um = (unresolved_method *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the fieldinfo */
/* patch stubroutine */
- *((ptrint *) (pv + disp)) = (ptrint) m->stubroutine;
+ *((ptrint *) datap) = (ptrint) m->stubroutine;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
*******************************************************************************/
-bool patcher_invokevirtual(u1 *sp)
+bool patcher_invokevirtual(patchref_t *pr)
{
u1 *ra;
u4 mcode;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- um = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ um = (unresolved_method *) pr->ref;
/* get the fieldinfo */
*((u4 *) ra) = mcode;
+ /* synchronize instruction cache */
+
+ md_icacheflush(ra, 4);
+
/* if we show disassembly, we have to skip the nop */
if (opt_shownops)
*******************************************************************************/
-bool patcher_invokeinterface(u1 *sp)
+bool patcher_invokeinterface(patchref_t *pr)
{
u1 *ra;
u4 mcode;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- um = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ um = (unresolved_method *) pr->ref;
/* get the fieldinfo */
*((u4 *) ra) = mcode;
+ /* synchronize instruction cache */
+
+ md_icacheflush(ra, 4);
+
/* if we show disassembly, we have to skip the nop */
if (opt_shownops)
*******************************************************************************/
-bool patcher_checkcast_instanceof_flags(u1 *sp)
+bool patcher_checkcast_instanceof_flags(patchref_t *pr)
{
u1 *ra;
u4 mcode;
constant_classref *cr;
- s4 disp;
- u1 *pv;
+ u1 *datap;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 8));
- disp = *((s4 *) (sp + 1 * 8));
- pv = (u1 *) *((ptrint *) (sp + 0 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ cr = (constant_classref *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the fieldinfo */
/* patch class flags */
- *((s4 *) (pv + disp)) = (s4) c->flags;
+ *((s4 *) datap) = (s4) c->flags;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
800c0000 lwz r0,0(r12)
*******************************************************************************/
-bool patcher_checkcast_interface(u1 *sp)
+bool patcher_checkcast_interface(patchref_t *pr)
{
u1 *ra;
constant_classref *cr;
u4 mcode;
/* get stuff from stack */
- ra = (u1*) *((ptrint *)(sp + 5*8));
- mcode = *((u4*) (sp + 3*8));
- cr = (constant_classref*) *((ptrint*)(sp+2*8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ cr = (constant_classref *) pr->ref;
/* get the fieldinfo */
if (!(c = resolve_classref_eager(cr))) {
/* patch back original code */
*((u4 *) ra) = mcode;
+ /* synchronize instruction cache */
+
+ md_icacheflush(ra, 4);
+
/* if we show NOPs, we have to skip them */
- if (opt_shownops) {
+ if (opt_shownops)
ra = ra +4;
- }
/* patch super class index */
disp = -(c->index);
*******************************************************************************/
-bool patcher_instanceof_interface(u1 *sp)
+bool patcher_instanceof_interface(patchref_t *pr)
{
u1 *ra;
u4 mcode;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ cr = (constant_classref *) pr->ref;
/* get the fieldinfo */
*((u4 *) ra) = mcode;
+ /* synchronize instruction cache */
+
+ md_icacheflush(ra, 4);
+
/* if we show disassembly, we have to skip the nop */
if (opt_shownops)
*******************************************************************************/
-bool patcher_checkcast_class(u1 *sp)
+bool patcher_checkcast_class(patchref_t *pr)
{
u1 *ra;
u4 mcode;
constant_classref *cr;
- s4 disp;
- u1 *pv;
+ u1 *datap;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 8));
- disp = *((s4 *) (sp + 1 * 8));
- pv = (u1 *) *((ptrint *) (sp + 0 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ cr = (constant_classref *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the fieldinfo */
/* patch super class' vftbl */
- *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
+ *((ptrint *) datap) = (ptrint) c->vftbl;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
*******************************************************************************/
-bool patcher_resolve_classref_to_classinfo(u1 *sp)
+bool patcher_resolve_classref_to_classinfo(patchref_t *pr)
{
constant_classref *cr;
- s4 disp;
- u1 *pv, *ra;
+ u1 *datap, *ra;
u4 mcode;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 8));
- disp = *((s4 *) (sp + 1 * 8));
- pv = (u1 *) *((ptrint *) (sp + 0 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ cr = (constant_classref *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the classinfo */
/* patch the classinfo pointer */
- *((ptrint *) (pv + disp)) = (ptrint) c;
+ *((ptrint *) datap) = (ptrint) c;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
*******************************************************************************/
-bool patcher_instanceof_class(u1 *sp)
+bool patcher_instanceof_class(patchref_t *pr)
{
u1 *ra;
u4 mcode;
constant_classref *cr;
- s4 disp;
- u1 *pv;
+ u1 *datap;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 8));
- disp = *((s4 *) (sp + 1 * 8));
- pv = (u1 *) *((ptrint *) (sp + 0 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ cr = (constant_classref *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the fieldinfo */
/* patch super class' vftbl */
- *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
+ *((ptrint *) datap) = (ptrint) c->vftbl;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
*******************************************************************************/
-bool patcher_resolve_classref_to_vftbl(u1 *sp)
+bool patcher_resolve_classref_to_vftbl(patchref_t *pr)
{
constant_classref *cr;
- s4 disp;
- u1 *pv, *ra;
+ u1 *datap, *ra;
u4 mcode;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 8));
- disp = *((s4 *) (sp + 1 * 8));
- pv = (u1 *) *((ptrint *) (sp + 0 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ cr = (constant_classref *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the fieldinfo */
/* patch super class' vftbl */
- *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
+ *((ptrint *) datap) = (ptrint) c->vftbl;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
*******************************************************************************/
-bool patcher_resolve_classref_to_flags(u1 *sp)
+bool patcher_resolve_classref_to_flags(patchref_t *pr)
{
constant_classref *cr;
- s4 disp;
- u1 *pv, *ra;
+ u1 *datap, *ra;
u4 mcode;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- cr = (constant_classref *) *((ptrint *) (sp + 2 * 8));
- disp = *((s4 *) (sp + 1 * 8));
- pv = (u1 *) *((ptrint *) (sp + 0 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ cr = (constant_classref *) pr->ref;
+ datap = (u1 *) pr->datap;
/* get the fieldinfo */
/* patch class flags */
- *((s4 *) (pv + disp)) = (s4) c->flags;
+ *((s4 *) datap) = (s4) c->flags;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}
-/* patcher_clinit **************************************************************
+/* patcher_initialize_class ****************************************************
XXX
*******************************************************************************/
-bool patcher_clinit(u1 *sp)
+bool patcher_initialize_class(patchref_t *pr)
{
u1 *ra;
u4 mcode;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- c = (classinfo *) *((ptrint *) (sp + 2 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ c = (classinfo *) pr->ref;
/* check if the class is initialized */
*******************************************************************************/
#ifdef ENABLE_VERIFIER
-bool patcher_athrow_areturn(u1 *sp)
+bool patcher_athrow_areturn(patchref_t *pr)
{
u1 *ra;
u4 mcode;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- uc = (unresolved_class *) *((ptrint *) (sp + 2 * 8));
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ uc = (unresolved_class *) pr->ref;
/* resolve the class and check subtype constraints */
#endif /* ENABLE_VERIFIER */
-/* patcher_resolve_native ******************************************************
+/* patcher_resolve_native_function *********************************************
XXX
*******************************************************************************/
-bool patcher_resolve_native(u1 *sp)
+bool patcher_resolve_native_function(patchref_t *pr)
{
u1 *ra;
u4 mcode;
methodinfo *m;
- s4 disp;
- u1 *pv;
+ u1 *datap;
functionptr f;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 5 * 8));
- mcode = *((u4 *) (sp + 3 * 8));
- m = (methodinfo *) *((ptrint *) (sp + 2 * 8));
- disp = *((s4 *) (sp + 1 * 8));
- pv = (u1 *) *((ptrint *) (sp + 0 * 8));
+
+ ra = (u1 *) pr->mpc;
+ mcode = pr->mcode;
+ m = (methodinfo *) pr->ref;
+ datap = (u1 *) pr->datap;
/* resolve native function */
/* patch native function pointer */
- *((ptrint *) (pv + disp)) = (ptrint) f;
+ *((ptrint *) datap) = (ptrint) f;
/* synchronize data cache */
- md_dcacheflush(pv + disp, SIZEOF_VOID_P);
+ md_dcacheflush(datap, SIZEOF_VOID_P);
return true;
}