* src/vm/jit/x86_64/emit.c (emit_load): Changed to new variable
[cacao.git] / src / vm / jit / alpha / patcher.c
index df544fed1b4d5be38a5408510567b5f1b27ee923..a6308c7bc4f5495fbd8f2b5dd7a2928d1c9bfbbe 100644 (file)
@@ -1,9 +1,9 @@
 /* src/vm/jit/alpha/patcher.c - Alpha code patching functions
 
-   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
 
    This file is part of CACAO.
 
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
+   Contact: cacao@cacaojvm.org
 
    Authors: Christian Thalinger
 
    Changes:
 
-   $Id: patcher.c 3633 2005-11-08 10:58:04Z twisti $
+   $Id: patcher.c 5290 2006-09-04 17:12:48Z christian $
 
 */
 
 
 #include "config.h"
+
+#include <assert.h>
+
 #include "vm/types.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/resolve.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/patcher.h"
+#include "vm/jit/methodheader.h"
 
 
-/* patcher_get_putstatic *******************************************************
+/* patcher_wrapper *************************************************************
 
-   Machine code:
+   Wrapper for all patchers.  It also creates the stackframe info
+   structure.
 
-   <patched call position>
-   a73bff98    ldq     t11,-104(pv)
-   a2590000    ldl     a2,0(t11)
+   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;
        u4                 mcode;
-       unresolved_field  *uf;
-       s4                 disp;
-       u1                *pv;
-       fieldinfo         *fi;
+       functionptr        f;
+       bool               result;
+       java_objectheader *e;
+
+       /* define the patcher function */
+
+       bool (*patcher_function)(u1 *);
+
+       assert(pv != NULL);
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
+       xpc   = (u1 *)                *((ptrint *) (sp + 5 * 8));
        o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
-       uf    = (unresolved_field *)  *((ptrint *) (sp + 2 * 8));
-       disp  =                       *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
+       f     = (functionptr)         *((ptrint *) (sp + 0 * 8));
 
        /* calculate and set the new return address */
 
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
+       xpc = xpc - 1 * 4;
+
+       *((ptrint *) (sp + 5 * 8)) = (ptrint) xpc;
+
+       /* 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;
 
-       /* get the fieldinfo */
+       /* create the stackframeinfo */
 
-       if (!(fi = resolve_field_eager(uf))) {
-               PATCHER_MONITOREXIT;
+       stacktrace_create_extern_stackframeinfo(&sfi, pv, sp + 6 * 8, ra, xpc);
 
-               return false;
-       }
+       /* call the proper patcher function */
 
-       /* check if the field's class is initialized */
+       result = (patcher_function)(sp);
 
-       if (!fi->class->initialized) {
-               if (!initialize_class(fi->class)) {
-                       PATCHER_MONITOREXIT;
+       /* remove the stackframeinfo */
 
-                       return false;
-               }
+       stacktrace_remove_stackframeinfo(&sfi);
+
+       /* check for an error, get the exception and return it */
+
+       if (result == false) {
+               e = exceptions_get_and_clear_exception();
+
+               PATCHER_MONITOREXIT;
+
+               return e;
        }
 
        /* patch back original code */
 
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
+       mcode = *((u4 *) (sp + 3 * 8));
 
-       asm_sync_instruction_cache();
+       *((u4 *) xpc) = mcode;
 
-       /* patch the field value's address */
+       /* synchronize instruction cache */
 
-       *((ptrint *) (pv + disp)) = (ptrint) &(fi->value);
+       md_icacheflush(NULL, 0);
 
        PATCHER_MARK_PATCHED_MONITOREXIT;
 
-       return true;
+       return NULL;
 }
 
+/* patcher_initialize_class ****************************************************
 
-/* patcher_get_putfield ********************************************************
-
-   Machine code:
-
-   <patched call position>
-   a2af0020    ldl     a5,32(s6)
+   Initalizes a given classinfo pointer.  This function does not patch
+   any data.
 
 *******************************************************************************/
 
-bool patcher_get_putfield(u1 *sp)
+bool patcher_initialize_class(u1 *sp)
 {
-       u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
-       unresolved_field  *uf;
-       fieldinfo         *fi;
-
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
-       uf    = (unresolved_field *)  *((ptrint *) (sp + 2 * 8));
-
-       /* calculate and set the new return address */
+       classinfo *c;
 
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
+       /* get stuff from the stack */
 
-       /* get the fieldinfo */
+       c = (classinfo *) *((ptrint *) (sp + 2 * 8));
 
-       if (!(fi = resolve_field_eager(uf))) {
-               PATCHER_MONITOREXIT;
+       /* check if the class is initialized */
 
-               return false;
-       }
+       if (!(c->state & CLASS_INITIALIZED))
+               if (!initialize_class(c))
+                       return false;
 
-       /* patch back original code */
+       return true;
+}
 
