* src/vm/jit/x86_64/patcher.c (vm/jit/x86_64/codegen.h): Added.
authortwisti <none@none>
Mon, 17 Jul 2006 09:47:02 +0000 (09:47 +0000)
committertwisti <none@none>
Mon, 17 Jul 2006 09:47:02 +0000 (09:47 +0000)
(vm/exceptions.h): Likewise.
(patcher_get_putstatic): Removed monitor enter/exit and return address
calculation, this is now done by the wrapper.
(patcher_get_putfield): Likewise.
(patcher_putfieldconst): Likewise.
(patcher_aconst): Likewise.
(patcher_builtin_multianewarray): Likewise.
(patcher_builtin_arraycheckcast): Likewise.
(patcher_invokestatic_special): Likewise.
(patcher_invokevirtual): Likewise.
(patcher_invokeinterface): Likewise.
(patcher_checkcast_instanceof_flags): Likewise.
(patcher_checkcast_instanceof_interface): Likewise.
(patcher_checkcast_class): Likewise.
(patcher_instanceof_class): Likewise.
(patcher_clinit): Likewise.
(patcher_athrow_areturn): Likewise.
(patcher_resolve_native): Likewise.

* src/vm/jit/x86_64/asmpart.S (asm_wrapper_patcher): Use
patcher_wrapper.

src/vm/jit/x86_64/asmpart.S
src/vm/jit/x86_64/patcher.c

index 19537200e4befe31aec2acbfec165a651fc55f7f..53d2e00c9dab4473050338e54ebac265bb385df7 100644 (file)
@@ -30,7 +30,7 @@
 
    Changes: Edwin Steiner
 
-   $Id: asmpart.S 5110 2006-07-11 22:23:55Z twisti $
+   $Id: asmpart.S 5142 2006-07-17 09:47:02Z twisti $
 
 */
 
@@ -539,25 +539,13 @@ asm_wrapper_patcher:
        mov     itmp1,0*8(sp)               /* save itmp1 and itmp2               */
        mov     itmp2,1*8(sp)               /* can be used by some instructions   */
 
-       mov     sp,a0                       /* create stackframe info             */
-       add     $((3+ARG_CNT+TMP_CNT)*8),a0
-       xor     a1,a1                       /* if pv is NULL, use findmethod      */
-       mov     bp,a2                       /* pass java sp                       */
-       add     $((6+1)*8),a2
-       mov     ((5+1)*8)(bp),a3            /* pass ra to java function           */
-       mov     a3,a4                       /* xpc is equal to ra                 */
-       call    stacktrace_create_extern_stackframeinfo@PLT
-
-       mov     bp,a0                       /* pass stack pointer                 */
-       add     $((1+1)*8),a0               /* skip function pointer              */
-       mov     1*8(bp),itmp3               /* get function pointer               */
-       call    *itmp3                      /* call the patcher function          */
+       mov     bp,a0                       /* pass SP of patcher stub            */
+       add     $(1*8),a0
+       mov     $0,a1                       /* pass PV (if NULL, use findmethod)  */
+       mov     $0,a2                       /* pass RA (it's on the stack)        */
+       call    patcher_wrapper@PLT
        mov     v0,2*8(sp)                  /* save return value                  */
 
-       mov     sp,a0                       /* remove stackframe info             */
-       add     $((3+ARG_CNT+TMP_CNT)*8),a0
-       call    stacktrace_remove_stackframeinfo@PLT
-
        RESTORE_ARGUMENT_REGISTERS(3)
        RESTORE_TEMPORARY_REGISTERS(3+ARG_CNT)
 
@@ -567,14 +555,14 @@ asm_wrapper_patcher:
 
        mov     bp,sp                       /* restore original sp                */
        pop     bp                          /* restore bp                         */
-       add     $(5*8),sp                   /* remove patcher stackframe, keep ra */
+       add     $(5*8),sp                   /* remove patcher stackframe, keep RA */
 
        test    itmp3,itmp3                 /* exception thrown?                  */
-       j     L_asm_wrapper_patcher_exception
+       jne     L_asm_wrapper_patcher_exception
        ret                                 /* call new patched code              */
 
 L_asm_wrapper_patcher_exception:
-       call    exceptions_get_and_clear_exception@PLT
+       mov     itmp3,xptr                  /* get exception                      */
        pop     xpc                         /* get and remove return address      */
        jmp     L_asm_handle_exception
 
