Config: Port remaining Interface settings to new config system.

This commit is contained in:
Admiral H. Curtiss 2021-12-31 03:00:39 +01:00
commit d6331c1e71
No known key found for this signature in database
GPG key ID: F051B4C4044F33FB
30 changed files with 135 additions and 162 deletions

View file

@ -273,8 +273,8 @@ void CachedInterpreter::Jit(u32 address)
if (!op.skip)
{
const bool breakpoint = SConfig::GetInstance().bEnableDebugging &&
PowerPC::breakpoints.IsAddressBreakPoint(op.address);
const bool breakpoint =
m_enable_debugging && PowerPC::breakpoints.IsAddressBreakPoint(op.address);
const bool check_fpu = (op.opinfo->flags & FL_USE_FPU) && !js.firstFPInstructionFound;
const bool endblock = (op.opinfo->flags & FL_ENDBLOCK) != 0;
const bool memcheck = (op.opinfo->flags & FL_LOADSTORE) && jo.memcheck;

View file

@ -14,7 +14,7 @@
#include "Common/GekkoDisassembler.h"
#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"
#include "Core/Config/MainSettings.h"
#include "Core/CoreTiming.h"
#include "Core/Debugger/Debugger_SymbolMap.h"
#include "Core/HLE/HLE.h"
@ -247,7 +247,7 @@ void Interpreter::Run()
CoreTiming::Advance();
// we have to check exceptions at branches apparently (or maybe just rfi?)
if (SConfig::GetInstance().bEnableDebugging)
if (Config::Get(Config::MAIN_ENABLE_DEBUGGING))
{
#ifdef SHOW_HISTORY
s_pc_block_vec.push_back(PC);

View file

@ -355,8 +355,8 @@ void Jit64::Init()
// BLR optimization has the same consequences as block linking, as well as
// depending on the fault handler to be safe in the event of excessive BL.
m_enable_blr_optimization = jo.enableBlocklink && SConfig::GetInstance().bFastmem &&
!SConfig::GetInstance().bEnableDebugging;
m_enable_blr_optimization =
jo.enableBlocklink && SConfig::GetInstance().bFastmem && !m_enable_debugging;
m_cleanup_after_stackfault = false;
m_stack = nullptr;
@ -603,8 +603,8 @@ void Jit64::JustWriteExit(u32 destination, bool bl, u32 after)
MOV(32, PPCSTATE(pc), Imm32(destination));
// Do not skip breakpoint check if debugging.
const u8* dispatcher = SConfig::GetInstance().bEnableDebugging ? asm_routines.dispatcher :
asm_routines.dispatcher_no_check;
const u8* dispatcher =
m_enable_debugging ? asm_routines.dispatcher : asm_routines.dispatcher_no_check;
// Perform downcount flag check, followed by the requested exit
if (bl)
@ -796,7 +796,7 @@ void Jit64::Jit(u32 em_address, bool clear_cache_and_retry_on_failure)
std::size_t block_size = m_code_buffer.size();
if (SConfig::GetInstance().bEnableDebugging)
if (m_enable_debugging)
{
// We can link blocks as long as we are not single stepping and there are no breakpoints here
EnableBlockLink();
@ -1007,7 +1007,7 @@ bool Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
js.fastmemLoadStore = nullptr;
js.fixupExceptionHandler = false;
if (!SConfig::GetInstance().bEnableDebugging)
if (!m_enable_debugging)
js.downcountAmount += PatchEngine::GetSpeedhackCycles(js.compilerPC);
if (i == (code_block.m_num_instructions - 1))
@ -1094,8 +1094,7 @@ bool Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
js.firstFPInstructionFound = true;
}
if (SConfig::GetInstance().bEnableDebugging && breakpoints.IsAddressBreakPoint(op.address) &&
!CPU::IsStepping())
if (m_enable_debugging && breakpoints.IsAddressBreakPoint(op.address) && !CPU::IsStepping())
{
// Turn off block linking if there are breakpoints so that the Step Over command does not
// link this block.

View file

@ -9,7 +9,7 @@
#include "Common/JitRegister.h"
#include "Common/x64ABI.h"
#include "Common/x64Emitter.h"
#include "Core/ConfigManager.h"
#include "Core/Config/MainSettings.h"
#include "Core/CoreTiming.h"
#include "Core/HW/CPU.h"
#include "Core/HW/Memmap.h"
@ -37,6 +37,8 @@ void Jit64AsmRoutineManager::Init(u8* stack_top)
void Jit64AsmRoutineManager::Generate()
{
const bool enable_debugging = Config::Get(Config::MAIN_ENABLE_DEBUGGING);
enter_code = AlignCode16();
// We need to own the beginning of RSP, so we do an extra stack adjustment
// for the shadow region before calls in this function. This call will
@ -65,8 +67,7 @@ void Jit64AsmRoutineManager::Generate()
ABI_PushRegistersAndAdjustStack({}, 0);
ABI_CallFunction(CoreTiming::Advance);
ABI_PopRegistersAndAdjustStack({}, 0);
FixupBranch skipToRealDispatch =
J(SConfig::GetInstance().bEnableDebugging); // skip the sync and compare first time
FixupBranch skipToRealDispatch = J(enable_debugging); // skip the sync and compare first time
dispatcher_mispredicted_blr = GetCodePtr();
AND(32, PPCSTATE(pc), Imm32(0xFFFFFFFC));
@ -88,7 +89,7 @@ void Jit64AsmRoutineManager::Generate()
FixupBranch dbg_exit;
if (SConfig::GetInstance().bEnableDebugging)
if (enable_debugging)
{
MOV(64, R(RSCRATCH), ImmPtr(CPU::GetStatePtr()));
TEST(32, MatR(RSCRATCH), Imm32(static_cast<u32>(CPU::State::Stepping)));
@ -205,7 +206,7 @@ void Jit64AsmRoutineManager::Generate()
J_CC(CC_Z, outerLoop);
// Landing pad for drec space
if (SConfig::GetInstance().bEnableDebugging)
if (enable_debugging)
SetJumpTarget(dbg_exit);
ResetStack(*this);
if (m_stack_top)

View file

@ -14,9 +14,8 @@ JitBlockCache::JitBlockCache(JitBase& jit) : JitBaseBlockCache{jit}
void JitBlockCache::WriteLinkBlock(const JitBlock::LinkData& source, const JitBlock* dest)
{
// Do not skip breakpoint check if debugging.
const u8* dispatcher = SConfig::GetInstance().bEnableDebugging ?
m_jit.GetAsmRoutines()->dispatcher :
m_jit.GetAsmRoutines()->dispatcher_no_check;
const u8* dispatcher = m_jit.IsDebuggingEnabled() ? m_jit.GetAsmRoutines()->dispatcher :
m_jit.GetAsmRoutines()->dispatcher_no_check;
u8* location = source.exitPtrs;
const u8* address = dest ? dest->checkedEntry : dispatcher;

View file

@ -67,8 +67,8 @@ void JitArm64::Init()
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CARRY_MERGE);
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_FOLLOW);
m_enable_blr_optimization = jo.enableBlocklink && SConfig::GetInstance().bFastmem &&
!SConfig::GetInstance().bEnableDebugging;
m_enable_blr_optimization =
jo.enableBlocklink && SConfig::GetInstance().bFastmem && !m_enable_debugging;
m_cleanup_after_stackfault = false;
AllocStack();
@ -655,7 +655,7 @@ void JitArm64::Jit(u32 em_address, bool clear_cache_and_retry_on_failure)
std::size_t block_size = m_code_buffer.size();
if (SConfig::GetInstance().bEnableDebugging)
if (m_enable_debugging)
{
// Comment out the following to disable breakpoints (speed-up)
block_size = 1;
@ -820,7 +820,7 @@ bool JitArm64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
js.downcountAmount += opinfo->numCycles;
js.isLastInstruction = i == (code_block.m_num_instructions - 1);
if (!SConfig::GetInstance().bEnableDebugging)
if (!m_enable_debugging)
js.downcountAmount += PatchEngine::GetSpeedhackCycles(js.compilerPC);
// Skip calling UpdateLastUsed for lmw/stmw - it usually hurts more than it helps

View file

@ -48,6 +48,8 @@ void JitBase::RefreshConfig()
bJITSystemRegistersOff = Config::Get(Config::MAIN_DEBUG_JIT_SYSTEM_REGISTERS_OFF);
bJITBranchOff = Config::Get(Config::MAIN_DEBUG_JIT_BRANCH_OFF);
bJITRegisterCacheOff = Config::Get(Config::MAIN_DEBUG_JIT_REGISTER_CACHE_OFF);
m_enable_debugging = Config::Get(Config::MAIN_ENABLE_DEBUGGING);
analyzer.SetDebuggingEnabled(m_enable_debugging);
}
bool JitBase::CanMergeNextInstructions(int count) const
@ -57,8 +59,7 @@ bool JitBase::CanMergeNextInstructions(int count) const
// Be careful: a breakpoint kills flags in between instructions
for (int i = 1; i <= count; i++)
{
if (SConfig::GetInstance().bEnableDebugging &&
PowerPC::breakpoints.IsAddressBreakPoint(js.op[i].address))
if (m_enable_debugging && PowerPC::breakpoints.IsAddressBreakPoint(js.op[i].address))
return false;
if (js.op[i].isBranchTarget)
return false;

View file

@ -126,6 +126,7 @@ protected:
bool bJITSystemRegistersOff = false;
bool bJITBranchOff = false;
bool bJITRegisterCacheOff = false;
bool m_enable_debugging = false;
void RefreshConfig();
@ -139,6 +140,8 @@ public:
JitBase();
~JitBase() override;
bool IsDebuggingEnabled() const { return m_enable_debugging; }
static const u8* Dispatch(JitBase& jit);
virtual JitBaseBlockCache* GetBlockCache() = 0;

View file

@ -15,6 +15,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"
@ -191,7 +192,7 @@ static void AnalyzeFunction2(Common::Symbol* func)
func->flags = flags;
}
static bool CanSwapAdjacentOps(const CodeOp& a, const CodeOp& b)
bool PPCAnalyzer::CanSwapAdjacentOps(const CodeOp& a, const CodeOp& b)
{
const GekkoOPInfo* a_info = a.opinfo;
const GekkoOPInfo* b_info = b.opinfo;
@ -199,10 +200,11 @@ static bool CanSwapAdjacentOps(const CodeOp& a, const CodeOp& b)
u64 b_flags = b_info->flags;
// can't reorder around breakpoints
if (SConfig::GetInstance().bEnableDebugging &&
(PowerPC::breakpoints.IsAddressBreakPoint(a.address) ||
PowerPC::breakpoints.IsAddressBreakPoint(b.address)))
if (m_is_debugging_enabled && (PowerPC::breakpoints.IsAddressBreakPoint(a.address) ||
PowerPC::breakpoints.IsAddressBreakPoint(b.address)))
{
return false;
}
if (b_flags & (FL_SET_CRx | FL_ENDBLOCK | FL_TIMER | FL_EVIL | FL_SET_OE))
return false;
if ((b_flags & (FL_RC_BIT | FL_RC_BIT_F)) && (b.inst.Rc))

View file

@ -215,6 +215,7 @@ public:
void SetOption(AnalystOption option) { m_options |= option; }
void ClearOption(AnalystOption option) { m_options &= ~(option); }
bool HasOption(AnalystOption option) const { return !!(m_options & option); }
void SetDebuggingEnabled(bool enabled) { m_is_debugging_enabled = enabled; }
u32 Analyze(u32 address, CodeBlock* block, CodeBuffer* buffer, std::size_t block_size);
private:
@ -225,6 +226,7 @@ private:
CROR
};
bool CanSwapAdjacentOps(const CodeOp& a, const CodeOp& b);
void ReorderInstructionsCore(u32 instructions, CodeOp* code, bool reverse, ReorderType type);
void ReorderInstructions(u32 instructions, CodeOp* code);
void SetInstructionStats(CodeBlock* block, CodeOp* code, const GekkoOPInfo* opinfo, u32 index);
@ -232,6 +234,8 @@ private:
// Options
u32 m_options = 0;
bool m_is_debugging_enabled = false;
};
void FindFunctions(u32 startAddr, u32 endAddr, PPCSymbolDB* func_db);

View file

@ -18,6 +18,7 @@
#include "Common/FloatUtils.h"
#include "Common/Logging/Log.h"
#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
@ -264,7 +265,7 @@ void Init(CPUCore cpu_core)
InitializeCPUCore(cpu_core);
ppcState.iCache.Init();
if (SConfig::GetInstance().bEnableDebugging)
if (Config::Get(Config::MAIN_ENABLE_DEBUGGING))
breakpoints.ClearAllTemporary();
}