Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: patcher.c 7464 2007-03-06 00:26:31Z edwin $
-
*/
#include "config.h"
+
+#include <stdint.h>
+
#include "vm/types.h"
#include "vm/jit/i386/codegen.h"
#include "vm/exceptions.h"
#include "vm/initialize.h"
-#include "vm/jit/patcher.h"
+#include "vm/jit/patcher-common.h"
#include "vm/jit/stacktrace.h"
#include "vmcore/class.h"
#include "vmcore/references.h"
-/* patcher_wrapper *************************************************************
+#define PATCH_BACK_ORIGINAL_MCODE *((u2 *) pr->mpc) = (u2) pr->mcode
- 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.
+/* patcher_patch_code **********************************************************
+
+ Just patches back the original machine code.
*******************************************************************************/
-java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
+void patcher_patch_code(patchref_t *pr)
{
- stackframeinfo sfi;
- u1 *xpc;
- java_objectheader *o;
- functionptr f;
- bool result;
- java_objectheader *e;
-
- /* define the patcher function */
-
- bool (*patcher_function)(u1 *);
-
- /* get stuff from the stack */
-
- xpc = (u1 *) *((ptrint *) (sp + 6 * 4));
- o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
- f = (functionptr) *((ptrint *) (sp + 0 * 4));
-
- /* calculate and set the new return address */
-
- xpc = xpc - PATCHER_CALL_SIZE;
-
- *((ptrint *) (sp + 6 * 4)) = (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;
-
- /* 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_get_pv_from_pc. */
-
- stacktrace_create_extern_stackframeinfo(&sfi, pv, sp + 7 * 4, 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();
-
- PATCHER_MONITOREXIT;
-
- return e;
- }
-
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
- return NULL;
+ PATCH_BACK_ORIGINAL_MCODE;
}
*******************************************************************************/
-bool patcher_get_putstatic(u1 *sp)
+bool patcher_get_putstatic(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
unresolved_field *uf;
fieldinfo *fi;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- uf = (unresolved_field *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ uf = (unresolved_field *) pr->ref;
/* get the fieldinfo */
if (!initialize_class(fi->class))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch the field value's address */
- *((ptrint *) (ra + 1)) = (ptrint) &(fi->value);
+ *((intptr_t *) (ra + 1)) = (intptr_t) fi->value;
return true;
}
*******************************************************************************/
-bool patcher_getfield(u1 *sp)
+bool patcher_getfield(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
unresolved_field *uf;
fieldinfo *fi;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- uf = (unresolved_field *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ uf = (unresolved_field *) pr->ref;
/* get the fieldinfo */
if (!(fi = resolve_field_eager(uf)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch the field's offset */
*******************************************************************************/
-bool patcher_putfield(u1 *sp)
+bool patcher_putfield(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
unresolved_field *uf;
fieldinfo *fi;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- uf = (unresolved_field *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ uf = (unresolved_field *) pr->ref;
/* get the fieldinfo */
if (!(fi = resolve_field_eager(uf)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch the field's offset */
*******************************************************************************/
-bool patcher_putfieldconst(u1 *sp)
+bool patcher_putfieldconst(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
unresolved_field *uf;
fieldinfo *fi;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- uf = (unresolved_field *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ uf = (unresolved_field *) pr->ref;
/* get the fieldinfo */
if (!(fi = resolve_field_eager(uf)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch the field's offset */
*******************************************************************************/
-bool patcher_aconst(u1 *sp)
+bool patcher_aconst(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
constant_classref *cr;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- cr = (constant_classref *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ cr = (constant_classref *) pr->ref;
/* get the classinfo */
if (!(c = resolve_classref_eager(cr)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch the classinfo pointer */
*******************************************************************************/
-bool patcher_builtin_multianewarray(u1 *sp)
+bool patcher_builtin_multianewarray(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
constant_classref *cr;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- cr = (constant_classref *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ cr = (constant_classref *) pr->ref;
/* get the classinfo */
if (!(c = resolve_classref_eager(cr)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch the classinfo pointer */
*((ptrint *) (ra + 7 + 4)) = (ptrint) c;
- /* patch new function address */
-
- *((ptrint *) (ra + 7 + 8 + 2 + 3 + 4 + 1)) =
- (ptrint) BUILTIN_multianewarray;
-
return true;
}
*******************************************************************************/
-bool patcher_builtin_arraycheckcast(u1 *sp)
+bool patcher_builtin_arraycheckcast(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
constant_classref *cr;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- cr = (constant_classref *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ cr = (constant_classref *) pr->ref;
/* get the classinfo */
if (!(c = resolve_classref_eager(cr)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch the classinfo pointer */
*******************************************************************************/
-bool patcher_invokestatic_special(u1 *sp)
+bool patcher_invokestatic_special(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
unresolved_method *um;
methodinfo *m;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- um = (unresolved_method *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ um = (unresolved_method *) pr->ref;
/* get the fieldinfo */
if (!(m = resolve_method_eager(um)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch stubroutine */
*******************************************************************************/
-bool patcher_invokevirtual(u1 *sp)
+bool patcher_invokevirtual(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
unresolved_method *um;
methodinfo *m;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- um = (unresolved_method *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ um = (unresolved_method *) pr->ref;
/* get the fieldinfo */
if (!(m = resolve_method_eager(um)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch vftbl index */
*******************************************************************************/
-bool patcher_invokeinterface(u1 *sp)
+bool patcher_invokeinterface(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
unresolved_method *um;
methodinfo *m;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- um = (unresolved_method *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ um = (unresolved_method *) pr->ref;
/* get the fieldinfo */
if (!(m = resolve_method_eager(um)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch interfacetable index */
*******************************************************************************/
-bool patcher_checkcast_instanceof_flags(u1 *sp)
+bool patcher_checkcast_instanceof_flags(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
constant_classref *cr;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- cr = (constant_classref *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ cr = (constant_classref *) pr->ref;
/* get the fieldinfo */
if (!(c = resolve_classref_eager(cr)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch class flags */
}
-/* patcher_checkcast_instanceof_interface **************************************
+/* patcher_checkcast_interface *************************************************
Machine code:
8b 91 00 00 00 00 mov 0x00000000(%ecx),%edx
81 ea 00 00 00 00 sub $0x00000000,%edx
85 d2 test %edx,%edx
- 0f 8e 00 00 00 00 jle 0x00000000
+ 0f 8f 06 00 00 00 jg 0x00000000
+ 8b 35 03 00 00 00 mov 0x3,%esi
8b 91 00 00 00 00 mov 0x00000000(%ecx),%edx
*******************************************************************************/
-bool patcher_checkcast_instanceof_interface(u1 *sp)
+bool patcher_checkcast_interface(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
constant_classref *cr;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- cr = (constant_classref *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ cr = (constant_classref *) pr->ref;
/* get the fieldinfo */
if (!(c = resolve_classref_eager(cr)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch super class index */
*((s4 *) (ra + 6 + 2)) = (s4) c->index;
- *((s4 *) (ra + 6 + 6 + 2 + 6 + 2)) =
+ *((s4 *) (ra + 6 + 6 + 2 + 6 + 6 + 2)) =
(s4) (OFFSET(vftbl_t, interfacetable[0]) -
c->index * sizeof(methodptr*));
}
-/* patcher_checkcast_class *****************************************************
+/* patcher_instanceof_interface ************************************************
Machine code:
<patched call position>
- ba 00 00 00 00 mov $0x00000000,%edx
- 8b 89 00 00 00 00 mov 0x00000000(%ecx),%ecx
- 8b 92 00 00 00 00 mov 0x00000000(%edx),%edx
- 29 d1 sub %edx,%ecx
- ba 00 00 00 00 mov $0x00000000,%edx
+ 8b 91 00 00 00 00 mov 0x00000000(%ecx),%edx
+ 81 ea 00 00 00 00 sub $0x00000000,%edx
+ 85 d2 test %edx,%edx
+ 0f 8e 13 00 00 00 jle 0x00000000
+ 8b 91 00 00 00 00 mov 0x00000000(%ecx),%edx
*******************************************************************************/
-bool patcher_checkcast_class(u1 *sp)
+bool patcher_instanceof_interface(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
constant_classref *cr;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- cr = (constant_classref *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ cr = (constant_classref *) pr->ref;
/* get the fieldinfo */
if (!(c = resolve_classref_eager(cr)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
- /* patch super class' vftbl */
+ /* patch super class index */
- *((ptrint *) (ra + 1)) = (ptrint) c->vftbl;
- *((ptrint *) (ra + 5 + 6 + 6 + 2 + 1)) = (ptrint) c->vftbl;
+ *((s4 *) (ra + 6 + 2)) = (s4) c->index;
+
+ *((s4 *) (ra + 6 + 6 + 2 + 6 + 2)) =
+ (s4) (OFFSET(vftbl_t, interfacetable[0]) -
+ c->index * sizeof(methodptr*));
return true;
}
-/* patcher_instanceof_class ****************************************************
+/* patcher_checkcast_class *****************************************************
Machine code:
<patched call position>
- b9 00 00 00 00 mov $0x0,%ecx
- 8b 40 14 mov 0x14(%eax),%eax
- 8b 51 18 mov 0x18(%ecx),%edx
- 8b 49 14 mov 0x14(%ecx),%ecx
+ ba 00 00 00 00 mov $0x00000000,%edx
+ 8b 89 00 00 00 00 mov 0x00000000(%ecx),%ecx
+ 8b 92 00 00 00 00 mov 0x00000000(%edx),%edx
+ 29 d1 sub %edx,%ecx
+ ba 00 00 00 00 mov $0x00000000,%edx
*******************************************************************************/
-bool patcher_instanceof_class(u1 *sp)
+bool patcher_checkcast_class(patchref_t *pr)
{
u1 *ra;
- u8 mcode;
constant_classref *cr;
classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- cr = (constant_classref *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ cr = (constant_classref *) pr->ref;
/* get the fieldinfo */
if (!(c = resolve_classref_eager(cr)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
/* patch super class' vftbl */
*((ptrint *) (ra + 1)) = (ptrint) c->vftbl;
+ *((ptrint *) (ra + 5 + 6 + 6 + 2 + 1)) = (ptrint) c->vftbl;
return true;
}
-/* patcher_clinit **************************************************************
-
- Is used int PUT/GETSTATIC and native stub.
-
- Machine code:
-
- <patched call position>
-
-*******************************************************************************/
-
-bool patcher_clinit(u1 *sp)
-{
- u1 *ra;
- u8 mcode;
- classinfo *c;
-
- /* get stuff from the stack */
-
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- c = (classinfo *) *((ptrint *) (sp + 1 * 4));
-
- /* check if the class is initialized */
-
- if (!(c->state & CLASS_INITIALIZED))
- if (!initialize_class(c))
- return false;
-
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
-
- return true;
-}
-
-
-/* patcher_athrow_areturn ******************************************************
-
- Machine code:
-
- <patched call position>
-
-*******************************************************************************/
-
-#ifdef ENABLE_VERIFIER
-bool patcher_athrow_areturn(u1 *sp)
-{
- u1 *ra;
- u8 mcode;
- unresolved_class *uc;
-
- /* get stuff from the stack */
-
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- uc = (unresolved_class *) *((ptrint *) (sp + 1 * 4));
-
- /* resolve the class and check subtype constraints */
-
- if (!resolve_class_eager_no_access_check(uc))
- return false;
-
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
-
- return true;
-}
-#endif /* ENABLE_VERIFIER */
-
-
-/* patcher_resolve_native ******************************************************
-
- Is used in native stub.
+/* patcher_instanceof_class ****************************************************
Machine code:
<patched call position>
- c7 44 24 04 28 90 01 40 movl $0x40019028,0x4(%esp)
+ b9 00 00 00 00 mov $0x0,%ecx
+ 8b 40 14 mov 0x14(%eax),%eax
+ 8b 51 18 mov 0x18(%ecx),%edx
+ 8b 49 14 mov 0x14(%ecx),%ecx
*******************************************************************************/
-#if !defined(WITH_STATIC_CLASSPATH)
-bool patcher_resolve_native(u1 *sp)
+bool patcher_instanceof_class(patchref_t *pr)
{
- u1 *ra;
- u8 mcode;
- methodinfo *m;
- functionptr f;
+ u1 *ra;
+ constant_classref *cr;
+ classinfo *c;
/* get stuff from the stack */
- ra = (u1 *) *((ptrint *) (sp + 6 * 4));
- mcode = *((u8 *) (sp + 2 * 4));
- m = (methodinfo *) *((ptrint *) (sp + 1 * 4));
+ ra = (u1 *) pr->mpc;
+ cr = (constant_classref *) pr->ref;
- /* resolve native function */
+ /* get the fieldinfo */
- if (!(f = native_resolve_function(m)))
+ if (!(c = resolve_classref_eager(cr)))
return false;
- /* patch back original code */
-
- *((u4 *) (ra + 0)) = (u4) mcode;
- *((u1 *) (ra + 4)) = (u1) (mcode >> 32);
+ PATCH_BACK_ORIGINAL_MCODE;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
- ra = ra + 5;
+ if (opt_shownops)
+ ra = ra + PATCHER_CALL_SIZE;
- /* patch native function pointer */
+ /* patch super class' vftbl */
- *((ptrint *) (ra + 4)) = (ptrint) f;
+ *((ptrint *) (ra + 1)) = (ptrint) c->vftbl;
return true;
}
-#endif /* !defined(WITH_STATIC_CLASSPATH) */
/*