Disabled optimizations, block merging and instruction skipping code while the debugger is stepping.

This commit is contained in:
skidau 2014-10-27 23:38:45 +11:00
parent 4570dd7eeb
commit daf977e84e
5 changed files with 41 additions and 22 deletions

View File

@ -190,7 +190,7 @@ void Jit64::Init()
// BLR optimization has the same consequences as block linking, as well as // 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. // depending on the fault handler to be safe in the event of excessive BL.
m_enable_blr_optimization = jo.enableBlocklink && SConfig::GetInstance().m_LocalCoreStartupParameter.bFastmem; m_enable_blr_optimization = jo.enableBlocklink && SConfig::GetInstance().m_LocalCoreStartupParameter.bFastmem && !SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging;
m_clear_cache_asap = false; m_clear_cache_asap = false;
m_stack = nullptr; m_stack = nullptr;
@ -207,9 +207,7 @@ void Jit64::Init()
code_block.m_stats = &js.st; code_block.m_stats = &js.st;
code_block.m_gpa = &js.gpa; code_block.m_gpa = &js.gpa;
code_block.m_fpa = &js.fpa; code_block.m_fpa = &js.fpa;
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE); EnableOptimization();
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_MERGE);
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CARRY_MERGE);
} }
void Jit64::ClearCache() void Jit64::ClearCache()
@ -518,6 +516,7 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
{ {
// We can link blocks as long as we are not single stepping and there are no breakpoints here // We can link blocks as long as we are not single stepping and there are no breakpoints here
EnableBlockLink(); EnableBlockLink();
EnableOptimization();
// Comment out the following to disable breakpoints (speed-up) // Comment out the following to disable breakpoints (speed-up)
if (!Profiler::g_ProfileBlocks) if (!Profiler::g_ProfileBlocks)
@ -528,6 +527,9 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
// Do not link this block to other blocks While single stepping // Do not link this block to other blocks While single stepping
jo.enableBlocklink = false; jo.enableBlocklink = false;
analyzer.ClearOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE);
analyzer.ClearOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_MERGE);
analyzer.ClearOption(PPCAnalyst::PPCAnalyzer::OPTION_CARRY_MERGE);
} }
Trace(); Trace();
} }
@ -873,3 +875,10 @@ void Jit64::EnableBlockLink()
jo.enableBlocklink = false; jo.enableBlocklink = false;
} }
} }
void Jit64::EnableOptimization()
{
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE);
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_MERGE);
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CARRY_MERGE);
}

View File

@ -65,6 +65,8 @@ public:
void Init() override; void Init() override;
void EnableOptimization();
void EnableBlockLink(); void EnableBlockLink();
void Shutdown() override; void Shutdown() override;

View File

@ -97,11 +97,14 @@ void Jit64::lXXx(UGeckoInstruction inst)
// PowerPC has no 8-bit sign extended load, but x86 does, so merge extsb with the load if we find it. // PowerPC has no 8-bit sign extended load, but x86 does, so merge extsb with the load if we find it.
if (accessSize == 8 && js.next_inst.OPCD == 31 && js.next_inst.SUBOP10 == 954 && if (accessSize == 8 && js.next_inst.OPCD == 31 && js.next_inst.SUBOP10 == 954 &&
js.next_inst.RS == inst.RD && js.next_inst.RA == inst.RD && !js.next_inst.Rc) js.next_inst.RS == inst.RD && js.next_inst.RA == inst.RD && !js.next_inst.Rc)
{
if (PowerPC::GetState() != PowerPC::CPU_STEPPING)
{ {
js.downcountAmount++; js.downcountAmount++;
js.skipnext = true; js.skipnext = true;
signExtend = true; signExtend = true;
} }
}
// TODO(ector): Make it dynamically enable/disable idle skipping where appropriate // TODO(ector): Make it dynamically enable/disable idle skipping where appropriate
// Will give nice boost to dual core mode // Will give nice boost to dual core mode
@ -109,6 +112,7 @@ void Jit64::lXXx(UGeckoInstruction inst)
// IMHO those Idles should always be skipped and replaced by a more controllable "native" Idle methode // IMHO those Idles should always be skipped and replaced by a more controllable "native" Idle methode
// ... maybe the throttle one already do that :p // ... maybe the throttle one already do that :p
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle && if (SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle &&
PowerPC::GetState() != PowerPC::CPU_STEPPING &&
inst.OPCD == 32 && inst.OPCD == 32 &&
(inst.hex & 0xFFFF0000) == 0x800D0000 && (inst.hex & 0xFFFF0000) == 0x800D0000 &&
(Memory::ReadUnchecked_U32(js.compilerPC + 4) == 0x28000000 || (Memory::ReadUnchecked_U32(js.compilerPC + 4) == 0x28000000 ||

View File

@ -227,6 +227,8 @@ void Jit64::mfspr(UGeckoInstruction inst)
u32 nextIndex = (js.next_inst.SPRU << 5) | (js.next_inst.SPRL & 0x1F); u32 nextIndex = (js.next_inst.SPRU << 5) | (js.next_inst.SPRL & 0x1F);
// Be careful; the actual opcode is for mftb (371), not mfspr (339) // Be careful; the actual opcode is for mftb (371), not mfspr (339)
if (js.next_inst.OPCD == 31 && js.next_inst.SUBOP10 == 371 && (nextIndex == SPR_TU || nextIndex == SPR_TL)) if (js.next_inst.OPCD == 31 && js.next_inst.SUBOP10 == 371 && (nextIndex == SPR_TU || nextIndex == SPR_TL))
{
if (PowerPC::GetState() != PowerPC::CPU_STEPPING)
{ {
int n = js.next_inst.RD; int n = js.next_inst.RD;
js.downcountAmount++; js.downcountAmount++;
@ -244,6 +246,7 @@ void Jit64::mfspr(UGeckoInstruction inst)
if (nextIndex == SPR_TU) if (nextIndex == SPR_TU)
MOV(32, gpr.R(n), R(RAX)); MOV(32, gpr.R(n), R(RAX));
} }
}
else else
{ {
gpr.Lock(d); gpr.Lock(d);

View File

@ -37,6 +37,7 @@ void JitILBase::lXz(UGeckoInstruction inst)
// Idle Skipping. This really should be done somewhere else. // Idle Skipping. This really should be done somewhere else.
// Either lower in the IR or higher in PPCAnalyist // Either lower in the IR or higher in PPCAnalyist
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle && if (SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle &&
PowerPC::GetState() != PowerPC::CPU_STEPPING &&
inst.OPCD == 32 && // Lwx inst.OPCD == 32 && // Lwx
(inst.hex & 0xFFFF0000) == 0x800D0000 && (inst.hex & 0xFFFF0000) == 0x800D0000 &&
(Memory::ReadUnchecked_U32(js.compilerPC + 4) == 0x28000000 || (Memory::ReadUnchecked_U32(js.compilerPC + 4) == 0x28000000 ||