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"
*******************************************************************************/
-java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
+java_object_t *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra)
{
stackframeinfo sfi;
u1 *xpc;
- java_objectheader *o;
+ java_object_t *o;
functionptr f;
bool result;
- java_objectheader *e;
+ java_handle_t *e;
/* define the patcher function */
/* get stuff from the stack */
xpc = (u1 *) *((ptrint *) (sp + 6 * 4));
- o = (java_objectheader *) *((ptrint *) (sp + 4 * 4));
+ o = (java_object_t *) *((ptrint *) (sp + 4 * 4));
f = (functionptr) *((ptrint *) (sp + 0 * 4));
/* calculate and set the new return address */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the field value's address */
- *((ptrint *) (ra + 1)) = (ptrint) &(fi->value);
+ *((intptr_t *) (ra + 1)) = (intptr_t) fi->value;
return true;
}
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the field's offset */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the field's offset */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the field's offset */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the classinfo pointer */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* 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;
}
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch the classinfo pointer */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch stubroutine */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch vftbl index */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch interfacetable index */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch class flags */
}
-/* patcher_checkcast_instanceof_interface **************************************
+/* patcher_checkcast_interface *************************************************
+
+ Machine code:
+
+ <patched call position>
+ 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 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_interface(u1 *sp)
+{
+ 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));
+
+ /* 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);
+
+ /* if we show disassembly, we have to skip the nop's */
+
+ if (opt_shownops)
+ ra = ra + 5;
+
+ /* patch super class index */
+
+ *((s4 *) (ra + 6 + 2)) = (s4) c->index;
+
+ *((s4 *) (ra + 6 + 6 + 2 + 6 + 6 + 2)) =
+ (s4) (OFFSET(vftbl_t, interfacetable[0]) -
+ c->index * sizeof(methodptr*));
+
+ return true;
+}
+
+
+/* patcher_instanceof_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 8e 13 00 00 00 jle 0x00000000
8b 91 00 00 00 00 mov 0x00000000(%ecx),%edx
*******************************************************************************/
-bool patcher_checkcast_instanceof_interface(u1 *sp)
+bool patcher_instanceof_interface(u1 *sp)
{
u1 *ra;
u8 mcode;
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch super class index */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch super class' vftbl */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch super class' vftbl */
/* if we show disassembly, we have to skip the nop's */
- if (opt_showdisassemble)
+ if (opt_shownops)
ra = ra + 5;
/* patch native function pointer */