* src/vm/jit/patcher-common.cpp: Conditionally restored NOP-insertion at
authorStefan Ring <stefan@complang.tuwien.ac.at>
Sat, 14 Nov 2009 14:56:58 +0000 (15:56 +0100)
committerStefan Ring <stefan@complang.tuwien.ac.at>
Sat, 14 Nov 2009 14:56:58 +0000 (15:56 +0100)
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
src/vm/jit/x86_64/arch.h
src/vm/jit/x86_64/patcher.c

index 216b4fc856f6cb3e7acef6d458c5703146ca262f..57c6fdb39005537ba738f0c2e160324d418083d1 100644 (file)
@@ -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;
 
index 80ac34246003c2bf23ac998e5450249c9dd45f9e..ef425cb2148fa98812c8c205de464d3f913bd3f7 100644 (file)
 
 #define CAS_PROVIDES_FULL_BARRIER        1
 
+#define USES_PATCHABLE_MEMORY_BARRIER    1
+
 #endif /* _ARCH_H */
 
 
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */
index ae4b7aa2131eb14c9949dca08ab808ba38f185ab..81cc09e0e8bbc78583471327af0d14c9203634c0 100644 (file)
@@ -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;