* src/vm/jit/alpha/patcher.c (patcher_wrapper): Patch back machine
authorchristian <none@none>
Mon, 4 Sep 2006 17:12:48 +0000 (17:12 +0000)
committerchristian <none@none>
Mon, 4 Sep 2006 17:12:48 +0000 (17:12 +0000)
code.
(patcher_aconst): Renamed to patcher_resolve_classref_to_classinfo.
(patcher_clinit): Renamed to patcher_initialize_class.
(patcher_resolve_native): Renamed to patcher_resolve_native_function.
(patcher_athrow_areturn): Renamed to patcher_resolve_class.
(patcher_checkcast_instanceof_class): Renamed to
patcher_resolve_classref_to_vftbl.
(patcher_checkcast_instanceof_flags): Renamed to
patcher_resolve_classref_to_flags.
(patcher_builtin_multianewarray): Removed.
(patcher_builtin_arraycheckcast): Likewise.

* src/vm/jit/alpha/codegen.c (codegen): Use new patcher functions.

src/vm/jit/alpha/codegen.c
src/vm/jit/alpha/patcher.c

index c2bb514b90e58213bd98ba91dd2b88b492bc278b..d63cb5f3f3838f38315958e75789f8d07526523d 100644 (file)
@@ -32,7 +32,7 @@
             Christian Ullrich
             Edwin Steiner
 
-   $Id: codegen.c 5289 2006-09-04 16:33:57Z twisti $
+   $Id: codegen.c 5290 2006-09-04 17:12:48Z christian $
 
 */
 
@@ -476,7 +476,8 @@ bool codegen(jitdata *jd)
                                   resolved the same class, the returned displacement
                                   of dseg_addaddress is ok to use. */
 
-                               codegen_addpatchref(cd, PATCHER_aconst, cr, disp);
+                               codegen_addpatchref(cd, PATCHER_resolve_classref_to_classinfo,
+                                                                       cr, disp);
 
                                if (opt_showdisassemble)
                                        M_NOP;
@@ -2000,7 +2001,8 @@ bool codegen(jitdata *jd)
                                disp = dseg_add_address(cd, &(fi->value));
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
-                                       codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0);
+                                       codegen_addpatchref(cd, PATCHER_initialize_class, fi->class,
+                                                                               0);
 
                                        if (opt_showdisassemble)
                                                M_NOP;
@@ -2052,7 +2054,8 @@ bool codegen(jitdata *jd)
                                disp = dseg_add_address(cd, &(fi->value));
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
-                                       codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0);
+                                       codegen_addpatchref(cd, PATCHER_initialize_class, fi->class,
+                                                                               0);
 
                                        if (opt_showdisassemble)
                                                M_NOP;
