Interpreter: Drop idle skipping in interpreter.

And reimplement it in the cached interpreter based on the idle loop detection.
This commit is contained in:
degasus 2019-04-20 20:51:43 +02:00
parent 55abe1a085
commit 6ec4ade3b6
2 changed files with 12 additions and 24 deletions

View file

@ -181,6 +181,15 @@ static bool CheckBreakpoint(u32 data)
return false;
}
static bool CheckIdle(u32 idle_pc)
{
if (PowerPC::ppcState.npc == idle_pc)
{
CoreTiming::Idle();
}
return false;
}
bool CachedInterpreter::HandleFunctionHooking(u32 address)
{
return HLE::ReplaceFunctionIfPossible(address, [&](u32 function, HLE::HookType type) {
@ -242,6 +251,7 @@ void CachedInterpreter::Jit(u32 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;
const bool idle_loop = op.branchIsIdleLoop;
if (breakpoint)
{
@ -261,6 +271,8 @@ void CachedInterpreter::Jit(u32 address)
m_code.emplace_back(PPCTables::GetInterpreterOp(op.inst), op.inst);
if (memcheck)
m_code.emplace_back(CheckDSI, js.downcountAmount);
if (idle_loop)
m_code.emplace_back(CheckIdle, js.blockStart);
if (endblock)
m_code.emplace_back(EndBlock, js.downcountAmount);
}

View file

@ -5,7 +5,6 @@
#include "Common/Assert.h"
#include "Common/CommonTypes.h"
#include "Core/ConfigManager.h"
#include "Core/CoreTiming.h"
#include "Core/HLE/HLE.h"
#include "Core/PowerPC/Interpreter/ExceptionUtils.h"
#include "Core/PowerPC/Interpreter/Interpreter.h"
@ -23,11 +22,6 @@ void Interpreter::bx(UGeckoInstruction inst)
NPC = PC + SignExt26(inst.LI << 2);
m_end_block = true;
if (NPC == PC)
{
CoreTiming::Idle();
}
}
// bcx - ugly, straight from PPC manual equations :)
@ -56,24 +50,6 @@ void Interpreter::bcx(UGeckoInstruction inst)
}
m_end_block = true;
// this code trys to detect the most common idle loop:
// lwz r0, XXXX(r13)
// cmpXwi r0,0
// beq -8
if (NPC == PC - 8 && inst.hex == 0x4182fff8 /* beq */)
{
if (PowerPC::HostRead_U32(PC - 8) >> 16 == 0x800D /* lwz */)
{
u32 last_inst = PowerPC::HostRead_U32(PC - 4);
if (last_inst == 0x28000000 /* cmplwi */ ||
(last_inst == 0x2C000000 /* cmpwi */ && SConfig::GetInstance().bWii))
{
CoreTiming::Idle();
}
}
}
}
void Interpreter::bcctrx(UGeckoInstruction inst)