Skip to content

Commit

Permalink
CPU/CodeCache: Clear blocks on system shutdown
Browse files Browse the repository at this point in the history
Means we release all allocated memory on system shutdown, rather
than waiting until the next VM/system start.
  • Loading branch information
stenzek committed Nov 5, 2024
1 parent d0ad4e7 commit 8bd0e6c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/cpu_code_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ void CPU::CodeCache::Reset()
}
}

void CPU::CodeCache::Shutdown()
{
ClearBlocks();
}

void CPU::CodeCache::Execute()
{
if (IsUsingAnyRecompiler())
Expand Down
3 changes: 3 additions & 0 deletions src/core/cpu_code_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ void ProcessShutdown();
/// Flushes the code cache, forcing all blocks to be recompiled.
void Reset();

/// Free all non-persistent resources for the code cache.
void Shutdown();

/// Invalidates all blocks which are in the range of the specified code page.
void InvalidateBlocksWithPageIndex(u32 page_index);

Expand Down
1 change: 1 addition & 0 deletions src/core/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,7 @@ void System::DestroySystem()
CDROM::Shutdown();
g_gpu.reset();
DMA::Shutdown();
CPU::CodeCache::Shutdown();
CPU::PGXP::Shutdown();
CPU::Shutdown();
Bus::Shutdown();
Expand Down

0 comments on commit 8bd0e6c

Please sign in to comment.