* src/vm/jit/powerpc64/emit.c (emit_patcher_stubs): Removed, this is obsolete.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Wed, 5 Sep 2007 23:28:52 +0000 (01:28 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Wed, 5 Sep 2007 23:28:52 +0000 (01:28 +0200)
(emit_trap): Fixed trap instruction:

* src/vm/jit/powerpc64/codegen.c (codegen_emit, codegen_emit_stub_native): Call
the new patcher functions and adapted to above change.

* src/vm/jit/powerpc64/patcher.c: Adapted patchers to new signature for traps.
(patcher_wrapper): Removed, this is obsolete.

* src/vm/jit/powerpc64/asmpart.S (asm_patcher_wrapper): Removed, this is
obsolete.

* src/vm/jit/powerpc64/linux/md-os.c (md_signal_handler_sigsegv): Only calls the
exception handling if exception object present.

* src/vm/jit/patcher-common.h [__POWERPC64__]: Enabled new patcher stuff.

* src/vm/jit/patcher.h [__POWERPC64__]: Defined away old patcher stuff.

src/vm/jit/patcher-common.h
src/vm/jit/patcher.h
src/vm/jit/powerpc64/asmpart.S
src/vm/jit/powerpc64/codegen.c
src/vm/jit/powerpc64/emit.c
src/vm/jit/powerpc64/linux/md-os.c
src/vm/jit/powerpc64/patcher.c

index cc4328ec1e91fac60f567abd990c74901d830bf1..ad603143173b9f29b53fc7b03eb59328ddf89076 100644 (file)
@@ -76,7 +76,7 @@ java_handle_t *patcher_handler(u1 *pc);
 
 /* patcher prototypes and macros **********************************************/
 
-#if defined(__ALPHA__) || defined(__ARM__) || defined(__MIPS__) || defined(__POWERPC__) || defined (__S390__)
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined (__S390__)
 
 /* new patcher functions */
 
@@ -137,7 +137,7 @@ bool patcher_invokevirtual(patchref_t *pr);
 bool patcher_invokeinterface(patchref_t *pr);
 #define PATCHER_invokeinterface (functionptr) patcher_invokeinterface
 
-#if defined(__ALPHA__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__S390__) 
+#if defined(__ALPHA__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) 
 
 bool patcher_checkcast_interface(patchref_t *pr);
 #define PATCHER_checkcast_interface (functionptr) patcher_checkcast_interface
@@ -145,12 +145,12 @@ bool patcher_checkcast_interface(patchref_t *pr);
 bool patcher_instanceof_interface(patchref_t *pr);
 #define PATCHER_instanceof_interface (functionptr) patcher_instanceof_interface
 
-#endif /* defined(__ALPHA__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__S390__) */
+#endif /* defined(__ALPHA__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__) */
 
 /* very old patcher functions */
 /* XXX use newer patcher function names above! */
 
-#if defined(__S390__)
+#if defined(__POWERPC64__) || defined(__S390__)
 
 bool patcher_clinit(patchref_t *pr);
 #define PATCHER_clinit (functionptr) patcher_clinit
@@ -161,7 +161,10 @@ bool patcher_athrow_areturn(patchref_t *pr);
 bool patcher_checkcast_instanceof_interface(patchref_t *pr);
 #define PATCHER_checkcast_instanceof_interface (functionptr) patcher_checkcast_instanceof_interface
 
-#endif /* defined (__S390__) */
+bool patcher_checkcast_instanceof_flags(patchref_t *pr);
+#define PATCHER_checkcast_instanceof_flags (functionptr) patcher_checkcast_instanceof_flags
+
+#endif /* defined(__POWERPC64__) || defined(__S390__) */
 
 #endif /* architecture list */
 
index 68b167468dd90272c52fbb9a7b7f6abf1e029b35..24796150af5d7bb8e247a5ddd3ac330be8cb7918 100644 (file)
@@ -39,7 +39,7 @@
 #include "vm/global.h"
 
 
-#if defined(__ALPHA__) || defined(__ARM__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__S390__)
+#if defined(__ALPHA__) || defined(__ARM__) || defined(__MIPS__) || defined(__POWERPC__) || defined(__POWERPC64__) || defined(__S390__)
 # error "you should no longer include this file"
 #else
 
index 541722a9ffb3eb9999fe3e8d3533f9db5c3fda76..63b850e13bddb5f16b8b2fd52dfdbd8ebd29540a 100644 (file)
@@ -48,8 +48,6 @@
 
        .globl asm_abstractmethoderror
 
-       .globl asm_patcher_wrapper
-
 #if defined(ENABLE_REPLACEMENT)
        .globl asm_replacement_out
        .globl .asm_replacement_in
@@ -467,69 +465,6 @@ asm_abstractmethoderror:
        b       L_asm_handle_nat_exception
 
 
-/* asm_patcher_wrapper *********************************************************
-
-   XXX
-
-   Stack layout:
-     40   return address into JIT code (patch position)
-     32   pointer to virtual java_objectheader
-     24   machine code (which is patched back later)
-     16   unresolved class/method/field reference
-      8   data segment displacement from load instructions
-      0   patcher function pointer to call (pv is saved here afterwards)
-
-*******************************************************************************/
-
-asm_patcher_wrapper:
-       mflr    r0                    /* get Java return address (leaf)           */
-       std     r0,6*8(sp)            /* store it in the stub stackframe          */
-                                     /* keep stack 16-bytes aligned: 6+1+37 = 44 */
-       stdu    sp,-(LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8)(sp)
-
-       SAVE_ARGUMENT_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS) /* save 8 int/8 float arguments   */
-       SAVE_TEMPORARY_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS+ARG_CNT)
-
-       std     itmp1,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+1*8(sp)
-       std     itmp2,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+2*8(sp)
-       std     pv,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+3*8(sp)
-
-       addi    a0,sp,LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8      /* pass SP of patcher stub            */
-       mr      a1,pv                       /* pass PV                            */
-       mr      a2,r0                       /* pass RA (correct for leafs)        */
-       bl      patcher_wrapper
-       std     v0,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+4*8(sp)     /* save return value                  */
-
-
-       RESTORE_ARGUMENT_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS) /* restore 8 int/8 float args  */
-       RESTORE_TEMPORARY_REGISTERS(LA_SIZE_IN_POINTERS+PA_SIZE_IN_POINTERS+ARG_CNT)
-
-       ld     itmp1,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+1*8(sp)
-       ld     itmp2,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+2*8(sp)
-       ld     pv,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+3*8(sp)
-       ld     itmp3,LA_SIZE+PA_SIZE+(ARG_CNT+TMP_CNT)*8+4*8(sp)
-
-       ld      r0,LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8+6*8(sp) /* restore RA                      */
-       mtlr    r0
-
-       mr.     itmp3,itmp3           /* check for an exception                   */
-       bne     L_asm_patcher_wrapper_exception
-
-                                     /* get return address (into JIT code)       */
-       ld     itmp3,LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8+5*8(sp)
-
-                                     /* remove stack frame + patcher stub stack  */
-       addi    sp,sp,LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8+8*8
-
-       mtctr   itmp3
-       bctr                          /* jump to new patched code                 */
-
-L_asm_patcher_wrapper_exception:
-       mr      xptr,itmp3                  /* get exception                      */
-       ld      xpc,LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8+5*8(sp)
-       addi    sp,sp,LA_SIZE+PA_SIZE+ARG_CNT*8+TMP_CNT*8+4*8+8*8
-       b       L_asm_handle_exception
-
 #if defined(ENABLE_REPLACEMENT)
 
 /* asm_replacement_out *********************************************************
index 1456e47b69137ef04d27f41a9e051f18e9a2c8c9..82347e61004539c39f528a52461ef2eb47674021 100644 (file)
@@ -61,7 +61,7 @@
 #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"
@@ -464,7 +464,7 @@ bool codegen_emit(jitdata *jd)
 
                        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  {
@@ -1567,7 +1567,7 @@ bool codegen_emit(jitdata *jd)
                                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);
 
                        }
@@ -1577,7 +1577,7 @@ bool codegen_emit(jitdata *jd)
                                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);
                                }
                        }
 
@@ -1615,7 +1615,7 @@ bool codegen_emit(jitdata *jd)
                                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 {
@@ -1624,7 +1624,7 @@ bool codegen_emit(jitdata *jd)
                                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);
                                }
                        }
 
@@ -1663,7 +1663,7 @@ bool codegen_emit(jitdata *jd)
                                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;
@@ -1719,7 +1719,7 @@ bool codegen_emit(jitdata *jd)
                                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);
                        }
 
 
@@ -1753,7 +1753,7 @@ bool codegen_emit(jitdata *jd)
 
 #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 */
