CPU/CodeCache: Add InvalidateAll() method

This commit is contained in:
Connor McLaughlin 2021-12-02 18:40:31 +10:00
parent fe2062ff9f
commit c440593788
2 changed files with 47 additions and 27 deletions

View file

@ -836,11 +836,7 @@ void InvalidCodeFunction()
#endif
void InvalidateBlocksWithPageIndex(u32 page_index)
{
DebugAssert(page_index < Bus::RAM_8MB_CODE_PAGE_COUNT);
auto& blocks = m_ram_block_map[page_index];
for (CodeBlock* block : blocks)
static void InvalidateBlock(CodeBlock* block)
{
// Invalidate forces the block to be checked again.
Log_DebugPrintf("Invalidating block at 0x%08X", block->GetPC());
@ -869,11 +865,32 @@ void InvalidateBlocksWithPageIndex(u32 page_index)
#endif
}
void InvalidateBlocksWithPageIndex(u32 page_index)
{
DebugAssert(page_index < Bus::RAM_8MB_CODE_PAGE_COUNT);
auto& blocks = m_ram_block_map[page_index];
for (CodeBlock* block : blocks)
InvalidateBlock(block);
// Block will be re-added next execution.
blocks.clear();
Bus::ClearRAMCodePage(page_index);
}
void InvalidateAll()
{
for (auto& it : s_blocks)
{
CodeBlock* block = it.second;
if (block && !block->invalidated)
InvalidateBlock(block);
}
Bus::ClearRAMCodePageFlags();
for (auto& it : m_ram_block_map)
it.clear();
}
void RemoveReferencesToBlock(CodeBlock* block)
{
BlockMap::iterator iter = s_blocks.find(block->key.GetPC());

View file

@ -140,6 +140,9 @@ void Reinitialize();
/// Invalidates all blocks which are in the range of the specified code page.
void InvalidateBlocksWithPageIndex(u32 page_index);
/// Invalidates all blocks in the cache.
void InvalidateAll();
template<PGXPMode pgxp_mode>
void InterpretCachedBlock(const CodeBlock& block);