index 08ad6493dea5c8de1da642b4bc40135bc2523b0b..ce9df0711b5a579756c6115699e9797962ace2e0 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: patcher.c 4530 2006-02-21 09:11:53Z twisti $
+   $Id: patcher.c 5142 2006-07-17 09:47:02Z twisti $
 
 */
 
 #include "config.h"
 #include "vm/types.h"
 
+#include "vm/jit/x86_64/codegen.h"
+
 #include "mm/memory.h"
 #include "native/native.h"
 #include "vm/builtin.h"
 #include "vm/class.h"
+#include "vm/exceptions.h"
 #include "vm/field.h"
 #include "vm/initialize.h"
 #include "vm/options.h"
 #include "vm/jit/patcher.h"
 
 
-/* patcher_get_putstatic *******************************************************
+/* patcher_wrapper *************************************************************
 
-   Machine code:
+   Wrapper for all patchers.  It also creates the stackframe info
+   structure.
 
-   <patched call position>
-   4d 8b 15 86 fe ff ff             mov    -378(%rip),%r10
-   49 8b 32                         mov    (%r10),%rsi
+   If the return value of the patcher function is false, it gets the
+   exception object, clears the exception pointer and returns the
+   exception.
 
 *******************************************************************************/
 
-bool patcher_get_putstatic(u1 *sp)
+java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
 {
-       u1                *ra;
+       stackframeinfo     sfi;
+       u1                *xpc;
        java_objectheader *o;
-       u8                 mcode;
-       unresolved_field  *uf;
-       s4                 disp;
-       fieldinfo         *fi;
-       s4                 offset;
+       functionptr        f;
+       bool               result;
+       java_objectheader *e;
+
+       /* define the patcher function */
+
+       bool (*patcher_function)(u1 *);
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       uf    = (unresolved_field *)  *((ptrint *) (sp + 1 * 8));
-       disp  =                       *((s4 *)     (sp + 0 * 8));
+       xpc = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       o   = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
+       f   = (functionptr)         *((ptrint *) (sp + 0 * 8));
 
        /* calculate and set the new return address */
 
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
+       xpc = xpc - PATCHER_CALL_SIZE;
+
+       *((ptrint *) (sp + 5 * 8)) = (ptrint) xpc;
+
+       /* cast the passed function to a patcher function */
+
+       patcher_function = (bool (*)(u1 *)) (ptrint) f;
+
+       /* enter a monitor on the patching position */
 
        PATCHER_MONITORENTER;
 
-       /* get the fieldinfo */
+       /* create the stackframeinfo */
+
+       /* RA is passed as NULL, but the XPC is correct and can be used in
+          stacktrace_create_extern_stackframeinfo for
+          md_codegen_findmethod. */
+
+       stacktrace_create_extern_stackframeinfo(&sfi, pv, sp + 6 * 8, xpc, 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();
 
-       if (!(fi = resolve_field_eager(uf))) {
                PATCHER_MONITOREXIT;
 
-               return false;
+               return e;
        }
 
-       /* check if the field's class is initialized */
+       PATCHER_MARK_PATCHED_MONITOREXIT;
+
+       return NULL;
+}
 
-       if (!(fi->class->state & CLASS_INITIALIZED)) {
-               if (!initialize_class(fi->class)) {
-                       PATCHER_MONITOREXIT;
 
+/* patcher_get_putstatic *******************************************************
+
+   Machine code:
+
+   <patched call position>
+   4d 8b 15 86 fe ff ff             mov    -378(%rip),%r10
+   49 8b 32                         mov    (%r10),%rsi
+
+*******************************************************************************/
+
+bool patcher_get_putstatic(u1 *sp)
+{
+       u1               *ra;
+       u8                mcode;
+       unresolved_field *uf;
+       s4                disp;
+       fieldinfo        *fi;
+       s4                offset;
+
+       /* get stuff from the stack */
+
+       ra    = (u1 *)               *((ptrint *) (sp + 5 * 8));
+       mcode =                      *((u8 *)     (sp + 3 * 8));
+       uf    = (unresolved_field *) *((ptrint *) (sp + 2 * 8));
+       disp  =                      *((s4 *)     (sp + 1 * 8));
+
+       /* get the fieldinfo */
+
+       if (!(fi = resolve_field_eager(uf)))
+               return false;
+
+       /* check if the field's class is initialized */
+
+       if (!(fi->class->state & CLASS_INITIALIZED))
+               if (!initialize_class(fi->class))
                        return false;
-               }
-       }
 
        /* patch back original code */
 
@@ -118,8 +181,6 @@ bool patcher_get_putstatic(u1 *sp)
 
        *((ptrint *) (ra + 7 + offset)) = (ptrint) &(fi->value);
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -135,34 +196,22 @@ bool patcher_get_putstatic(u1 *sp)
 
 bool patcher_get_putfield(u1 *sp)
 {
-       u1                *ra;
-       java_objectheader *o;
-       u8                 mcode;
-       unresolved_field  *uf;
-       fieldinfo         *fi;
-       u1                 byte;
+       u1               *ra;
+       u8                mcode;
+       unresolved_field *uf;
+       fieldinfo        *fi;
+       u1                byte;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       uf    = (unresolved_field *)  *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)               *((ptrint *) (sp + 5 * 8));
+       mcode =                      *((u8 *)     (sp + 3 * 8));
+       uf    = (unresolved_field *) *((ptrint *) (sp + 2 * 8));
 
        /* get the fieldinfo */
 
-       if (!(fi = resolve_field_eager(uf))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(fi = resolve_field_eager(uf)))
                return false;
-       }
 
        /* patch back original code (instruction code is smaller than 8 bytes) */
 
@@ -186,8 +235,8 @@ bool patcher_get_putfield(u1 *sp)
                        *((u4 *) (ra + 4)) = (u4) (fi->offset);
                else
                        *((u4 *) (ra + 3)) = (u4) (fi->offset);
-
-       else {
+       }
+       else {
                /* check for special case: %rsp or %r12 as base register */
 
                byte = *(ra + 5);
@@ -198,8 +247,6 @@ bool patcher_get_putfield(u1 *sp)
                        *((u4 *) (ra + 5)) = (u4) (fi->offset);
        }
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -215,33 +262,21 @@ bool patcher_get_putfield(u1 *sp)
 
 bool patcher_putfieldconst(u1 *sp)
 {
-       u1                *ra;
-       java_objectheader *o;
-       u8                 mcode;
-       unresolved_field  *uf;
-       fieldinfo         *fi;
+       u1               *ra;
+       u8                mcode;
+       unresolved_field *uf;
+       fieldinfo        *fi;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       uf    = (unresolved_field *)  *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)               *((ptrint *) (sp + 5 * 8));
+       mcode =                      *((u8 *)     (sp + 3 * 8));
+       uf    = (unresolved_field *) *((ptrint *) (sp + 2 * 8));
 
        /* get the fieldinfo */
 
-       if (!(fi = resolve_field_eager(uf))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(fi = resolve_field_eager(uf)))
                return false;
-       }
 
        /* patch back original code */
 
@@ -258,15 +293,15 @@ bool patcher_putfieldconst(u1 *sp)
                /* handle special case when the base register is %r12 */
 
                if (*(ra + 2) == 0x84) {
-                       *((u4 *) (ra + 4)) = (u4) (fi->offset);
+                       *((u4 *) (ra + 4))      = (u4) (fi->offset);
                        *((u4 *) (ra + 12 + 4)) = (u4) (fi->offset + 4);
-
-               else {
-                       *((u4 *) (ra + 3)) = (u4) (fi->offset);
+               }
+               else {
+                       *((u4 *) (ra + 3))      = (u4) (fi->offset);
                        *((u4 *) (ra + 11 + 3)) = (u4) (fi->offset + 4);
                }
-
-       else {
+       }
+       else {
                /* handle special case when the base register is %r12 */
 
                if (*(ra + 2) == 0x84)
@@ -275,8 +310,6 @@ bool patcher_putfieldconst(u1 *sp)
                        *((u4 *) (ra + 3)) = (u4) (fi->offset);
        }
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -293,32 +326,20 @@ bool patcher_putfieldconst(u1 *sp)
 bool patcher_aconst(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
        u8                 mcode;
        constant_classref *cr;
        classinfo         *c;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       cr    = (constant_classref *) *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u8 *)     (sp + 3 * 8));
+       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
 
        /* get the classinfo */
 
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(c = resolve_classref_eager(cr)))
                return false;
-       }
 
        /* patch back original code */
 
@@ -333,8 +354,6 @@ bool patcher_aconst(u1 *sp)
 
        *((ptrint *) (ra + 2)) = (ptrint) c;
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -355,32 +374,20 @@ bool patcher_aconst(u1 *sp)
 bool patcher_builtin_multianewarray(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
        u8                 mcode;
        constant_classref *cr;
        classinfo         *c;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       cr    = (constant_classref *) *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u8 *)     (sp + 3 * 8));
+       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
 
        /* get the classinfo */
 
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(c = resolve_classref_eager(cr)))
                return false;
-       }
 
        /* patch back original code */
 
@@ -399,8 +406,6 @@ bool patcher_builtin_multianewarray(u1 *sp)
 
        *((ptrint *) (ra + 10 + 10 + 3 + 2)) = (ptrint) BUILTIN_multianewarray;
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -419,32 +424,20 @@ bool patcher_builtin_multianewarray(u1 *sp)
 bool patcher_builtin_arraycheckcast(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
        u8                 mcode;
        constant_classref *cr;
        classinfo         *c;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       cr    = (constant_classref *) *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u8 *)     (sp + 3 * 8));
+       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
 
        /* get the classinfo */
 
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(c = resolve_classref_eager(cr)))
                return false;
-       }
 
        /* patch back original code */
 
@@ -459,8 +452,6 @@ bool patcher_builtin_arraycheckcast(u1 *sp)
 
        *((ptrint *) (ra + 2)) = (ptrint) c;
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -478,32 +469,21 @@ bool patcher_builtin_arraycheckcast(u1 *sp)
 bool patcher_invokestatic_special(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
        u8                 mcode;
        unresolved_method *um;
        methodinfo        *m;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       um    = (unresolved_method *) *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u8 *)     (sp + 3 * 8));
+       um    = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
 
        /* get the fieldinfo */
 
-       if (!(m = resolve_method_eager(um))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(m = resolve_method_eager(um)))
                return false;
-       }
+
        /* patch back original code */
 
        *((u8 *) ra) = mcode;
@@ -517,8 +497,6 @@ bool patcher_invokestatic_special(u1 *sp)
 
        *((ptrint *) (ra + 2)) = (ptrint) m->stubroutine;
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -537,32 +515,20 @@ bool patcher_invokestatic_special(u1 *sp)
 bool patcher_invokevirtual(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
        u8                 mcode;
        unresolved_method *um;
        methodinfo        *m;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       um    = (unresolved_method *) *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u8 *)     (sp + 3 * 8));
+       um    = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
 
        /* get the fieldinfo */
 
-       if (!(m = resolve_method_eager(um))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(m = resolve_method_eager(um)))
                return false;
-       }
 
        /* patch back original code */
 
@@ -578,8 +544,6 @@ bool patcher_invokevirtual(u1 *sp)
        *((s4 *) (ra + 3 + 3)) = (s4) (OFFSET(vftbl_t, table[0]) +
                                                                   sizeof(methodptr) * m->vftblindex);
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -599,32 +563,20 @@ bool patcher_invokevirtual(u1 *sp)
 bool patcher_invokeinterface(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
        u8                 mcode;
        unresolved_method *um;
        methodinfo        *m;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       um    = (unresolved_method *) *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u8 *)     (sp + 3 * 8));
+       um    = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
 
        /* get the fieldinfo */
 
-       if (!(m = resolve_method_eager(um))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(m = resolve_method_eager(um)))
                return false;
-       }
 
        /* patch back original code */
 
@@ -645,8 +597,6 @@ bool patcher_invokeinterface(u1 *sp)
        *((s4 *) (ra + 3 + 7 + 3)) =
                (s4) (sizeof(methodptr) * (m - m->class->methods));
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -665,32 +615,20 @@ bool patcher_invokeinterface(u1 *sp)
 bool patcher_checkcast_instanceof_flags(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
        u8                 mcode;
        constant_classref *cr;
        classinfo         *c;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       cr    = (constant_classref *) *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u8 *)     (sp + 3 * 8));
+       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
 
        /* get the fieldinfo */
 
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(c = resolve_classref_eager(cr)))
                return false;
-       }
 
        /* patch back original code */
 
@@ -705,8 +643,6 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
 
        *((s4 *) (ra + 2)) = (s4) c->flags;
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -727,32 +663,20 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
 bool patcher_checkcast_instanceof_interface(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
        u8                 mcode;
        constant_classref *cr;
        classinfo         *c;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       cr    = (constant_classref *) *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u8 *)     (sp + 3 * 8));
+       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
 
        /* get the fieldinfo */
 
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(c = resolve_classref_eager(cr)))
                return false;
-       }
 
        /* patch back original code */
 
@@ -771,8 +695,6 @@ bool patcher_checkcast_instanceof_interface(u1 *sp)
                (s4) (OFFSET(vftbl_t, interfacetable[0]) -
                          c->index * sizeof(methodptr*));
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -793,32 +715,20 @@ bool patcher_checkcast_instanceof_interface(u1 *sp)
 bool patcher_checkcast_class(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
        u8                 mcode;
        constant_classref *cr;
        classinfo         *c;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       cr    = (constant_classref *) *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u8 *)     (sp + 3 * 8));