@@ -1926,7 +1926,7 @@ bool codegen_emit(jitdata *jd)
 
 #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 */
@@ -2202,7 +2202,7 @@ gen_method:
                                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);
@@ -2221,7 +2221,7 @@ gen_method:
                                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]) +
@@ -2244,7 +2244,7 @@ gen_method:
 
                        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;
@@ -2333,7 +2333,7 @@ gen_method:
                                        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);
@@ -2348,7 +2348,7 @@ gen_method:
 
                                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);
@@ -2381,7 +2381,7 @@ gen_method:
                                                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 {
@@ -2436,7 +2436,7 @@ gen_method:
 
                                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 {
@@ -2509,7 +2509,7 @@ gen_method:
                                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);
@@ -2521,7 +2521,7 @@ gen_method:
 
                        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);
 
@@ -2556,7 +2556,7 @@ gen_method:
                                        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);
 
@@ -2628,7 +2628,7 @@ gen_method:
                        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);
@@ -2673,9 +2673,9 @@ gen_method:
 
        dseg_createlinenumbertable(cd);
 
-       /* generate stubs */
+       /* generate traps */
 
-       emit_patcher_stubs(jd);
+       emit_patcher_traps(jd);
 
        /* everything's ok */
 
@@ -2775,7 +2775,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        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 */
 