-       *((u4 *) ra) = mcode;
+/* patcher_resolve_class *****************************************************
 
-       /* if we show disassembly, we have to skip the nop */
+   Initalizes a given classinfo pointer.  This function does not patch
+   any data.
 
-       if (opt_showdisassemble)
-               ra = ra + 4;
+*******************************************************************************/
 
-       /* patch the field's offset */
+#ifdef ENABLE_VERIFIER
+bool patcher_resolve_class(u1 *sp)
+{
+       unresolved_class *uc;
+       classinfo        *c;
 
-       *((u4 *) ra) |= (s2) (fi->offset & 0x0000ffff);
+       /* get stuff from the stack */
 
-       /* synchronize instruction cache */
+       uc = (unresolved_class *)  *((ptrint *) (sp + 2 * 8));
 
-       asm_sync_instruction_cache();
+       /* resolve the class */
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
+       if (!resolve_class(uc, resolveEager, false, &c))
+               return false;
 
        return true;
 }
+#endif /* ENABLE_VERIFIER */
 
 
-/* patcher_aconst **************************************************************
+/* patcher_resolve_classref_to_classinfo ***************************************
 
-   Machine code:
+   ACONST:
 
    <patched call postition>
    a61bff80    ldq     a0,-128(pv)
 
+   MULTIANEWARRAY:
+
+   <patched call position>
+   a63bff80    ldq     a1,-128(pv)
+   47de0412    mov     sp,a2
+   a77bff78    ldq     pv,-136(pv)
+   6b5b4000    jsr     (pv)
+
+   ARRAYCHECKCAST:
+
+   <patched call position>
+   a63bfe60    ldq     a1,-416(pv)
+   a77bfe58    ldq     pv,-424(pv)
+   6b5b4000    jsr     (pv)
+
 *******************************************************************************/
 
-bool patcher_aconst(u1 *sp)
+bool patcher_resolve_classref_to_classinfo(u1 *sp)
 {
-       u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
        constant_classref *cr;
        s4                 disp;
        u1                *pv;
@@ -201,63 +226,70 @@ bool patcher_aconst(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
        cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
        disp  =                       *((s4 *)     (sp + 1 * 8));
        pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
 
-       /* calculate and set the new return address */
+       /* get the classinfo */
 
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
+       if (!(c = resolve_classref_eager(cr)))
+               return false;
 
-       PATCHER_MONITORENTER;
+       /* patch the classinfo pointer */
 
-       /* get the classinfo */
+       *((ptrint *) (pv + disp)) = (ptrint) c;
 
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
+       return true;
+}
 
-               return false;
-       }
 
-       /* patch back original code */
+/* patcher_resolve_classref_to_vftbl *******************************************
 
-       *((u4 *) ra) = mcode;
+   CHECKCAST (class):
+   INSTANCEOF (class):
 
-       /* synchronize instruction cache */
+   <patched call position>
+   a7940000    ldq     at,0(a4)
+   a7bbff28    ldq     gp,-216(pv)
 
-       asm_sync_instruction_cache();
+*******************************************************************************/
 
-       /* patch the classinfo pointer */
+bool patcher_resolve_classref_to_vftbl(u1 *sp)
+{
+       constant_classref *cr;
+       s4                 disp;
+       u1                *pv;
+       classinfo         *c;
 
-       *((ptrint *) (pv + disp)) = (ptrint) c;
+       /* get stuff from the stack */
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
+       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
+       disp  =                       *((s4 *)     (sp + 1 * 8));
+       pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
+
+       /* get the fieldinfo */
+
+       if (!(c = resolve_classref_eager(cr)))
+               return false;
+
+       /* patch super class' vftbl */
+
+       *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
 
        return true;
 }
 
 
-/* patcher_builtin_multianewarray **********************************************
+/* patcher_resolve_classref_to_flags *******************************************
 
-   Machine code:
+   CHECKCAST/INSTANCEOF:
 
    <patched call position>
-   a63bff80    ldq     a1,-128(pv)
-   47de0412    mov     sp,a2
-   a77bff78    ldq     pv,-136(pv)
-   6b5b4000    jsr     (pv)
 
 *******************************************************************************/
 
