Fixes PR97.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 18 Aug 2008 09:22:59 +0000 (11:22 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 18 Aug 2008 09:22:59 +0000 (11:22 +0200)
* src/vm/jit/i386/md.h (md_cacheflush): Use a compiler optimization
barrier.
(md_icacheflush, md_dcacheflush): Likewise.
* src/vm/jit/i386/patcher.c (PATCH_BACK_ORIGINAL_MCODE): Use
md_icacheflush.

src/vm/jit/i386/md.h
src/vm/jit/i386/patcher.c

index 568f8e934d0115ac9bb15754eedc4e32cbb2346e..f5f2f915781ef1aea746413b348c4a65a1ed2f9a 100644 (file)
@@ -85,7 +85,8 @@ inline static void *md_codegen_get_pv_from_pc(void *ra)
 
 inline static void md_cacheflush(void *addr, int nbytes)
 {
-       /* do nothing */
+       // Compiler optimization barrier (see PR97).
+       __asm__ __volatile__ ("" : : : "memory");
 }
 
 
@@ -97,7 +98,8 @@ inline static void md_cacheflush(void *addr, int nbytes)
 
 inline static void md_icacheflush(void *addr, int nbytes)
 {
-       /* do nothing */
+       // Compiler optimization barrier (see PR97).
+       __asm__ __volatile__ ("" : : : "memory");
 }
 
 
@@ -109,7 +111,8 @@ inline static void md_icacheflush(void *addr, int nbytes)
 
 inline static void md_dcacheflush(void *addr, int nbytes)
 {
-       /* do nothing */
+       // Compiler optimization barrier (see PR97).
+       __asm__ __volatile__ ("" : : : "memory");
 }
 
 #endif /* _VM_JIT_I386_MD_H */
index 438ce1bf4aa1301a6b88f575e4e6c9de21f49e55..61d853bf38f29b339269f59e16c429b4c67ecaad 100644 (file)
@@ -30,6 +30,7 @@
 #include "vm/types.h"
 
 #include "vm/jit/i386/codegen.h"
+#include "vm/jit/i386/md.h"
 
 #include "mm/memory.h"
 
 #include "vm/jit/patcher-common.h"
 
 
-#define PATCH_BACK_ORIGINAL_MCODE *((u2 *) pr->mpc) = (u2) pr->mcode
+#define PATCH_BACK_ORIGINAL_MCODE                                                      \
+       do {                                                                                                    \
+               *((uint16_t*) pr->mpc) = (uint16_t) pr->mcode;          \
+               md_icacheflush((void*) pr->mpc, PATCHER_CALL_SIZE);     \
+       } while (0)
 
 
 /* patcher_patch_code **********************************************************