@@ -2972,9 +2972,9 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f)
        M_MTCTR(REG_ITMP3);
        M_RTS;
 
-       /* generate patcher stub call code */
+       /* generate patcher traps */
 
-       emit_patcher_stubs(jd);
+       emit_patcher_traps(jd);
 }
 
 
index 58b8b31fc177c05b18dd22ec0e698c8b9e09f61c..b8146ad5b4d5aaced88b27cd87df7fa88a10eeb3 100644 (file)
@@ -669,109 +669,6 @@ void emit_exception_check(codegendata *cd, instruction *iptr)
 }
 
 
-/* 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.
@@ -787,7 +684,8 @@ uint32_t emit_trap(codegendata *cd)
 
        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;
 }
index 3e62f609598ae29371a409dc0d70b8dea04934d8..f1f632f16dfa64888d0a7f57d1a3b2af9672589f 100644 (file)
@@ -118,9 +118,13 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        stacktrace_remove_stackframeinfo(&sfi);
 
-       _mc->gp_regs[REG_ITMP1]     = (intptr_t) p;
-       _mc->gp_regs[REG_ITMP2_XPC] = (intptr_t) xpc;
-       _mc->gp_regs[PT_NIP]        = (intptr_t) asm_handle_exception;
+       /* set registers (only if exception object ready) */
+
+       if (p != NULL) {
+               _mc->gp_regs[REG_ITMP1]     = (intptr_t) p;
+               _mc->gp_regs[REG_ITMP2_XPC] = (intptr_t) xpc;
+               _mc->gp_regs[PT_NIP]        = (intptr_t) asm_handle_exception;
+       }
 }
 
 
index 0a5a274b439ab4cba0c5a3d626f9ef0560a7ca87..d480039831125d806cefe1b8242132d39abb2092 100644 (file)
@@ -43,7 +43,7 @@
 #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:
@@ -135,22 +63,20 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
 
 *******************************************************************************/
 
-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 */
 
@@ -173,11 +99,11 @@ bool patcher_get_putstatic(u1 *sp)
 
        /* 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;
 }
@@ -192,18 +118,16 @@ bool patcher_get_putstatic(u1 *sp)
 
 *******************************************************************************/
 
-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 */
 
@@ -214,6 +138,10 @@ bool patcher_get_putfield(u1 *sp)
 
        *((u4 *) ra) = mcode;
 
+       /* synchronize instruction cache */
+
+       md_icacheflush(ra, 4);
+
        /* if we show disassembly, we have to skip the nop */
 
        if (opt_shownops)
@@ -231,169 +159,6 @@ bool patcher_get_putfield(u1 *sp)
 }
 
 
-/* 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:
@@ -405,22 +170,20 @@ bool patcher_builtin_arraycheckcast(u1 *sp)
 
 ******************************************************************************/
 
-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 */
 
@@ -437,11 +200,11 @@ bool patcher_invokestatic_special(u1 *sp)
 
        /* 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;
 }
@@ -459,7 +222,7 @@ bool patcher_invokestatic_special(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_invokevirtual(u1 *sp)
+bool patcher_invokevirtual(patchref_t *pr)
 {
        u1                *ra;
        u4                 mcode;
@@ -469,9 +232,9 @@ bool patcher_invokevirtual(u1 *sp)
 
        /* 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 */
 
@@ -482,6 +245,10 @@ bool patcher_invokevirtual(u1 *sp)
 
        *((u4 *) ra) = mcode;
 
