aboutsummaryrefslogtreecommitdiff
path: root/src/lj_asm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_asm.c')
-rw-r--r--src/lj_asm.c45
1 files changed, 1 insertions, 44 deletions
diff --git a/src/lj_asm.c b/src/lj_asm.c
index 16671a8a..1103e998 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -147,14 +147,6 @@ IRFLDEF(FLOFS)
147 0 147 0
148}; 148};
149 149
150/* Define this if you want to run LuaJIT with Valgrind. */
151#ifdef LUAJIT_USE_VALGRIND
152#include <valgrind/valgrind.h>
153#define VG_INVALIDATE(p, sz) VALGRIND_DISCARD_TRANSLATIONS(p, sz)
154#else
155#define VG_INVALIDATE(p, sz) ((void)0)
156#endif
157
158/* -- Target-specific instruction emitter --------------------------------- */ 150/* -- Target-specific instruction emitter --------------------------------- */
159 151
160#if LJ_TARGET_X86ORX64 152#if LJ_TARGET_X86ORX64
@@ -931,41 +923,6 @@ static uint32_t ir_khash(IRIns *ir)
931 return hashrot(lo, hi); 923 return hashrot(lo, hi);
932} 924}
933 925
934#if !LJ_TARGET_X86ORX64 && LJ_TARGET_OSX
935void sys_icache_invalidate(void *start, size_t len);
936#endif
937
938#if LJ_TARGET_LINUX && LJ_TARGET_PPC
939#include <dlfcn.h>
940static void (*asm_ppc_cache_flush)(MCode *start, MCode *end);
941static void asm_dummy_cache_flush(MCode *start, MCode *end)
942{
943 UNUSED(start); UNUSED(end);
944}
945#endif
946
947/* Flush instruction cache. */
948static void asm_cache_flush(MCode *start, MCode *end)
949{
950 VG_INVALIDATE(start, (char *)end-(char *)start);
951#if LJ_TARGET_X86ORX64
952 UNUSED(start); UNUSED(end);
953#elif LJ_TARGET_OSX
954 sys_icache_invalidate(start, end-start);
955#elif LJ_TARGET_LINUX && LJ_TARGET_PPC
956 if (!asm_ppc_cache_flush) {
957 void *vdso = dlopen("linux-vdso32.so.1", RTLD_LAZY);
958 if (!vdso || !(asm_ppc_cache_flush = dlsym(vdso, "__kernel_sync_dicache")))
959 asm_ppc_cache_flush = asm_dummy_cache_flush;
960 }
961 asm_ppc_cache_flush(start, end);
962#elif defined(__GNUC__) && !LJ_TARGET_PPC
963 __clear_cache(start, end);
964#else
965#error "Missing builtin to flush instruction cache"
966#endif
967}
968
969/* -- Allocations --------------------------------------------------------- */ 926/* -- Allocations --------------------------------------------------------- */
970 927
971static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args); 928static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args);
@@ -1776,7 +1733,7 @@ void lj_asm_trace(jit_State *J, GCtrace *T)
1776 if (!as->loopref) 1733 if (!as->loopref)
1777 asm_tail_fixup(as, T->link); /* Note: this may change as->mctop! */ 1734 asm_tail_fixup(as, T->link); /* Note: this may change as->mctop! */
1778 T->szmcode = (MSize)((char *)as->mctop - (char *)as->mcp); 1735 T->szmcode = (MSize)((char *)as->mctop - (char *)as->mcp);
1779 asm_cache_flush(T->mcode, origtop); 1736 lj_mcode_sync(T->mcode, origtop);
1780} 1737}
1781 1738
1782#undef IR 1739#undef IR