From 67da78971605bb8a2953a9f6d5a7862857049538 Mon Sep 17 00:00:00 2001 From: Stefan Ring Date: Sat, 14 Nov 2009 15:56:58 +0100 Subject: [PATCH] * src/vm/jit/patcher-common.cpp: Conditionally restored NOP-insertion at patcher sites that was removed in ca65904a0c8b. * src/vm/jit/x86_64/arch.h: Added USES_PATCHABLE_MEMORY_BARRIER. * src/vm/jit/x86_64/patcher.c: Adjust offsets to changed code layout. --- src/vm/jit/patcher-common.cpp | 16 ++++++++-------- src/vm/jit/x86_64/arch.h | 3 +++ src/vm/jit/x86_64/patcher.c | 19 ++++++++++++++++++- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/vm/jit/patcher-common.cpp b/src/vm/jit/patcher-common.cpp index 216b4fc85..57c6fdb39 100644 --- a/src/vm/jit/patcher-common.cpp +++ b/src/vm/jit/patcher-common.cpp @@ -213,24 +213,24 @@ void patcher_list_show(codeinfo *code) 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; diff --git a/src/vm/jit/x86_64/arch.h b/src/vm/jit/x86_64/arch.h index 80ac34246..ef425cb21 100644 --- a/src/vm/jit/x86_64/arch.h +++ b/src/vm/jit/x86_64/arch.h @@ -126,6 +126,8 @@ #define CAS_PROVIDES_FULL_BARRIER 1 +#define USES_PATCHABLE_MEMORY_BARRIER 1 + #endif /* _ARCH_H */ @@ -140,4 +142,5 @@ * c-basic-offset: 4 * tab-width: 4 * End: + * vim:noexpandtab:sw=4:ts=4: */ diff --git a/src/vm/jit/x86_64/patcher.c b/src/vm/jit/x86_64/patcher.c index ae4b7aa21..81cc09e0e 100644 --- a/src/vm/jit/x86_64/patcher.c +++ b/src/vm/jit/x86_64/patcher.c @@ -1,6 +1,6 @@ /* 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. @@ -176,6 +176,8 @@ bool patcher_resolve_classref_to_flags(patchref_t *pr) if (c == NULL) return false; + ra += PATCHER_CALL_SIZE; + // Patch class flags. /* *datap = c->flags; */ *((int32_t*) (ra + 2)) = c->flags; @@ -205,6 +207,7 @@ bool patcher_get_putstatic(patchref_t *pr) { 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); @@ -212,6 +215,8 @@ bool patcher_get_putstatic(patchref_t *pr) 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)) @@ -250,6 +255,8 @@ bool patcher_get_putfield(patchref_t *pr) 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)) { @@ -297,6 +304,8 @@ bool patcher_putfieldconst(patchref_t *pr) 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. @@ -379,6 +388,8 @@ bool patcher_invokevirtual(patchref_t *pr) 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); @@ -415,6 +426,8 @@ bool patcher_invokeinterface(patchref_t *pr) 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); @@ -455,6 +468,8 @@ bool patcher_checkcast_interface(patchref_t *pr) if (c == NULL) return false; + pc += PATCHER_CALL_SIZE; + // Patch super class index. *((int32_t*) (pc + 7 + 3)) = c->index; @@ -493,6 +508,8 @@ bool patcher_instanceof_interface(patchref_t *pr) if (c == NULL) return false; + pc += PATCHER_CALL_SIZE; + // Patch super class index. *((int32_t*) (pc + 7 + 3)) = c->index; -- 2.25.1