-bool patcher_builtin_multianewarray(u1 *sp)
+bool patcher_resolve_classref_to_flags(u1 *sp)
 {
-       u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
        constant_classref *cr;
        s4                 disp;
        u1                *pv;
@@ -265,104 +297,134 @@ bool patcher_builtin_multianewarray(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
        cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
        disp  =                       *((s4 *)     (sp + 1 * 8));
        pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
 
-       /* calculate and set the new return address */
+       /* get the fieldinfo */
 
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
+       if (!(c = resolve_classref_eager(cr)))
+               return false;
 
-       PATCHER_MONITORENTER;
+       /* patch class flags */
 
-       /* get the classinfo */
+       *((s4 *) (pv + disp)) = (s4) c->flags;
 
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
+       return true;
+}
 
-               return false;
-       }
 
-       /* patch back original code */
+/* patcher_resolve_native_function *********************************************
 
-       *((u4 *) ra) = mcode;
+   XXX
 
-       /* synchronize instruction cache */
+*******************************************************************************/
 
-       asm_sync_instruction_cache();
+#if !defined(WITH_STATIC_CLASSPATH)
+bool patcher_resolve_native_function(u1 *sp)
+{
+       methodinfo  *m;
+       s4           disp;
+       u1          *pv;
+       functionptr  f;
 
-       /* patch the classinfo pointer */
+       /* get stuff from the stack */
 
-       *((ptrint *) (pv + disp)) = (ptrint) c;
+       m     = (methodinfo *) *((ptrint *) (sp + 2 * 8));
+       disp  =                *((s4 *)     (sp + 1 * 8));
+       pv    = (u1 *)         *((ptrint *) (sp + 0 * 8));
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
+       /* resolve native function */
+
+       if (!(f = native_resolve_function(m)))
+               return false;
+
+       /* patch native function pointer */
+
+       *((ptrint *) (pv + disp)) = (ptrint) f;
 
        return true;
 }
+#endif /* !defined(WITH_STATIC_CLASSPATH) */
 
 
-/* patcher_builtin_arraycheckcast **********************************************
+/* patcher_get_putstatic *******************************************************
 
    Machine code:
 
    <patched call position>
-   a63bfe60    ldq     a1,-416(pv)
-   a77bfe58    ldq     pv,-424(pv)
-   6b5b4000    jsr     (pv)
+   a73bff98    ldq     t11,-104(pv)
+   a2590000    ldl     a2,0(t11)
 
 *******************************************************************************/
 
-bool patcher_builtin_arraycheckcast(u1 *sp)
+bool patcher_get_putstatic(u1 *sp)
 {
-       u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
-       constant_classref *cr;
-       s4                 disp;
-       u1                *pv;
-       classinfo         *c;
+       unresolved_field *uf;
+       s4                disp;
+       u1               *pv;
+       fieldinfo        *fi;
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
-       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
-       disp  =                       *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
+       uf    = (unresolved_field *) *((ptrint *) (sp + 2 * 8));
+       disp  =                      *((s4 *)     (sp + 1 * 8));
+       pv    = (u1 *)               *((ptrint *) (sp + 0 * 8));
 
-       /* calculate and set the new return address */
+       /* get the fieldinfo */
 
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
+       if (!(fi = resolve_field_eager(uf)))
+               return false;
 
-       PATCHER_MONITORENTER;
+       /* check if the field's class is initialized */
 
-       /* get the classinfo */
+       if (!(fi->class->state & CLASS_INITIALIZED))
+               if (!initialize_class(fi->class))
+                       return false;
 
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
+       /* patch the field value's address */
 
-               return false;
-       }
+       *((ptrint *) (pv + disp)) = (ptrint) &(fi->value);
 
-       /* patch back original code */
+       return true;
+}
 
-       *((u4 *) ra) = mcode;
 
-       /* synchronize instruction cache */
+/* patcher_get_putfield ********************************************************
 
-       asm_sync_instruction_cache();
+   Machine code:
 
-       /* patch the classinfo pointer */
+   <patched call position>
+   a2af0020    ldl     a5,32(s6)
 
