Correct the clearing/destruction order when switching JITs.

Fixes #20502
This commit is contained in:
Henrik Rydgård
2025-06-11 16:07:26 +02:00
parent 28caa6fdb2
commit 6e84cd7f38
3 changed files with 24 additions and 20 deletions
+3 -2
View File
@@ -140,8 +140,9 @@ __attribute__((format(printf, 5, 6)))
// They can have a value between 0 and 15.
enum class DebugCounter {
APP_BOOT = 0,
GAME_BOOT = 0,
GAME_SHUTDOWN = 0,
GAME_BOOT = 1,
GAME_SHUTDOWN = 2,
CPUCORE_SWITCHES = 3,
};
bool HitAnyAsserts();
+3
View File
@@ -119,6 +119,9 @@ private:
class IRBlockCache : public JitBlockCacheDebugInterface {
public:
IRBlockCache(bool compileToNative);
~IRBlockCache() {
Clear();
}
void Clear();
std::vector<int> FindInvalidatedBlockNumbers(u32 address, u32 length);
+18 -18
View File
@@ -228,39 +228,39 @@ void MIPSState::UpdateCore(CPUCore desired) {
return;
}
PSP_CoreParameter().cpuCore = desired;
MIPSComp::JitInterface *oldjit = MIPSComp::jit;
MIPSComp::JitInterface *newjit = nullptr;
IncrementDebugCounter(DebugCounter::CPUCORE_SWITCHES);
// Get rid of the old JIT first, before switching.
{
std::lock_guard<std::recursive_mutex> guard(MIPSComp::jitLock);
if (MIPSComp::jit) {
delete MIPSComp::jit;
MIPSComp::jit = nullptr;
}
}
PSP_CoreParameter().cpuCore = desired;
MIPSComp::JitInterface *newjit = nullptr;
switch (PSP_CoreParameter().cpuCore) {
case CPUCore::JIT:
case CPUCore::JIT_IR:
INFO_LOG(Log::CPU, "Switching to JIT%s", PSP_CoreParameter().cpuCore == CPUCore::JIT_IR ? " IR" : "");
if (oldjit) {
std::lock_guard<std::recursive_mutex> guard(MIPSComp::jitLock);
MIPSComp::jit = nullptr;
delete oldjit;
}
newjit = MIPSComp::CreateNativeJit(this, PSP_CoreParameter().cpuCore == CPUCore::JIT_IR);
break;
case CPUCore::IR_INTERPRETER:
INFO_LOG(Log::CPU, "Switching to IR interpreter");
if (oldjit) {
std::lock_guard<std::recursive_mutex> guard(MIPSComp::jitLock);
MIPSComp::jit = nullptr;
delete oldjit;
}
newjit = new MIPSComp::IRJit(this, false);
break;
case CPUCore::INTERPRETER:
INFO_LOG(Log::CPU, "Switching to interpreter");
if (oldjit) {
std::lock_guard<std::recursive_mutex> guard(MIPSComp::jitLock);
MIPSComp::jit = nullptr;
delete oldjit;
}
// Leaving newjit as null.
break;
default:
WARN_LOG(Log::CPU, "Invalid value for cpuCore, falling back to interpreter");
break;
}