Fix for LAZY_FLUSH_ICACHE_RANGE. Blocks are indexed by native addresses.

This commit is contained in:
gbeauche 2006-05-08 16:56:07 +00:00
parent ecdc036c69
commit 24af8d27c3
4 changed files with 36 additions and 21 deletions

View File

@ -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
}

View File

@ -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);

View File

@ -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
}

View File

@ -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