void patcher_add_patch_ref(jitdata *jd, functionptr patcher, void* ref, s4 disp)
{
- codegendata *cd;
- codeinfo *code;
- s4 patchmpc;
-
- cd = jd->cd;
- code = jd->code;
- patchmpc = cd->mcodeptr - cd->mcodebase;
+ codegendata *cd = jd->cd;
+ codeinfo *code = jd->code;
#if defined(ALIGN_PATCHER_TRAP)
emit_patcher_alignment(cd);
- patchmpc = cd->mcodeptr - cd->mcodebase;
#endif
+ int32_t patchmpc = cd->mcodeptr - cd->mcodebase;
+
#if !defined(NDEBUG)
if (patcher_list_find(code, (void*) (intptr_t) patchmpc) != NULL)
os::abort("patcher_add_patch_ref: different patchers at same position.");
#endif
+#if defined(USES_PATCHABLE_MEMORY_BARRIER)
+ PATCHER_NOPS;
+#endif
+
// Set patcher information (mpc is resolved later).
patchref_t pr;
/* src/vm/jit/x86_64/patcher.c - x86_64 code patching functions
- Copyright (C) 1996-2005, 2006, 2007, 2008
+ Copyright (C) 1996-2005, 2006, 2007, 2008, 2009
CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
if (c == NULL)
return false;
+ ra += PATCHER_CALL_SIZE;
+
// Patch class flags.
/* *datap = c->flags; */
*((int32_t*) (ra + 2)) = c->flags;
{
unresolved_field* uf = (unresolved_field*) pr->ref;
uintptr_t* datap = (uintptr_t*) pr->datap;
+ uint8_t* ra = (uint8_t*) pr->mpc;
// Resolve the field.
fieldinfo* fi = resolve_field_eager(uf);
if (fi == NULL)
return false;
+ ra += PATCHER_CALL_SIZE;
+
// Check if the field's class is initialized/
if (!(fi->clazz->state & CLASS_INITIALIZED))
if (!initialize_class(fi->clazz))
if (fi == NULL)
return false;
+ pc += PATCHER_CALL_SIZE;
+
// Patch the field's offset: we check for the field type, because
// the instructions have different lengths.
if (IS_INT_LNG_TYPE(fi->type)) {
if (fi == NULL)
return false;
+ pc += PATCHER_CALL_SIZE;
+
// Patch the field's offset.
if (IS_2_WORD_TYPE(fi->type) || IS_ADR_TYPE(fi->type)) {
// Handle special case when the base register is %r12.
if (m == NULL)
return false;
+ pc += PATCHER_CALL_SIZE;
+
// Patch vftbl index.
*((int32_t*) (pc + 3 + 3)) = (int32_t) (OFFSET(vftbl_t, table[0]) + sizeof(methodptr) * m->vftblindex);
if (m == NULL)
return false;
+ pc += PATCHER_CALL_SIZE;
+
// Patch interfacetable index.
*((int32_t*) (pc + 3 + 3)) = (int32_t) (OFFSET(vftbl_t, interfacetable[0]) - sizeof(methodptr) * m->clazz->index);
if (c == NULL)
return false;
+ pc += PATCHER_CALL_SIZE;
+
// Patch super class index.
*((int32_t*) (pc + 7 + 3)) = c->index;
if (c == NULL)
return false;
+ pc += PATCHER_CALL_SIZE;
+
// Patch super class index.
*((int32_t*) (pc + 7 + 3)) = c->index;