-       *((ptrint *) (pv + disp)) = (ptrint) c;
+*******************************************************************************/
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
+bool patcher_get_putfield(u1 *sp)
+{
+       u1               *ra;
+       unresolved_field *uf;
+       fieldinfo        *fi;
+
+       ra    = (u1 *)               *((ptrint *) (sp + 5 * 8));
+       uf    = (unresolved_field *) *((ptrint *) (sp + 2 * 8));
+
+       /* get the fieldinfo */
+
+       if (!(fi = resolve_field_eager(uf)))
+               return false;
+
+       /* if we show disassembly, we have to skip the nop */
+
+       if (opt_showdisassemble) {
+               /* patch the field's offset into the instruction */
+
+               *((u4 *) (ra + 4)) |= (s2) (fi->offset & 0x0000ffff);
+       }
+       else {
+               /* otherwise store the patched instruction on the stack */
+
+               *((u4 *) (sp + 3 * 8)) |= (s2) (fi->offset & 0x0000ffff);
+       }
 
        return true;
 }
@@ -380,9 +442,6 @@ bool patcher_builtin_arraycheckcast(u1 *sp)
 
 bool patcher_invokestatic_special(u1 *sp)
 {
-       u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
        unresolved_method *um;
        s4                 disp;
        u1                *pv;
@@ -390,42 +449,19 @@ bool patcher_invokestatic_special(u1 *sp)
 
        /* get stuff from the stack */
 
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
        um    = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
        disp  =                       *((s4 *)     (sp + 1 * 8));
        pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
-
        /* get the fieldinfo */
 
-       if (!(m = resolve_method_eager(um))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(m = resolve_method_eager(um)))
                return false;
-       }
-
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       asm_sync_instruction_cache();
 
        /* patch stubroutine */
 
        *((ptrint *) (pv + disp)) = (ptrint) m->stubroutine;
 
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -444,36 +480,18 @@ bool patcher_invokestatic_special(u1 *sp)
 bool patcher_invokevirtual(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
        unresolved_method *um;
        methodinfo        *m;
 
        /* get stuff from the stack */
 
        ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
        um    = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
-
-       /* get the fieldinfo */
-
-       if (!(m = resolve_method_eager(um))) {
-               PATCHER_MONITOREXIT;
+       /* get the fieldinfo */
 
+       if (!(m = resolve_method_eager(um)))
                return false;
-       }
-
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
 
        /* if we show disassembly, we have to skip the nop */
 
@@ -485,12 +503,6 @@ bool patcher_invokevirtual(u1 *sp)
        *((s4 *) (ra + 4)) |= (s4) ((OFFSET(vftbl_t, table[0]) +
                                                                 sizeof(methodptr) * m->vftblindex) & 0x0000ffff);
 
-       /* synchronize instruction cache */
-
-       asm_sync_instruction_cache();
-
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -510,36 +522,18 @@ bool patcher_invokevirtual(u1 *sp)
 bool patcher_invokeinterface(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
        unresolved_method *um;
        methodinfo        *m;
 
        /* get stuff from the stack */
 
        ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
        um    = (unresolved_method *) *((ptrint *) (sp + 2 * 8));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
-
        /* get the fieldinfo */
 
-       if (!(m = resolve_method_eager(um))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(m = resolve_method_eager(um)))
                return false;
-       }
-
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
 
        /* if we show disassembly, we have to skip the nop */
 
@@ -556,72 +550,6 @@ bool patcher_invokeinterface(u1 *sp)
        *((s4 *) (ra + 4 + 4)) |=
                (s4) ((sizeof(methodptr) * (m - m->class->methods)) & 0x0000ffff);
 
-       /* synchronize instruction cache */
-
-       asm_sync_instruction_cache();
-
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
-       return true;
-}
-
-
-/* patcher_checkcast_instanceof_flags ******************************************
-
-   Machine code:
-
-   <patched call position>
-
-*******************************************************************************/
-
-bool patcher_checkcast_instanceof_flags(u1 *sp)
-{
-       u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
-       constant_classref *cr;
-       s4                 disp;
-       u1                *pv;
-       classinfo         *c;
-
-       /* get stuff from the stack */
-
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
-       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
-       disp  =                       *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
-
-       /* get the fieldinfo */
-
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
-
-               return false;
-       }
-
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       asm_sync_instruction_cache();
-
-       /* patch class flags */
-
-       *((s4 *) (pv + disp)) = (s4) c->flags;
-
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
 
@@ -642,36 +570,18 @@ bool patcher_checkcast_instanceof_flags(u1 *sp)
 bool patcher_checkcast_instanceof_interface(u1 *sp)
 {
        u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
        constant_classref *cr;
        classinfo         *c;
 
        /* get stuff from the stack */
 
        ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
        cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
 
-       /* calculate and set the new return address */
-
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
-
        /* get the fieldinfo */
 
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
-
+       if (!(c = resolve_classref_eager(cr)))
                return false;
-       }
-
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
 
        /* if we show disassembly, we have to skip the nop */
 