@@ -2105,7 +2108,8 @@ bool codegen(jitdata *jd)
                                disp = dseg_add_address(cd, &(fi->value));
 
                                if (!CLASS_IS_OR_ALMOST_INITIALIZED(fi->class)) {
-                                       codegen_addpatchref(cd, PATCHER_clinit, fi->class, 0);
+                                       codegen_addpatchref(cd, PATCHER_initialize_class, fi->class,
+                                                                               0);
 
                                        if (opt_showdisassemble)
                                                M_NOP;
@@ -2279,7 +2283,7 @@ bool codegen(jitdata *jd)
                        if (iptr->val.a) {
                                unresolved_class *uc = INSTRUCTION_UNRESOLVED_CLASS(iptr);
 
-                               codegen_addpatchref(cd, PATCHER_athrow_areturn, uc, 0);
+                               codegen_addpatchref(cd, PATCHER_resolve_class, uc, 0);
 
                                if (opt_showdisassemble)
                                        M_NOP;
@@ -2656,7 +2660,7 @@ bool codegen(jitdata *jd)
                        if (iptr->val.a) {
                                unresolved_class *uc = INSTRUCTION_UNRESOLVED_CLASS(iptr);
 
-                               codegen_addpatchref(cd, PATCHER_athrow_areturn, uc, 0);
+                               codegen_addpatchref(cd, PATCHER_resolve_class, uc, 0);
 
                                if (opt_showdisassemble)
                                        M_NOP;
@@ -3086,7 +3090,7 @@ gen_method:
 
                                        disp = dseg_add_unique_s4(cd, 0);         /* super->flags */
 
-                                       codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags,
+                                       codegen_addpatchref(cd, PATCHER_resolve_classref_to_flags,
                                                                                (constant_classref *) iptr->target,
                                                                                disp);
 
@@ -3138,7 +3142,7 @@ gen_method:
                                                disp = dseg_add_unique_address(cd, NULL);
 
                                                codegen_addpatchref(cd,
-                                                                                       PATCHER_checkcast_instanceof_class,
+                                                                                       PATCHER_resolve_classref_to_vftbl,
                                                                                        (constant_classref *) iptr->target,
                                                                                        disp);
 
@@ -3190,7 +3194,8 @@ gen_method:
                                disp = dseg_addaddress(cd, iptr->val.a);
 
                                if (iptr->val.a == NULL) {
-                                       codegen_addpatchref(cd, PATCHER_builtin_arraycheckcast,
+                                       codegen_addpatchref(cd,
+                                                                               PATCHER_resolve_classref_to_classinfo,
                                                                                (constant_classref *) iptr->target,
                                                                                disp);
 
@@ -3280,7 +3285,7 @@ gen_method:
 
                                disp = dseg_add_unique_s4(cd, 0);             /* super->flags */
 
-                               codegen_addpatchref(cd, PATCHER_checkcast_instanceof_flags,
+                               codegen_addpatchref(cd, PATCHER_resolve_classref_to_flags,
                                                                        (constant_classref *) iptr->target, disp);
 
                                if (opt_showdisassemble)
@@ -3334,7 +3339,7 @@ gen_method:
                                if (super == NULL) {
                                        disp = dseg_add_unique_address(cd, NULL);
 
-                                       codegen_addpatchref(cd, PATCHER_checkcast_instanceof_class,
+                                       codegen_addpatchref(cd, PATCHER_resolve_classref_to_vftbl,
                                                                                (constant_classref *) iptr->target,
                                                                                disp);
 
@@ -3391,7 +3396,7 @@ gen_method:
                        if (iptr->val.a == NULL) {
                                disp = dseg_add_unique_address(cd, 0);
 
-                               codegen_addpatchref(cd, PATCHER_builtin_multianewarray,
+                               codegen_addpatchref(cd, PATCHER_resolve_classref_to_classinfo,
                                                                        (constant_classref *) iptr->target,
                                                                        disp);
 
@@ -3619,7 +3624,7 @@ u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd)
 
 #if !defined(WITH_STATIC_CLASSPATH)
        if (f == NULL) {
-               codegen_addpatchref(cd, PATCHER_resolve_native, m, funcdisp);
+               codegen_addpatchref(cd, PATCHER_resolve_native_function, m, funcdisp);
 
                if (opt_showdisassemble)
                        M_NOP;
index b10aede4cab0461319cb51aa3d147b6fafcb4778..a6308c7bc4f5495fbd8f2b5dd7a2928d1c9bfbbe 100644 (file)
@@ -28,7 +28,7 @@
 
    Changes:
 
-   $Id: patcher.c 5160 2006-07-19 09:13:34Z twisti $
+   $Id: patcher.c 5290 2006-09-04 17:12:48Z christian $
 
 */
 
@@ -142,99 +142,82 @@ java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
        return NULL;
 }
 
+/* patcher_initialize_class ****************************************************
 
-/* patcher_get_putstatic *******************************************************
-
-   Machine code:
-
-   <patched call position>
-   a73bff98    ldq     t11,-104(pv)
-   a2590000    ldl     a2,0(t11)
+   Initalizes a given classinfo pointer.  This function does not patch
+   any data.
 
 *******************************************************************************/
 
-bool patcher_get_putstatic(u1 *sp)
+bool patcher_initialize_class(u1 *sp)
 {
-       unresolved_field *uf;
-       s4                disp;
-       u1               *pv;
-       fieldinfo        *fi;
+       classinfo *c;
 
        /* get stuff from the stack */
 
-       uf    = (unresolved_field *) *((ptrint *) (sp + 2 * 8));
-       disp  =                      *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)               *((ptrint *) (sp + 0 * 8));
-
-       /* get the fieldinfo */
-
-       if (!(fi = resolve_field_eager(uf)))
-               return false;
+       c = (classinfo *) *((ptrint *) (sp + 2 * 8));
 
-       /* check if the field's class is initialized */
+       /* check if the class is initialized */
 
-       if (!(fi->class->state & CLASS_INITIALIZED))
-               if (!initialize_class(fi->class))
+       if (!(c->state & CLASS_INITIALIZED))
+               if (!initialize_class(c))
                        return false;
 
-       /* patch the field value's address */
-
-       *((ptrint *) (pv + disp)) = (ptrint) &(fi->value);
-
        return true;
 }
 
+/* patcher_resolve_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)
+#ifdef ENABLE_VERIFIER
+bool patcher_resolve_class(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;
+       unresolved_class *uc;
+       classinfo        *c;
 
-       /* if we show disassembly, we have to skip the nop */
+       /* get stuff from the stack */
 
-       if (opt_showdisassemble) {
-               /* patch the field's offset into the instruction */
+       uc = (unresolved_class *)  *((ptrint *) (sp + 2 * 8));
 
-               *((u4 *) (ra + 4)) |= (s2) (fi->offset & 0x0000ffff);
-       }
-       else {
-               /* otherwise store the patched instruction on the stack */
+       /* resolve the class */
 
-               *((u4 *) (sp + 3 * 8)) |= (s2) (fi->offset & 0x0000ffff);
-       }
+       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)
 {
        constant_classref *cr;
        s4                 disp;
@@ -260,19 +243,18 @@ bool patcher_aconst(u1 *sp)
 }
 
 
-/* patcher_builtin_multianewarray **********************************************
+/* patcher_resolve_classref_to_vftbl *******************************************
 
-   Machine code:
+   CHECKCAST (class):
+   INSTANCEOF (class):
 
    <patched call position>
-   a63bff80    ldq     a1,-128(pv)
-   47de0412    mov     sp,a2
-   a77bff78    ldq     pv,-136(pv)
-   6b5b4000    jsr     (pv)
+   a7940000    ldq     at,0(a4)
+   a7bbff28    ldq     gp,-216(pv)
 
 *******************************************************************************/
 
-bool patcher_builtin_multianewarray(u1 *sp)
+bool patcher_resolve_classref_to_vftbl(u1 *sp)
 {
        constant_classref *cr;
        s4                 disp;
@@ -285,31 +267,28 @@ bool patcher_builtin_multianewarray(u1 *sp)
        disp  =                       *((s4 *)     (sp + 1 * 8));
        pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
 
-       /* get the classinfo */
+       /* get the fieldinfo */
 
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
-       /* patch the classinfo pointer */
+       /* patch super class' vftbl */
 
-       *((ptrint *) (pv + disp)) = (ptrint) c;
+       *((ptrint *) (pv + disp)) = (ptrint) c->vftbl;
 
        return true;
 }
 
 
-/* patcher_builtin_arraycheckcast **********************************************
+/* patcher_resolve_classref_to_flags *******************************************
 
-   Machine code:
+   CHECKCAST/INSTANCEOF:
 
    <patched call position>
-   a63bfe60    ldq     a1,-416(pv)
-   a77bfe58    ldq     pv,-424(pv)
-   6b5b4000    jsr     (pv)
 
 *******************************************************************************/
 
-bool patcher_builtin_arraycheckcast(u1 *sp)
+bool patcher_resolve_classref_to_flags(u1 *sp)
 {
        constant_classref *cr;
        s4                 disp;
@@ -322,14 +301,130 @@ bool patcher_builtin_arraycheckcast(u1 *sp)
        disp  =                       *((s4 *)     (sp + 1 * 8));
        pv    = (u1 *)                *((ptrint *) (sp + 0 * 8));
 
-       /* get the classinfo */
+       /* get the fieldinfo */
 
        if (!(c = resolve_classref_eager(cr)))
                return false;
 
-       /* patch the classinfo pointer */
+       /* patch class flags */
 
-       *((ptrint *) (pv + disp)) = (ptrint) c;
+       *((s4 *) (pv + disp)) = (s4) c->flags;
+
+       return true;
+}
+
+
+/* patcher_resolve_native_function *********************************************
+
+   XXX
+
+*******************************************************************************/
+
+#if !defined(WITH_STATIC_CLASSPATH)
+bool patcher_resolve_native_function(u1 *sp)
+{
+       methodinfo  *m;
+       s4           disp;
+       u1          *pv;
+       functionptr  f;
+
+       /* get stuff from the stack */
+
+       m     = (methodinfo *) *((ptrint *) (sp + 2 * 8));
+       disp  =                *((s4 *)     (sp + 1 * 8));
+       pv    = (u1 *)         *((ptrint *) (sp + 0 * 8));
+
+       /* 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_get_putstatic *******************************************************
+
+   Machine code:
+
+   <patched call position>
+   a73bff98    ldq     t11,-104(pv)
+   a2590000    ldl     a2,0(t11)
+
+*******************************************************************************/
+
+bool patcher_get_putstatic(u1 *sp)
+{
+       unresolved_field *uf;
+       s4                disp;
+       u1               *pv;
+       fieldinfo        *fi;
+
+       /* get stuff from the stack */
+
+       uf    = (unresolved_field *) *((ptrint *) (sp + 2 * 8));
+       disp  =                      *((s4 *)     (sp + 1 * 8));
+       pv    = (u1 *)               *((ptrint *) (sp + 0 * 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 the field value's address */
+
+       *((ptrint *) (pv + disp)) = (ptrint) &(fi->value);
+
+       return true;
+}
+
+
+/* patcher_get_putfield ********************************************************
+
+   Machine code:
+
+   <patched call position>
+   a2af0020    ldl     a5,32(s6)
+
+*******************************************************************************/
+
+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;
 }
@@ -459,40 +554,6 @@ bool patcher_invokeinterface(u1 *sp)
 }
 
 
-/* patcher_checkcast_instanceof_flags ******************************************
-
-   Machine code:
-
-   <patched call position>
-
-*******************************************************************************/
-
-bool patcher_checkcast_instanceof_flags(u1 *sp)
-{
-       constant_classref *cr;
-       s4                 disp;
-       u1                *pv;
-       classinfo         *c;
-
-       /* get stuff from the stack */
-
-       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 class flags */
-
-       *((s4 *) (pv + disp)) = (s4) c->flags;
-
-       return true;
-}
-
-
 /* patcher_checkcast_instanceof_interface **************************************
 
    Machine code:
@@ -538,128 +599,6 @@ bool patcher_checkcast_instanceof_interface(u1 *sp)
 }
 
 
-/* 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)
-{
-       constant_classref *cr;
-       s4                 disp;
-       u1                *pv;
-       classinfo         *c;
-
-       /* get stuff from the stack */
-
-       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_clinit **************************************************************
-
-   XXX
-
-*******************************************************************************/
-
-bool patcher_clinit(u1 *sp)
-{
-       classinfo *c;
-
-       /* get stuff from the stack */
-
-       c = (classinfo *) *((ptrint *) (sp + 2 * 8));
-
-       /* check if the class is initialized */
-
-       if (!(c->state & CLASS_INITIALIZED))
-               if (!initialize_class(c))
-                       return false;
-
-       return true;
-}
-
-
-/* patcher_athrow_areturn ******************************************************
-
-   Machine code:
-
-   <patched call position>
-
-*******************************************************************************/
-
-#ifdef ENABLE_VERIFIER
-bool patcher_athrow_areturn(u1 *sp)
-{
-       unresolved_class *uc;
-       classinfo        *c;
-
-       /* get stuff from the stack */
-
-       uc = (unresolved_class *)  *((ptrint *) (sp + 2 * 8));
-
-       /* resolve the class */
-
-       if (!resolve_class(uc, resolveEager, false, &c))
-               return false;
-
-       return true;
-}
-#endif /* ENABLE_VERIFIER */
-
-
-/* patcher_resolve_native ******************************************************
-
-   XXX
-
-*******************************************************************************/
-
-#if !defined(WITH_STATIC_CLASSPATH)
-bool patcher_resolve_native(u1 *sp)
-{
-       methodinfo  *m;
-       s4           disp;
-       u1          *pv;
-       functionptr  f;
-
-       /* get stuff from the stack */
-
-       m     = (methodinfo *) *((ptrint *) (sp + 2 * 8));
-       disp  =                *((s4 *)     (sp + 1 * 8));
-       pv    = (u1 *)         *((ptrint *) (sp + 0 * 8));
-
-       /* 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) */
-
-
 /*
  * 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