- created jitcache-arm-x86 branch
[cacao.git] / src / vm / jit / i386 / patcher.c
index b0ef05b8d5bc430a98718410741c7316b79733ea..4aa86f6e23afe739d0c23bc521f2a1cd807140ca 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/i386/patcher.c - i386 code patching functions
 
-   Copyright (C) 1996-2005, 2006, 2007 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, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
 #include "vmcore/references.h"
 
 
-#define PATCH_BACK_ORIGINAL_MCODE *((u2 *) ra) = (u2) pr->mcode
+#define PATCH_BACK_ORIGINAL_MCODE *((u2 *) pr->mpc) = (u2) pr->mcode
+
+
+/* patcher_patch_code **********************************************************
+
+   Just patches back the original machine code.
+
+*******************************************************************************/
+
+void patcher_patch_code(patchref_t *pr)
+{
+       PATCH_BACK_ORIGINAL_MCODE;
+}
 
 
 /* patcher_get_putstatic *******************************************************
@@ -81,8 +91,8 @@ bool patcher_get_putstatic(patchref_t *pr)
 
        /* check if the field's class is initialized */
 
-       if (!(fi->class->state & CLASS_INITIALIZED))
-               if (!initialize_class(fi->class))
+       if (!(fi->clazz->state & CLASS_INITIALIZED))
+               if (!initialize_class(fi->clazz))
                        return false;
 
        PATCH_BACK_ORIGINAL_MCODE;
@@ -253,7 +263,7 @@ bool patcher_putfieldconst(patchref_t *pr)
 
    Machine code:
 
-   <patched call postition>
+   <patched call position>
    c7 04 24 00 00 00 00       movl   $0x0000000,(%esp)
    b8 00 00 00 00             mov    $0x0000000,%eax
 
@@ -403,7 +413,7 @@ bool patcher_invokestatic_special(patchref_t *pr)
        ra    = (u1 *)                pr->mpc;
        um    = (unresolved_method *) pr->ref;
 
-       /* get the fieldinfo */
+       /* get the methodinfo */
 
        if (!(m = resolve_method_eager(um)))
                return false;
@@ -504,12 +514,12 @@ bool patcher_invokeinterface(patchref_t *pr)
        /* patch interfacetable index */
 
        *((s4 *) (ra + 2 + 2)) = (s4) (OFFSET(vftbl_t, interfacetable[0]) -
-                                                                  sizeof(methodptr) * m->class->index);
+                                                                  sizeof(methodptr) * m->clazz->index);
 
        /* patch method offset */
 
        *((s4 *) (ra + 2 + 6 + 2)) =
-               (s4) (sizeof(methodptr) * (m - m->class->methods));
+               (s4) (sizeof(methodptr) * (m - m->clazz->methods));
 
        return true;
 }
@@ -740,111 +750,6 @@ bool patcher_instanceof_class(patchref_t *pr)
 }
 
 
-/* patcher_initialize_class ****************************************************
-
-   Is used int PUT/GETSTATIC and native stub.
-
-   Machine code:
-
-   <patched call position>
-
-*******************************************************************************/
-
-bool patcher_initialize_class(patchref_t *pr)
-{
-       u1        *ra;
-       classinfo *c;
-
-       /* get stuff from the stack */
-
-       ra    = (u1 *)        pr->mpc;
-       c     = (classinfo *) pr->ref;
-
-       /* check if the class is initialized */
-
-       if (!(c->state & CLASS_INITIALIZED))
-               if (!initialize_class(c))
-                       return false;
-
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       return true;
-}
-
-
-/* patcher_resolve_class *******************************************************
-
-   Machine code:
-
-   <patched call position>
-
-*******************************************************************************/
-
-#ifdef ENABLE_VERIFIER
-bool patcher_resolve_class(patchref_t *pr)
-{
-       u1               *ra;
-       unresolved_class *uc;
-
-       /* get stuff from the stack */
-
-       ra    = (u1 *)               pr->mpc;
-       uc    = (unresolved_class *) pr->ref;
-
-       /* resolve the class and check subtype constraints */
-
-       if (!resolve_class_eager_no_access_check(uc))
-               return false;
-
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       return true;
-}
-#endif /* ENABLE_VERIFIER */
-
-
-/* patcher_resolve_native_function *********************************************
-
-   Is used in native stub.
-
-   Machine code:
-
-   <patched call position>
-   c7 44 24 04 28 90 01 40    movl   $0x40019028,0x4(%esp)
-
-*******************************************************************************/
-
-bool patcher_resolve_native_function(patchref_t *pr)
-{
-       u1          *ra;
-       methodinfo  *m;
-       functionptr  f;
-
-       /* get stuff from the stack */
-
-       ra    = (u1 *)         pr->mpc;
-       m     = (methodinfo *) pr->ref;
-
-       /* resolve native function */
-
-       if (!(f = native_resolve_function(m)))
-               return false;
-
-       PATCH_BACK_ORIGINAL_MCODE;
-
-       /* if we show disassembly, we have to skip the nop's */
-
-       if (opt_shownops)
-               ra = ra + PATCHER_CALL_SIZE;
-
-       /* patch native function pointer */
-
-       *((ptrint *) (ra + 4)) = (ptrint) f;
-
-       return true;
-}
-
-
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where