+       /* synchronize instruction cache */
+
+       md_icacheflush(ra, 4);
+
        /* if we show disassembly, we have to skip the nop */
 
        if (opt_shownops)
@@ -514,7 +281,7 @@ bool patcher_invokevirtual(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_invokeinterface(u1 *sp)
+bool patcher_invokeinterface(patchref_t *pr)
 {
        u1                *ra;
        u4                 mcode;
@@ -524,9 +291,9 @@ bool patcher_invokeinterface(u1 *sp)
 
        /* 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 */
 
@@ -537,6 +304,10 @@ bool patcher_invokeinterface(u1 *sp)
 
        *((u4 *) ra) = mcode;
 
+       /* synchronize instruction cache */
+
+       md_icacheflush(ra, 4);
+
        /* if we show disassembly, we have to skip the nop */
 
        if (opt_shownops)
@@ -576,22 +347,20 @@ bool patcher_invokeinterface(u1 *sp)
 
 *******************************************************************************/
 
-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 */
 
@@ -608,11 +377,11 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
 
        /* 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;
 }
@@ -629,7 +398,7 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
    800c0000    lwz   r0,0(r12)
 
 *******************************************************************************/
-bool patcher_checkcast_interface(u1 *sp)
+bool patcher_checkcast_interface(patchref_t *pr)
 {
        u1 *ra;
        constant_classref *cr;
@@ -638,9 +407,9 @@ bool patcher_checkcast_interface(u1 *sp)
        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)))  {
@@ -650,10 +419,13 @@ bool patcher_checkcast_interface(u1 *sp)
        /* 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);
@@ -684,7 +456,7 @@ bool patcher_checkcast_interface(u1 *sp)
 
 *******************************************************************************/
 
-bool patcher_instanceof_interface(u1 *sp)
+bool patcher_instanceof_interface(patchref_t *pr)
 {
        u1                *ra;
        u4                 mcode;
@@ -694,9 +466,9 @@ bool patcher_instanceof_interface(u1 *sp)
 
        /* 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 */
 
@@ -707,6 +479,10 @@ bool patcher_instanceof_interface(u1 *sp)
 
        *((u4 *) ra) = mcode;
 
+       /* synchronize instruction cache */
+
+       md_icacheflush(ra, 4);
+
        /* if we show disassembly, we have to skip the nop */
 
        if (opt_shownops)
@@ -741,22 +517,20 @@ bool patcher_instanceof_interface(u1 *sp)
 
 *******************************************************************************/
 
-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 */
 
@@ -773,11 +547,11 @@ bool patcher_checkcast_class(u1 *sp)
 
        /* 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;
 }
@@ -813,21 +587,19 @@ bool patcher_checkcast_class(u1 *sp)
 
 *******************************************************************************/
 
-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 */
 
@@ -844,11 +616,11 @@ bool patcher_resolve_classref_to_classinfo(u1 *sp)
 
        /* 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;
 }
@@ -865,22 +637,20 @@ bool patcher_resolve_classref_to_classinfo(u1 *sp)
 
 *******************************************************************************/
 
-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 */
 
@@ -897,11 +667,11 @@ bool patcher_instanceof_class(u1 *sp)
 
        /* 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;
 }
@@ -924,21 +694,19 @@ bool patcher_instanceof_class(u1 *sp)
 
 *******************************************************************************/
 
-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 */
 
@@ -955,11 +723,11 @@ bool patcher_resolve_classref_to_vftbl(u1 *sp)
 
        /* 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;
 }
@@ -973,21 +741,19 @@ bool patcher_resolve_classref_to_vftbl(u1 *sp)
 
 *******************************************************************************/
 
-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 */
 
@@ -1004,22 +770,22 @@ bool patcher_resolve_classref_to_flags(u1 *sp)
 
        /* 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;
@@ -1027,9 +793,9 @@ bool patcher_clinit(u1 *sp)
 
        /* 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 */
 
@@ -1058,7 +824,7 @@ bool patcher_clinit(u1 *sp)
 *******************************************************************************/
 
 #ifdef ENABLE_VERIFIER
-bool patcher_athrow_areturn(u1 *sp)
+bool patcher_athrow_areturn(patchref_t *pr)
 {
        u1               *ra;
        u4                mcode;
@@ -1066,9 +832,9 @@ bool patcher_athrow_areturn(u1 *sp)
 
        /* 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 */
 
@@ -1088,28 +854,27 @@ bool patcher_athrow_areturn(u1 *sp)
 #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 */
 
@@ -1126,11 +891,11 @@ bool patcher_resolve_native(u1 *sp)
 
        /* 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;
 }