diff --git a/Core/HLE/HLE.cpp b/Core/HLE/HLE.cpp index 0a2531a5d7..32aefdd462 100644 --- a/Core/HLE/HLE.cpp +++ b/Core/HLE/HLE.cpp @@ -493,18 +493,16 @@ const HLEFunction *GetSyscallFuncPointer(MIPSOpcode op) return &moduleDB[modulenum].funcTable[funcnum]; } -void *GetQuickSyscallFunc(MIPSOpcode op) -{ - // TODO: Clear jit cache on g_Config.bShowDebugStats change? - if (g_Config.bShowDebugStats) - return NULL; +void *GetQuickSyscallFunc(MIPSOpcode op) { + if (coreCollectDebugStats) + return nullptr; const HLEFunction *info = GetSyscallFuncPointer(op); if (!info || !info->func) - return NULL; + return nullptr; // TODO: Do this with a flag? - if (op == GetSyscallOp("FakeSysCalls", NID_IDLE)) + if (op == idleOp) return (void *)info->func; if (info->flags != 0) return (void *)&CallSyscallWithFlags; @@ -520,8 +518,8 @@ void hleSetSteppingTime(double t) void CallSyscall(MIPSOpcode op) { PROFILE_THIS_SCOPE("syscall"); - double start = 0.0; // need to initialize to fix the race condition where g_Config.bShowDebugStats is enabled in the middle of this func. - if (g_Config.bShowDebugStats) + double start = 0.0; // need to initialize to fix the race condition where coreCollectDebugStats is enabled in the middle of this func. + if (coreCollectDebugStats) { time_update(); start = time_now_d(); @@ -546,7 +544,7 @@ void CallSyscall(MIPSOpcode op) ERROR_LOG_REPORT(HLE, "Unimplemented HLE function %s", info->name ? info->name : "(\?\?\?)"); } - if (g_Config.bShowDebugStats) + if (coreCollectDebugStats) { time_update(); u32 callno = (op >> 6) & 0xFFFFF; //20 bits diff --git a/Core/System.cpp b/Core/System.cpp index 8211a675ff..159d212fe5 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -86,6 +86,9 @@ static std::condition_variable cpuThreadReplyCond; static u64 cpuThreadUntil; bool audioInitialized; +bool coreCollectDebugStats = false; +bool coreCollectDebugStatsForced = false; + // This can be read and written from ANYWHERE. volatile CoreState coreState = CORE_STEPPING; // Note: intentionally not used for CORE_NEXTFRAME. @@ -367,6 +370,20 @@ void Core_UpdateState(CoreState newState) { Core_UpdateSingleStep(); } +void Core_ForceCollectDebugStats(bool flag) { + // Don't set the real flag yet, since it may trigger clearing jit cache. + coreCollectDebugStatsForced = flag; +} + +static void Core_UpdateCollectDebugStats(bool flag) { + bool newFlag = flag || coreCollectDebugStatsForced; + + if (coreCollectDebugStats != newFlag) { + coreCollectDebugStats = newFlag; + mipsr4k.ClearJitCache(); + } +} + void System_Wake() { // Ping the threads so they check coreState. CPU_NextStateNot(CPU_THREAD_NOT_RUNNING, CPU_THREAD_SHUTDOWN); @@ -517,6 +534,8 @@ void PSP_EndHostFrame() { } void PSP_RunLoopUntil(u64 globalticks) { + Core_UpdateCollectDebugStats(g_Config.bShowDebugStats); + SaveState::Process(); if (coreState == CORE_POWERDOWN || coreState == CORE_ERROR) { return; diff --git a/Core/System.h b/Core/System.h index b9c5feadf6..87851ee20a 100644 --- a/Core/System.h +++ b/Core/System.h @@ -97,6 +97,9 @@ enum CoreState CORE_ERROR, }; +extern bool coreCollectDebugStats; +void Core_ForceCollectDebugStats(bool flag); + extern volatile CoreState coreState; extern volatile bool coreStatePending; void Core_UpdateState(CoreState newState); diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index dac13fe626..4e28d5f1d9 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -848,13 +848,13 @@ u32 GPUCommon::Break(int mode) { } void GPUCommon::NotifySteppingEnter() { - if (g_Config.bShowDebugStats) { + if (coreCollectDebugStats) { time_update(); timeSteppingStarted_ = time_now_d(); } } void GPUCommon::NotifySteppingExit() { - if (g_Config.bShowDebugStats) { + if (coreCollectDebugStats) { if (timeSteppingStarted_ <= 0.0) { ERROR_LOG(G3D, "Mismatched stepping enter/exit."); } @@ -867,7 +867,7 @@ void GPUCommon::NotifySteppingExit() { bool GPUCommon::InterpretList(DisplayList &list) { // Initialized to avoid a race condition with bShowDebugStats changing. double start = 0.0; - if (g_Config.bShowDebugStats) { + if (coreCollectDebugStats) { time_update(); start = time_now_d(); } @@ -936,7 +936,7 @@ bool GPUCommon::InterpretList(DisplayList &list) { list.offsetAddr = gstate_c.offsetAddr; - if (g_Config.bShowDebugStats) { + if (coreCollectDebugStats) { time_update(); double total = time_now_d() - start - timeSpentStepping_; hleSetSteppingTime(timeSpentStepping_); @@ -984,7 +984,7 @@ void GPUCommon::UpdatePC(u32 currentPC, u32 newPC) { cyclesExecuted += 2 * executed; cycleLastPC = newPC; - if (g_Config.bShowDebugStats) { + if (coreCollectDebugStats) { gpuStats.otherGPUCycles += 2 * executed; gpuStats.gpuCommandsAtCallLevel[std::min(currentList->stackptr, 3)] += executed; } @@ -2459,4 +2459,4 @@ bool GPUCommon::GetOutputFramebuffer(GPUDebugBuffer &buffer) { bool GPUCommon::GetCurrentTexture(GPUDebugBuffer &buffer, int level) { return textureCache_->GetCurrentTextureDebug(buffer, level); -} \ No newline at end of file +}