JitCache: Extract ErasePhysicalRange as function.
This commit is contained in:
parent
70caf447b9
commit
7f6b8e3555
|
@ -36,9 +36,10 @@ static void ClearCacheThreadSafe(u64 userdata, s64 cyclesdata)
|
|||
JitInterface::ClearCache();
|
||||
}
|
||||
|
||||
bool JitBlock::Overlap(u32 addr, u32 length)
|
||||
bool JitBlock::OverlapsPhysicalRange(u32 address, u32 length) const
|
||||
{
|
||||
return physical_addresses.lower_bound(addr) != physical_addresses.lower_bound(addr + length);
|
||||
return physical_addresses.lower_bound(address) !=
|
||||
physical_addresses.lower_bound(address + length);
|
||||
}
|
||||
|
||||
JitBaseBlockCache::JitBaseBlockCache(JitBase& jit) : m_jit{jit}
|
||||
|
@ -182,7 +183,7 @@ const u8* JitBaseBlockCache::Dispatch()
|
|||
return block->normalEntry;
|
||||
}
|
||||
|
||||
void JitBaseBlockCache::InvalidateICache(u32 address, const u32 length, bool forced)
|
||||
void JitBaseBlockCache::InvalidateICache(u32 address, u32 length, bool forced)
|
||||
{
|
||||
auto translated = PowerPC::JitCache_TranslateAddress(address);
|
||||
if (!translated.valid)
|
||||
|
@ -199,13 +200,32 @@ void JitBaseBlockCache::InvalidateICache(u32 address, const u32 length, bool for
|
|||
valid_block.Clear(pAddr / 32);
|
||||
}
|
||||
|
||||
// destroy JIT blocks
|
||||
if (destroy_block)
|
||||
{
|
||||
// destroy JIT blocks
|
||||
ErasePhysicalRange(pAddr, length);
|
||||
|
||||
// If the code was actually modified, we need to clear the relevant entries from the
|
||||
// FIFO write address cache, so we don't end up with FIFO checks in places they shouldn't
|
||||
// be (this can clobber flags, and thus break any optimization that relies on flags
|
||||
// being in the right place between instructions).
|
||||
if (!forced)
|
||||
{
|
||||
for (u32 i = address; i < address + length; i += 4)
|
||||
{
|
||||
m_jit.js.fifoWriteAddresses.erase(i);
|
||||
m_jit.js.pairedQuantizeAddresses.erase(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JitBaseBlockCache::ErasePhysicalRange(u32 address, u32 length)
|
||||
{
|
||||
// Iterate over all macro blocks which overlap the given range.
|
||||
u32 range_mask = ~(BLOCK_RANGE_MAP_ELEMENTS - 1);
|
||||
auto start = block_range_map.lower_bound(pAddr & range_mask);
|
||||
auto end = block_range_map.lower_bound(pAddr + length);
|
||||
auto start = block_range_map.lower_bound(address & range_mask);
|
||||
auto end = block_range_map.lower_bound(address + length);
|
||||
while (start != end)
|
||||
{
|
||||
// Iterate over all blocks in the macro block.
|
||||
|
@ -213,7 +233,7 @@ void JitBaseBlockCache::InvalidateICache(u32 address, const u32 length, bool for
|
|||
while (iter != start->second.end())
|
||||
{
|
||||
JitBlock* block = *iter;
|
||||
if (block->Overlap(pAddr, length))
|
||||
if (block->OverlapsPhysicalRange(address, length))
|
||||
{
|
||||
// If the block overlaps, also remove all other occupied slots in the other macro blocks.
|
||||
// This will leak empty macro blocks, but they may be reused or cleared later on.
|
||||
|
@ -238,20 +258,6 @@ void JitBaseBlockCache::InvalidateICache(u32 address, const u32 length, bool for
|
|||
else
|
||||
start++;
|
||||
}
|
||||
|
||||
// If the code was actually modified, we need to clear the relevant entries from the
|
||||
// FIFO write address cache, so we don't end up with FIFO checks in places they shouldn't
|
||||
// be (this can clobber flags, and thus break any optimization that relies on flags
|
||||
// being in the right place between instructions).
|
||||
if (!forced)
|
||||
{
|
||||
for (u32 i = address; i < address + length; i += 4)
|
||||
{
|
||||
m_jit.js.fifoWriteAddresses.erase(i);
|
||||
m_jit.js.pairedQuantizeAddresses.erase(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32* JitBaseBlockCache::GetBlockBitSet() const
|
||||
|
|
|
@ -25,7 +25,7 @@ class JitBase;
|
|||
// address.
|
||||
struct JitBlock
|
||||
{
|
||||
bool Overlap(u32 addr, u32 length);
|
||||
bool OverlapsPhysicalRange(u32 address, u32 length) const;
|
||||
|
||||
// A special entry point for block linking; usually used to check the
|
||||
// downcount.
|
||||
|
@ -143,7 +143,8 @@ public:
|
|||
// assembly version.)
|
||||
const u8* Dispatch();
|
||||
|
||||
void InvalidateICache(u32 address, const u32 length, bool forced);
|
||||
void InvalidateICache(u32 address, u32 length, bool forced);
|
||||
void ErasePhysicalRange(u32 address, u32 length);
|
||||
|
||||
u32* GetBlockBitSet() const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue