diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index 1d26f1d895..40aada1195 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -146,7 +146,7 @@ void Host_UpdateDisasmDialog() { } -void Host_JitCacheCleared() +void Host_JitCacheInvalidation() { } diff --git a/Source/Core/Core/GeckoCode.cpp b/Source/Core/Core/GeckoCode.cpp index d4c76df23e..92f389545d 100644 --- a/Source/Core/Core/GeckoCode.cpp +++ b/Source/Core/Core/GeckoCode.cpp @@ -17,6 +17,7 @@ #include "Core/Config/MainSettings.h" #include "Core/Core.h" +#include "Core/Host.h" #include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" #include "Core/System.h" @@ -196,6 +197,7 @@ static Installation InstallCodeHandlerLocked(const Core::CPUThreadGuard& guard) { ppc_state.iCache.Invalidate(memory, jit_interface, INSTALLER_BASE_ADDRESS + j); } + Host_JitCacheInvalidation(); return Installation::Installed; } diff --git a/Source/Core/Core/HLE/HLE.cpp b/Source/Core/Core/HLE/HLE.cpp index 0fafedfaa8..66d0960821 100644 --- a/Source/Core/Core/HLE/HLE.cpp +++ b/Source/Core/Core/HLE/HLE.cpp @@ -16,6 +16,7 @@ #include "Core/HLE/HLE_Misc.h" #include "Core/HLE/HLE_OS.h" #include "Core/HW/Memmap.h" +#include "Core/Host.h" #include "Core/IOS/ES/ES.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" @@ -74,6 +75,7 @@ void Patch(Core::System& system, u32 addr, std::string_view func_name) { s_hooked_addresses[addr] = i; ppc_state.iCache.Invalidate(memory, jit_interface, addr); + Host_JitCacheInvalidation(); return; } } @@ -144,6 +146,8 @@ void PatchFunctions(Core::System& system) INFO_LOG_FMT(OSHLE, "Patching {} {:08x}", os_patches[i].name, symbol->address); } } + + Host_JitCacheInvalidation(); } void Clear() @@ -264,6 +268,7 @@ u32 UnPatch(Core::System& system, std::string_view patch_name) ++i; } } + Host_JitCacheInvalidation(); return addr; } @@ -276,6 +281,7 @@ u32 UnPatch(Core::System& system, std::string_view patch_name) s_hooked_addresses.erase(addr); ppc_state.iCache.Invalidate(memory, jit_interface, addr); } + Host_JitCacheInvalidation(); return symbol->address; } @@ -299,6 +305,7 @@ u32 UnpatchRange(Core::System& system, u32 start_addr, u32 end_addr) i = s_hooked_addresses.erase(i); count += 1; } + Host_JitCacheInvalidation(); return count; } diff --git a/Source/Core/Core/Host.h b/Source/Core/Core/Host.h index 6d217f2650..9fd6a3c35f 100644 --- a/Source/Core/Core/Host.h +++ b/Source/Core/Core/Host.h @@ -60,7 +60,7 @@ void Host_PPCSymbolsChanged(); void Host_RefreshDSPDebuggerWindow(); void Host_RequestRenderWindowSize(int width, int height); void Host_UpdateDisasmDialog(); -void Host_JitCacheCleared(); +void Host_JitCacheInvalidation(); void Host_JitProfileDataWiped(); void Host_UpdateMainFrame(); void Host_UpdateTitle(const std::string& title); diff --git a/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp b/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp index dd012ce88f..b281ac0300 100644 --- a/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp +++ b/Source/Core/Core/PowerPC/CachedInterpreter/CachedInterpreter.cpp @@ -442,7 +442,7 @@ void CachedInterpreter::ClearCache() ClearCodeSpace(); ResetFreeMemoryRanges(); RefreshConfig(); - Host_JitCacheCleared(); + Host_JitCacheInvalidation(); } void CachedInterpreter::LogGeneratedCode() const diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 0201127a42..de2def0dbf 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -313,7 +313,7 @@ void Jit64::ClearCache() RefreshConfig(); asm_routines.Regenerate(); ResetFreeMemoryRanges(); - Host_JitCacheCleared(); + Host_JitCacheInvalidation(); } void Jit64::FreeRanges() diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index d50750dc35..b8f1d8cd73 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -197,7 +197,7 @@ void JitArm64::GenerateAsmAndResetFreeMemoryRanges() ResetFreeMemoryRanges(routines_near_end - routines_near_start, routines_far_end - routines_far_start); - Host_JitCacheCleared(); + Host_JitCacheInvalidation(); } void JitArm64::FreeRanges() diff --git a/Source/Core/Core/PowerPC/PowerPC.cpp b/Source/Core/Core/PowerPC/PowerPC.cpp index fec63c86d5..3cc1112bd7 100644 --- a/Source/Core/Core/PowerPC/PowerPC.cpp +++ b/Source/Core/Core/PowerPC/PowerPC.cpp @@ -57,6 +57,7 @@ static void InvalidateCacheThreadSafe(Core::System& system, u64 userdata, s64 cy { system.GetPPCState().iCache.Invalidate(system.GetMemory(), system.GetJitInterface(), static_cast(userdata)); + Host_JitCacheInvalidation(); } PowerPCManager::PowerPCManager(Core::System& system) @@ -296,6 +297,7 @@ void PowerPCManager::ScheduleInvalidateCacheThreadSafe(u32 address) { m_ppc_state.iCache.Invalidate(m_system.GetMemory(), m_system.GetJitInterface(), static_cast(address)); + Host_JitCacheInvalidation(); } } diff --git a/Source/Core/DolphinNoGUI/MainNoGUI.cpp b/Source/Core/DolphinNoGUI/MainNoGUI.cpp index f5aaae01ca..33490265b3 100644 --- a/Source/Core/DolphinNoGUI/MainNoGUI.cpp +++ b/Source/Core/DolphinNoGUI/MainNoGUI.cpp @@ -86,7 +86,7 @@ void Host_UpdateDisasmDialog() { } -void Host_JitCacheCleared() +void Host_JitCacheInvalidation() { } diff --git a/Source/Core/DolphinQt/Debugger/JITWidget.cpp b/Source/Core/DolphinQt/Debugger/JITWidget.cpp index f83b3a6c9c..39580e5030 100644 --- a/Source/Core/DolphinQt/Debugger/JITWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/JITWidget.cpp @@ -313,7 +313,7 @@ void JITWidget::SaveQSettings() const void JITWidget::ConnectSlots() { auto* const host = Host::GetInstance(); - connect(host, &Host::JitCacheCleared, this, &JITWidget::OnJitCacheCleared); + connect(host, &Host::JitCacheInvalidation, this, &JITWidget::OnJitCacheInvalidation); connect(host, &Host::UpdateDisasmDialog, this, &JITWidget::OnUpdateDisasmDialog); connect(host, &Host::PPCSymbolsChanged, this, &JITWidget::OnPPCSymbolsUpdated); connect(host, &Host::PPCBreakpointsChanged, this, &JITWidget::OnPPCBreakpointsChanged); @@ -326,7 +326,7 @@ void JITWidget::ConnectSlots() void JITWidget::DisconnectSlots() { auto* const host = Host::GetInstance(); - disconnect(host, &Host::JitCacheCleared, this, &JITWidget::OnJitCacheCleared); + disconnect(host, &Host::JitCacheInvalidation, this, &JITWidget::OnJitCacheInvalidation); disconnect(host, &Host::UpdateDisasmDialog, this, &JITWidget::OnUpdateDisasmDialog); disconnect(host, &Host::PPCSymbolsChanged, this, &JITWidget::OnPPCSymbolsUpdated); disconnect(host, &Host::PPCBreakpointsChanged, this, &JITWidget::OnPPCBreakpointsChanged); @@ -340,7 +340,7 @@ void JITWidget::Show() { ConnectSlots(); // Handle every slot that may have missed a signal while this widget was hidden. - // OnJitCacheCleared() can be skipped. + // OnJitCacheInvalidation() can be skipped. // OnUpdateDisasmDialog() can be skipped. // OnPPCSymbolsUpdated() can be skipped. // OnPPCBreakpointsChanged() can be skipped. @@ -446,7 +446,7 @@ void JITWidget::OnStatusBarPressed() ShowFreeMemoryStatus(); } -void JITWidget::OnJitCacheCleared() +void JITWidget::OnJitCacheInvalidation() { if (Core::GetState(m_system) != Core::State::Paused) return; diff --git a/Source/Core/DolphinQt/Debugger/JITWidget.h b/Source/Core/DolphinQt/Debugger/JITWidget.h index d192a8ee0a..02fd501348 100644 --- a/Source/Core/DolphinQt/Debugger/JITWidget.h +++ b/Source/Core/DolphinQt/Debugger/JITWidget.h @@ -102,7 +102,7 @@ private: void OnStatusBarPressed(); // Conditionally connected slots (external signals) - void OnJitCacheCleared(); + void OnJitCacheInvalidation(); void OnUpdateDisasmDialog(); void OnPPCSymbolsUpdated(); void OnPPCBreakpointsChanged(); diff --git a/Source/Core/DolphinQt/Debugger/JitBlockTableModel.cpp b/Source/Core/DolphinQt/Debugger/JitBlockTableModel.cpp index 27bece81cd..b9a003779f 100644 --- a/Source/Core/DolphinQt/Debugger/JitBlockTableModel.cpp +++ b/Source/Core/DolphinQt/Debugger/JitBlockTableModel.cpp @@ -112,7 +112,7 @@ void JitBlockTableModel::UpdateSymbols() void JitBlockTableModel::ConnectSlots() { auto* const host = Host::GetInstance(); - connect(host, &Host::JitCacheCleared, this, &JitBlockTableModel::OnJitCacheCleared); + connect(host, &Host::JitCacheInvalidation, this, &JitBlockTableModel::OnJitCacheInvalidation); connect(host, &Host::JitProfileDataWiped, this, &JitBlockTableModel::OnJitProfileDataWiped); connect(host, &Host::UpdateDisasmDialog, this, &JitBlockTableModel::OnUpdateDisasmDialog); connect(host, &Host::PPCSymbolsChanged, this, &JitBlockTableModel::OnPPCSymbolsUpdated); @@ -125,7 +125,7 @@ void JitBlockTableModel::ConnectSlots() void JitBlockTableModel::DisconnectSlots() { auto* const host = Host::GetInstance(); - disconnect(host, &Host::JitCacheCleared, this, &JitBlockTableModel::OnJitCacheCleared); + disconnect(host, &Host::JitCacheInvalidation, this, &JitBlockTableModel::OnJitCacheInvalidation); disconnect(host, &Host::JitProfileDataWiped, this, &JitBlockTableModel::OnJitProfileDataWiped); disconnect(host, &Host::UpdateDisasmDialog, this, &JitBlockTableModel::OnUpdateDisasmDialog); disconnect(host, &Host::PPCSymbolsChanged, this, &JitBlockTableModel::OnPPCSymbolsUpdated); @@ -169,7 +169,7 @@ void JitBlockTableModel::OnFilterSymbolTextChanged(const QString& string) m_filtering_by_symbols = !string.isEmpty(); } -void JitBlockTableModel::OnJitCacheCleared() +void JitBlockTableModel::OnJitCacheInvalidation() { Update(Core::GetState(m_system)); } @@ -187,7 +187,9 @@ void JitBlockTableModel::OnUpdateDisasmDialog() void JitBlockTableModel::OnPPCSymbolsUpdated() { - UpdateSymbols(); + // Previously, this was only a call to `UpdateSymbols`, but HLE patch engine code can + // invalidate JIT blocks when specific symbols are loaded. What can be done about it? + Update(Core::GetState(m_system)); } void JitBlockTableModel::OnPPCBreakpointsChanged() diff --git a/Source/Core/DolphinQt/Debugger/JitBlockTableModel.h b/Source/Core/DolphinQt/Debugger/JitBlockTableModel.h index eeaf2273d5..81028499cb 100644 --- a/Source/Core/DolphinQt/Debugger/JitBlockTableModel.h +++ b/Source/Core/DolphinQt/Debugger/JitBlockTableModel.h @@ -106,7 +106,7 @@ private: void Hide(); // Conditionally connected slots (external signals) - void OnJitCacheCleared(); + void OnJitCacheInvalidation(); void OnJitProfileDataWiped(); void OnUpdateDisasmDialog(); void OnPPCSymbolsUpdated(); diff --git a/Source/Core/DolphinQt/Host.cpp b/Source/Core/DolphinQt/Host.cpp index 3dc6f2a12b..f936986b5f 100644 --- a/Source/Core/DolphinQt/Host.cpp +++ b/Source/Core/DolphinQt/Host.cpp @@ -256,9 +256,9 @@ void Host_UpdateDisasmDialog() QueueOnObject(QApplication::instance(), [] { emit Host::GetInstance()->UpdateDisasmDialog(); }); } -void Host_JitCacheCleared() +void Host_JitCacheInvalidation() { - QueueOnObject(QApplication::instance(), [] { emit Host::GetInstance()->JitCacheCleared(); }); + QueueOnObject(QApplication::instance(), [] { emit Host::GetInstance()->JitCacheInvalidation(); }); } void Host_JitProfileDataWiped() diff --git a/Source/Core/DolphinQt/Host.h b/Source/Core/DolphinQt/Host.h index 4f3be255e8..cee44a2e6a 100644 --- a/Source/Core/DolphinQt/Host.h +++ b/Source/Core/DolphinQt/Host.h @@ -40,7 +40,7 @@ signals: void RequestStop(); void RequestRenderSize(int w, int h); void UpdateDisasmDialog(); - void JitCacheCleared(); + void JitCacheInvalidation(); void JitProfileDataWiped(); void PPCSymbolsChanged(); void PPCBreakpointsChanged(); diff --git a/Source/Core/DolphinTool/ToolHeadlessPlatform.cpp b/Source/Core/DolphinTool/ToolHeadlessPlatform.cpp index 4f445623b9..6e3f590a2d 100644 --- a/Source/Core/DolphinTool/ToolHeadlessPlatform.cpp +++ b/Source/Core/DolphinTool/ToolHeadlessPlatform.cpp @@ -61,7 +61,7 @@ void Host_UpdateDisasmDialog() { } -void Host_JitCacheCleared() +void Host_JitCacheInvalidation() { } diff --git a/Source/DSPTool/StubHost.cpp b/Source/DSPTool/StubHost.cpp index d54d005674..8fcd5d8d76 100644 --- a/Source/DSPTool/StubHost.cpp +++ b/Source/DSPTool/StubHost.cpp @@ -41,7 +41,7 @@ bool Host_UpdateDiscordPresenceRaw(const std::string& details, const std::string void Host_UpdateDisasmDialog() { } -void Host_JitCacheCleared() +void Host_JitCacheInvalidation() { } void Host_JitProfileDataWiped() diff --git a/Source/UnitTests/StubHost.cpp b/Source/UnitTests/StubHost.cpp index 96fe3e71d9..19d833bde3 100644 --- a/Source/UnitTests/StubHost.cpp +++ b/Source/UnitTests/StubHost.cpp @@ -41,7 +41,7 @@ bool Host_UpdateDiscordPresenceRaw(const std::string& details, const std::string void Host_UpdateDisasmDialog() { } -void Host_JitCacheCleared() +void Host_JitCacheInvalidation() { } void Host_JitProfileDataWiped()