@@ -228,39 +228,39 @@ void MIPSState::UpdateCore(CPUCore desired) {
228
228
return ;
229
229
}
230
230
231
+ IncrementDebugCounter (DebugCounter::CPUCORE_SWITCHES);
232
+
233
+ // Get rid of the old JIT first, before switching.
234
+ {
235
+ std::lock_guard<std::recursive_mutex> guard (MIPSComp::jitLock);
236
+ if (MIPSComp::jit) {
237
+ delete MIPSComp::jit;
238
+ MIPSComp::jit = nullptr ;
239
+ }
240
+ }
241
+
231
242
PSP_CoreParameter ().cpuCore = desired;
232
- MIPSComp::JitInterface *oldjit = MIPSComp::jit;
233
- MIPSComp::JitInterface *newjit = nullptr ;
234
243
244
+ MIPSComp::JitInterface *newjit = nullptr ;
235
245
switch (PSP_CoreParameter ().cpuCore ) {
236
246
case CPUCore::JIT:
237
247
case CPUCore::JIT_IR:
238
248
INFO_LOG (Log::CPU, " Switching to JIT%s" , PSP_CoreParameter ().cpuCore == CPUCore::JIT_IR ? " IR" : " " );
239
- if (oldjit) {
240
- std::lock_guard<std::recursive_mutex> guard (MIPSComp::jitLock);
241
- MIPSComp::jit = nullptr ;
242
- delete oldjit;
243
- }
244
249
newjit = MIPSComp::CreateNativeJit (this , PSP_CoreParameter ().cpuCore == CPUCore::JIT_IR);
245
250
break ;
246
251
247
252
case CPUCore::IR_INTERPRETER:
248
253
INFO_LOG (Log::CPU, " Switching to IR interpreter" );
249
- if (oldjit) {
250
- std::lock_guard<std::recursive_mutex> guard (MIPSComp::jitLock);
251
- MIPSComp::jit = nullptr ;
252
- delete oldjit;
253
- }
254
254
newjit = new MIPSComp::IRJit (this , false );
255
255
break ;
256
256
257
257
case CPUCore::INTERPRETER:
258
258
INFO_LOG (Log::CPU, " Switching to interpreter" );
259
- if (oldjit) {
260
- std::lock_guard<std::recursive_mutex> guard (MIPSComp::jitLock) ;
261
- MIPSComp::jit = nullptr ;
262
- delete oldjit;
263
- }
259
+ // Leaving newjit as null.
260
+ break ;
261
+
262
+ default :
263
+ WARN_LOG (Log::CPU, " Invalid value for cpuCore, falling back to interpreter " );
264
264
break ;
265
265
}
266
266
0 commit comments