From df61e527dacb523e6f71d00f7d8d79d2c391d257 Mon Sep 17 00:00:00 2001 From: spycrab Date: Sun, 8 Jul 2018 21:26:34 +0200 Subject: [PATCH 1/2] Core/PowerPC: Add option to disable branch following --- Source/Core/Core/BootManager.cpp | 2 ++ Source/Core/Core/Config/MainSettings.h | 2 +- Source/Core/Core/ConfigManager.cpp | 2 ++ Source/Core/Core/ConfigManager.h | 1 + Source/Core/Core/Movie.cpp | 2 ++ Source/Core/Core/Movie.h | 3 ++- Source/Core/Core/PowerPC/PPCAnalyst.cpp | 5 ++++- 7 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/BootManager.cpp b/Source/Core/Core/BootManager.cpp index f9848189f8..86ff53bd77 100644 --- a/Source/Core/Core/BootManager.cpp +++ b/Source/Core/Core/BootManager.cpp @@ -240,6 +240,8 @@ bool BootCore(std::unique_ptr boot) IniFile::Section* controls_section = game_ini.GetOrCreateSection("Controls"); core_section->Get("CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread); + + core_section->Get("JITFollowBranch", &StartUp.bJITFollowBranch, StartUp.bJITFollowBranch); core_section->Get("EnableCheats", &StartUp.bEnableCheats, StartUp.bEnableCheats); core_section->Get("SyncOnSkipIdle", &StartUp.bSyncGPUOnSkipIdleHack, StartUp.bSyncGPUOnSkipIdleHack); diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index e798049786..e23e96882d 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -17,8 +17,8 @@ namespace Config { // Main.Core -extern const ConfigInfo MAIN_SKIP_IPL; extern const ConfigInfo MAIN_CPU_CORE; +extern const ConfigInfo MAIN_JIT_FOLLOW_BRANCH; extern const ConfigInfo MAIN_FASTMEM; // Should really be in the DSP section, but we're kind of stuck with bad decisions made in the past. extern const ConfigInfo MAIN_DSP_HLE; diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 97e8ff3c99..0b2c3a3a25 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -219,6 +219,7 @@ void SConfig::SaveCoreSettings(IniFile& ini) core->Set("SkipIPL", bHLE_BS2); core->Set("TimingVariance", iTimingVariance); core->Set("CPUCore", cpu_core); + core->Set("JITFollowBranch", bJITFollowBranch); core->Set("Fastmem", bFastmem); core->Set("CPUThread", bCPUThread); core->Set("DSPHLE", bDSPHLE); @@ -510,6 +511,7 @@ void SConfig::LoadCoreSettings(IniFile& ini) #else core->Get("CPUCore", &cpu_core, PowerPC::CPUCore::Interpreter); #endif + core->Get("JITFollowBranch", &bJITFollowBranch, true); core->Get("Fastmem", &bFastmem, true); core->Get("DSPHLE", &bDSPHLE, true); core->Get("TimingVariance", &iTimingVariance, 40); diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 40f8cdf217..faed2d4a0a 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -83,6 +83,7 @@ struct SConfig PowerPC::CPUCore cpu_core; + bool bJITFollowBranch; bool bJITNoBlockCache = false; bool bJITNoBlockLinking = false; bool bJITOff = false; diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index ce7df4a2b1..7a32e04410 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -851,6 +851,7 @@ void ReadHeader() { s_bSaveConfig = true; Config::AddLayer(ConfigLoaders::GenerateMovieConfigLoader(&tmpHeader)); + SConfig::GetInstance().bJITFollowBranch = tmpHeader.bFollowBranch; s_bClearSave = tmpHeader.bClearSave; s_memcards = tmpHeader.memcards; s_bongos = tmpHeader.bongos; @@ -1307,6 +1308,7 @@ void SaveRecording(const std::string& filename) header.filetype[3] = 0x1A; strncpy(header.gameID.data(), SConfig::GetInstance().GetGameID().c_str(), 6); header.bWii = SConfig::GetInstance().bWii; + header.bFollowBranch = SConfig::GetInstance().bJITFollowBranch; header.controllers = s_controllers & (SConfig::GetInstance().bWii ? 0xFF : 0x0F); header.bFromSaveState = s_bRecordingFromSaveState; diff --git a/Source/Core/Core/Movie.h b/Source/Core/Core/Movie.h index ee599d7777..11a700f18b 100644 --- a/Source/Core/Core/Movie.h +++ b/Source/Core/Core/Movie.h @@ -104,7 +104,8 @@ struct DTMHeader bool bPAL60; u8 language; bool bReducePollingRate; - std::array reserved; // Padding for any new config options + bool bFollowBranch; + std::array reserved; // Padding for any new config options std::array discChange; // Name of iso file to switch to, for two disc games. std::array revision; // Git hash u32 DSPiromHash; diff --git a/Source/Core/Core/PowerPC/PPCAnalyst.cpp b/Source/Core/Core/PowerPC/PPCAnalyst.cpp index b65108f7a8..b4f270bfa0 100644 --- a/Source/Core/Core/PowerPC/PPCAnalyst.cpp +++ b/Source/Core/Core/PowerPC/PPCAnalyst.cpp @@ -14,6 +14,7 @@ #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/PowerPC/JitCommon/JitBase.h" #include "Core/PowerPC/MMU.h" @@ -671,6 +672,8 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, std: u32 numFollows = 0; u32 num_inst = 0; + const bool enable_follow = SConfig::GetInstance().bJITFollowBranch; + for (std::size_t i = 0; i < block_size; ++i) { auto result = PowerPC::TryReadInstruction(address); @@ -706,7 +709,7 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, std: // If it is small, the performance will be down. // If it is big, the size of generated code will be big and // cache clearning will happen many times. - if (HasOption(OPTION_BRANCH_FOLLOW) && numFollows < BRANCH_FOLLOWING_THRESHOLD) + if (enable_follow && HasOption(OPTION_BRANCH_FOLLOW) && numFollows < BRANCH_FOLLOWING_THRESHOLD) { if (inst.OPCD == 18 && block_size > 1) { From b2f1945187662ff73f82a71d243e920a3ad47bed Mon Sep 17 00:00:00 2001 From: spycrab Date: Mon, 9 Jul 2018 22:39:20 +0200 Subject: [PATCH 2/2] GameINI/N: Disable branch following by default --- Data/Sys/GameSettings/N.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Data/Sys/GameSettings/N.ini b/Data/Sys/GameSettings/N.ini index 0effba7558..c8a3b940fb 100644 --- a/Data/Sys/GameSettings/N.ini +++ b/Data/Sys/GameSettings/N.ini @@ -1,4 +1,7 @@ # Nxxxxx - All Nintendo 64 Virtual Console games +[Core] +JITFollowBranch = False + [Video_Settings] SuggestedAspectRatio = 2