+       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
 
        /* get the fieldinfo */
 
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(c = resolve_classref_eager(cr)))
                return false;
-       }
 
        /* patch back original code */
 
@@ -834,8 +744,6 @@ bool patcher_checkcast_class(u1 *sp)
        *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
        *((ptrint *) (ra + 10 + 7 + 7 + 3 + 2)) = (ptrint) c->vftbl;
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -852,32 +760,20 @@ bool patcher_checkcast_class(u1 *sp)
 bool patcher_instanceof_class(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
        u8                 mcode;
        constant_classref *cr;
        classinfo         *c;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       cr    = (constant_classref *) *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       mcode =                       *((u8 *)     (sp + 3 * 8));
+       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
 
        /* get the fieldinfo */
 
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(c = resolve_classref_eager(cr)))
                return false;
-       }
 
        /* patch back original code */
 
@@ -892,8 +788,6 @@ bool patcher_instanceof_class(u1 *sp)
 
        *((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -912,41 +806,26 @@ bool patcher_instanceof_class(u1 *sp)
 
 bool patcher_clinit(u1 *sp)
 {
-       u1                *ra;
-       java_objectheader *o;
-       u8                 mcode;
-       classinfo         *c;
+       u1        *ra;
+       u8         mcode;
+       classinfo *c;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       c     = (classinfo *)         *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)        *((ptrint *) (sp + 5 * 8));
+       mcode =               *((u8 *)     (sp + 3 * 8));
+       c     = (classinfo *) *((ptrint *) (sp + 2 * 8));
 
        /* check if the class is initialized */
 
-       if (!(c->state & CLASS_INITIALIZED)) {
-               if (!initialize_class(c)) {
-                       PATCHER_MONITOREXIT;
-
+       if (!(c->state & CLASS_INITIALIZED))
+               if (!initialize_class(c))
                        return false;
-               }
-       }
 
        /* patch back original code */
 
        *((u8 *) ra) = mcode;
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -962,40 +841,26 @@ bool patcher_clinit(u1 *sp)
 #ifdef ENABLE_VERIFIER
 bool patcher_athrow_areturn(u1 *sp)
 {
-       u1                *ra;
-       java_objectheader *o;
-       u8                 mcode;
-       unresolved_class  *uc;
-       classinfo         *c;
+       u1               *ra;
+       u8                mcode;
+       unresolved_class *uc;
+       classinfo        *c;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       uc    = (unresolved_class *)  *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)               *((ptrint *) (sp + 5 * 8));
+       mcode =                      *((u8 *)     (sp + 3 * 8));
+       uc    = (unresolved_class *) *((ptrint *) (sp + 2 * 8));
 
        /* resolve the class */
 
-       if (!resolve_class(uc, resolveEager, false, &c)) {
-               PATCHER_MONITOREXIT;
-
+       if (!resolve_class(uc, resolveEager, false, &c))
                return false;
-       }
 
        /* patch back original code */
 
        *((u8 *) ra) = mcode;
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 #endif /* ENABLE_VERIFIER */
@@ -1014,33 +879,21 @@ bool patcher_athrow_areturn(u1 *sp)
 #if !defined(WITH_STATIC_CLASSPATH)
 bool patcher_resolve_native(u1 *sp)
 {
-       u1                *ra;
-       java_objectheader *o;
-       u8                 mcode;
-       methodinfo        *m;
-       functionptr        f;
+       u1          *ra;
+       u8           mcode;
+       methodinfo  *m;
+       functionptr  f;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 4 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 3 * 8));
-       mcode =                       *((u8 *)     (sp + 2 * 8));
-       m     = (methodinfo *)        *((ptrint *) (sp + 1 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 5;
-       *((ptrint *) (sp + 4 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       ra    = (u1 *)         *((ptrint *) (sp + 5 * 8));
+       mcode =                *((u8 *)     (sp + 3 * 8));
+       m     = (methodinfo *) *((ptrint *) (sp + 2 * 8));
 
        /* resolve native function */
 
-       if (!(f = native_resolve_function(m))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(f = native_resolve_function(m)))
                return false;
-       }
 
        /* patch back original code */
 
@@ -1055,8 +908,6 @@ bool patcher_resolve_native(u1 *sp)
 
        *((ptrint *) (ra + 2)) = (ptrint) f;
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 #endif /* !defined(WITH_STATIC_CLASSPATH) */