From 8bd0e6c3f775fd9e460df1e7db3b58a836046232 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Tue, 5 Nov 2024 13:06:44 +1000 Subject: [PATCH] CPU/CodeCache: Clear blocks on system shutdown Means we release all allocated memory on system shutdown, rather than waiting until the next VM/system start. --- src/core/cpu_code_cache.cpp | 5 +++++ src/core/cpu_code_cache.h | 3 +++ src/core/system.cpp | 1 + 3 files changed, 9 insertions(+) diff --git a/src/core/cpu_code_cache.cpp b/src/core/cpu_code_cache.cpp index c9e16e0cb..1bdd6aef6 100644 --- a/src/core/cpu_code_cache.cpp +++ b/src/core/cpu_code_cache.cpp @@ -225,6 +225,11 @@ void CPU::CodeCache::Reset() } } +void CPU::CodeCache::Shutdown() +{ + ClearBlocks(); +} + void CPU::CodeCache::Execute() { if (IsUsingAnyRecompiler()) diff --git a/src/core/cpu_code_cache.h b/src/core/cpu_code_cache.h index 9b4e46f41..6ed9e7d1b 100644 --- a/src/core/cpu_code_cache.h +++ b/src/core/cpu_code_cache.h @@ -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); diff --git a/src/core/system.cpp b/src/core/system.cpp index c8e64f7e5..12cc320c5 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1975,6 +1975,7 @@ void System::DestroySystem() CDROM::Shutdown(); g_gpu.reset(); DMA::Shutdown(); + CPU::CodeCache::Shutdown(); CPU::PGXP::Shutdown(); CPU::Shutdown(); Bus::Shutdown();