@@ -685,239 +595,8 @@ bool patcher_checkcast_instanceof_interface(u1 *sp)
        *((s4 *) (ra + 4 * 4)) |= (s4) ((OFFSET(vftbl_t, interfacetable[0]) -
                                                                         c->index * sizeof(methodptr*)) & 0x0000ffff);
 
-       /* synchronize instruction cache */
-
-       asm_sync_instruction_cache();
-
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
-       return true;
-}
-
-
-/* patcher_checkcast_instanceof_class ******************************************
-
-   Machine code:
-
-   <patched call position>
-   a7940000    ldq     at,0(a4)
-   a7bbff28    ldq     gp,-216(pv)
-
-*******************************************************************************/
-
-bool patcher_checkcast_instanceof_class(u1 *sp)
-{
-       u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
-       constant_classref *cr;
-       s4                 disp;
-       u1                *pv;
-       classinfo         *c;
-
-       /* get stuff from the stack */
-
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
-       cr    = (constant_classref *) *((ptrint *) (sp + 2 * 8));
-       disp  =                       *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
-
-       /* get the fieldinfo */
-
-       if (!(c = resolve_classref_eager(cr))) {
-               PATCHER_MONITOREXIT;
-
-               return false;
-       }
-
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       asm_sync_instruction_cache();
-
-       /* patch super class' vftbl */
-
-       *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
-
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
-       return true;
-}
-
-
-/* patcher_clinit **************************************************************
-
-   XXX
-
-*******************************************************************************/
-
-bool patcher_clinit(u1 *sp)
-{
-       u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
-       classinfo         *c;
-
-       /* get stuff from the stack */
-
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
-       c     = (classinfo *)         *((ptrint *) (sp + 2 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
-
-       /* check if the class is initialized */
-
-       if (!c->initialized) {
-               if (!initialize_class(c)) {
-                       PATCHER_MONITOREXIT;
-
-                       return false;
-               }
-       }
-
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       asm_sync_instruction_cache();
-
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
-       return true;
-}
-
-
-/* patcher_athrow_areturn ******************************************************
-
-   Machine code:
-
-   <patched call position>
-
-*******************************************************************************/
-
-bool patcher_athrow_areturn(u1 *sp)
-{
-       u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
-       unresolved_class  *uc;
-       classinfo         *c;
-
-       /* get stuff from the stack */
-
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
-       uc    = (unresolved_class *)  *((ptrint *) (sp + 2 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
-
-       /* resolve the class */
-
-       if (!resolve_class(uc, resolveEager, false, &c)) {
-               PATCHER_MONITOREXIT;
-
-               return false;
-       }
-
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       asm_sync_instruction_cache();
-
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
-       return true;
-}
-
-
-/* patcher_resolve_native ******************************************************
-
-   XXX
-
-*******************************************************************************/
-
-#if !defined(ENABLE_STATICVM)
-bool patcher_resolve_native(u1 *sp)
-{
-       u1                *ra;
-       java_objectheader *o;
-       u4                 mcode;
-       methodinfo        *m;
-       s4                 disp;
-       u1                *pv;
-       functionptr        f;
-
-       /* get stuff from the stack */
-
-       ra    = (u1 *)                *((ptrint *) (sp + 5 * 8));
-       o     = (java_objectheader *) *((ptrint *) (sp + 4 * 8));
-       mcode =                       *((u4 *)     (sp + 3 * 8));
-       m     = (methodinfo *)        *((ptrint *) (sp + 2 * 8));
-       disp  =                       *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
-
-       /* calculate and set the new return address */
-
-       ra = ra - 1 * 4;
-       *((ptrint *) (sp + 5 * 8)) = (ptrint) ra;
-
-       PATCHER_MONITORENTER;
-
-       /* resolve native function */
-
-       if (!(f = native_resolve_function(m))) {
-               PATCHER_MONITOREXIT;
-
-               return false;
-       }
-
-       /* patch back original code */
-
-       *((u4 *) ra) = mcode;
-
-       /* synchronize instruction cache */
-
-       asm_sync_instruction_cache();
-
-       /* patch native function pointer */
-
-       *((ptrint *) (pv + disp)) = (ptrint) f;
-
-       PATCHER_MARK_PATCHED_MONITOREXIT;
-
        return true;
 }
-#endif /* !defined(ENABLE_STATICVM) */
 
 
 /*