diff --git a/BasiliskII/src/MacOSX/main_macosx.mm b/BasiliskII/src/MacOSX/main_macosx.mm index 6697ae0a..a2e40fd5 100644 --- a/BasiliskII/src/MacOSX/main_macosx.mm +++ b/BasiliskII/src/MacOSX/main_macosx.mm @@ -54,7 +54,7 @@ using std::string; #include "xpram.h" #if USE_JIT -extern void flush_icache_range(uint32 start, uint32 size); // from compemu_support.cpp +extern void flush_icache_range(uint8 *start, uint32 size); // from compemu_support.cpp #endif #ifdef ENABLE_MON @@ -498,7 +498,7 @@ void FlushCodeCache(void *start, uint32 size) { #if USE_JIT if (UseJIT) - flush_icache_range((uintptr)start, size); + flush_icache_range((uint8 *)start, size); #endif } diff --git a/BasiliskII/src/Unix/main_unix.cpp b/BasiliskII/src/Unix/main_unix.cpp index 7ff57750..68727443 100644 --- a/BasiliskII/src/Unix/main_unix.cpp +++ b/BasiliskII/src/Unix/main_unix.cpp @@ -89,7 +89,7 @@ using std::string; #include "rpc.h" #if USE_JIT -extern void flush_icache_range(uint32 start, uint32 size); // from compemu_support.cpp +extern void flush_icache_range(uint8 *start, uint32 size); // from compemu_support.cpp #endif #ifdef ENABLE_MON @@ -945,7 +945,7 @@ void FlushCodeCache(void *start, uint32 size) { #if USE_JIT if (UseJIT) - flush_icache_range((uintptr)start, size); + flush_icache_range((uint8 *)start, size); #endif #if !EMULATED_68K && defined(__NetBSD__) m68k_sync_icache(start, size); diff --git a/BasiliskII/src/Windows/main_windows.cpp b/BasiliskII/src/Windows/main_windows.cpp index d42ea2f0..4dc357cc 100755 --- a/BasiliskII/src/Windows/main_windows.cpp +++ b/BasiliskII/src/Windows/main_windows.cpp @@ -52,7 +52,7 @@ using std::string; #include "kernel_windows.h" #if USE_JIT -extern void flush_icache_range(uint32 start, uint32 size); // from compemu_support.cpp +extern void flush_icache_range(uint8 *start, uint32 size); // from compemu_support.cpp #endif #ifdef ENABLE_MON @@ -517,7 +517,7 @@ void FlushCodeCache(void *start, uint32 size) { #if USE_JIT if (UseJIT) - flush_icache_range((uintptr)start, size); + flush_icache_range((uint8 *)start, size); #endif } diff --git a/BasiliskII/src/uae_cpu/compiler/compemu_support.cpp b/BasiliskII/src/uae_cpu/compiler/compemu_support.cpp index d6edce3e..c50271b2 100644 --- a/BasiliskII/src/uae_cpu/compiler/compemu_support.cpp +++ b/BasiliskII/src/uae_cpu/compiler/compemu_support.cpp @@ -6420,33 +6420,48 @@ static inline void flush_icache_lazy(int n) active=NULL; } -void flush_icache_range(uae_u32 start, uae_u32 length) +void flush_icache_range(uae_u8 *start_p, uae_u32 length) { if (!active) return; #if LAZY_FLUSH_ICACHE_RANGE - uae_u8 *start_p = get_real_address(start); blockinfo *bi = active; while (bi) { #if USE_CHECKSUM_INFO - bool invalidate = false; - for (checksum_info *csi = bi->csi; csi && !invalidate; csi = csi->next) - invalidate = (((start_p - csi->start_p) < csi->length) || - ((csi->start_p - start_p) < length)); + bool candidate = false; + for (checksum_info *csi = bi->csi; csi; csi = csi->next) { + if (((start_p - csi->start_p) < csi->length) || + ((csi->start_p - start_p) < length)) { + candidate = true; + break; + } + } #else // Assume system is consistent and would invalidate the right range - const bool invalidate = (bi->pc_p - start_p) < length; + const bool candidate = (bi->pc_p - start_p) < length; #endif - if (invalidate) { - uae_u32 cl = cacheline(bi->pc_p); - if (bi == cache_tags[cl + 1].bi) - cache_tags[cl].handler = (cpuop_func *)popall_execute_normal; - bi->handler_to_use = (cpuop_func *)popall_execute_normal; - set_dhtu(bi, bi->direct_pen); - bi->status = BI_NEED_RECOMP; - } + blockinfo *dbi = bi; bi = bi->next; + if (candidate) { + uae_u32 cl = cacheline(dbi->pc_p); + if (dbi->status == BI_INVALID || dbi->status == BI_NEED_RECOMP) { + if (dbi == cache_tags[cl+1].bi) + cache_tags[cl].handler = (cpuop_func *)popall_execute_normal; + dbi->handler_to_use = (cpuop_func *)popall_execute_normal; + set_dhtu(dbi, dbi->direct_pen); + dbi->status = BI_INVALID; + } + else { + if (dbi == cache_tags[cl+1].bi) + cache_tags[cl].handler = (cpuop_func *)popall_check_checksum; + dbi->handler_to_use = (cpuop_func *)popall_check_checksum; + set_dhtu(dbi, dbi->direct_pcc); + dbi->status = BI_NEED_CHECK; + } + remove_from_list(dbi); + add_to_dormant(dbi); + } } return; #endif