Merge pull request #7235 from spycrab/jit_disable_following

Core/PowerPC: Add option to disable branch following
This commit is contained in:
spycrab 2018-07-09 23:22:08 +02:00 committed by GitHub
commit 31bc017593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 3 deletions

View File

@ -1,4 +1,7 @@
# Nxxxxx - All Nintendo 64 Virtual Console games
[Core]
JITFollowBranch = False
[Video_Settings]
SuggestedAspectRatio = 2

View File

@ -240,6 +240,8 @@ bool BootCore(std::unique_ptr<BootParameters> 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);

View File

@ -17,8 +17,8 @@ namespace Config
{
// Main.Core
extern const ConfigInfo<bool> MAIN_SKIP_IPL;
extern const ConfigInfo<PowerPC::CPUCore> MAIN_CPU_CORE;
extern const ConfigInfo<bool> MAIN_JIT_FOLLOW_BRANCH;
extern const ConfigInfo<bool> 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<bool> MAIN_DSP_HLE;

View File

@ -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);

View File

@ -83,6 +83,7 @@ struct SConfig
PowerPC::CPUCore cpu_core;
bool bJITFollowBranch;
bool bJITNoBlockCache = false;
bool bJITNoBlockLinking = false;
bool bJITOff = false;

View File

@ -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;

View File

@ -104,7 +104,8 @@ struct DTMHeader
bool bPAL60;
u8 language;
bool bReducePollingRate;
std::array<u8, 10> reserved; // Padding for any new config options
bool bFollowBranch;
std::array<u8, 9> reserved; // Padding for any new config options
std::array<char, 40> discChange; // Name of iso file to switch to, for two disc games.
std::array<u8, 20> revision; // Git hash
u32 DSPiromHash;

View File

@ -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)
{