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 */
*((ptrint *) (ra + 7 + offset)) = (ptrint) &(fi->value);
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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) */
*((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);
*((u4 *) (ra + 5)) = (u4) (fi->offset);
}
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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 */
/* 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)
*((u4 *) (ra + 3)) = (u4) (fi->offset);
}
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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 */
*((ptrint *) (ra + 2)) = (ptrint) c;
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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 */
*((ptrint *) (ra + 10 + 10 + 3 + 2)) = (ptrint) BUILTIN_multianewarray;
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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 */
*((ptrint *) (ra + 2)) = (ptrint) c;
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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;
*((ptrint *) (ra + 2)) = (ptrint) m->stubroutine;
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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 */
*((s4 *) (ra + 3 + 3)) = (s4) (OFFSET(vftbl_t, table[0]) +
sizeof(methodptr) * m->vftblindex);
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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 */
*((s4 *) (ra + 3 + 7 + 3)) =
(s4) (sizeof(methodptr) * (m - m->class->methods));
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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 */
*((s4 *) (ra + 2)) = (s4) c->flags;
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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 */
(s4) (OFFSET(vftbl_t, interfacetable[0]) -
c->index * sizeof(methodptr*));
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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 */
*((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
*((ptrint *) (ra + 10 + 7 + 7 + 3 + 2)) = (ptrint) c->vftbl;
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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 */
*((ptrint *) (ra + 2)) = (ptrint) c->vftbl;
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
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;
}
#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 */
#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 */
*((ptrint *) (ra + 2)) = (ptrint) f;
- PATCHER_MARK_PATCHED_MONITOREXIT;
-
return true;
}
#endif /* !defined(WITH_STATIC_CLASSPATH) */