From ca511640a5f2a353d40f3561ccd56a4119e5f889 Mon Sep 17 00:00:00 2001 From: magumagu Date: Wed, 29 Jun 2016 18:51:42 -0700 Subject: [PATCH] Add support for DSI exceptions to CachedInterpreter. Should be straightforward. Maybe useful for the purpose of testing. --- .../Core/Core/PowerPC/CachedInterpreter.cpp | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/PowerPC/CachedInterpreter.cpp b/Source/Core/Core/PowerPC/CachedInterpreter.cpp index 41ba13998c..8f63a2381c 100644 --- a/Source/Core/Core/PowerPC/CachedInterpreter.cpp +++ b/Source/Core/Core/PowerPC/CachedInterpreter.cpp @@ -20,6 +20,7 @@ void CachedInterpreter::Init() jo.enableBlocklink = false; JitBaseBlockCache::Init(); + UpdateMemoryOptions(); code_block.m_stats = &js.st; code_block.m_gpa = &js.gpa; @@ -82,14 +83,30 @@ static void WritePC(UGeckoInstruction data) NPC = data.hex + 4; } +static void WriteBrokenBlockNPC(UGeckoInstruction data) +{ + NPC = data.hex; +} + static bool CheckFPU(u32 data) { UReg_MSR& msr = (UReg_MSR&)MSR; if (!msr.FP) { - PC = NPC = data; PowerPC::ppcState.Exceptions |= EXCEPTION_FPU_UNAVAILABLE; PowerPC::CheckExceptions(); + PowerPC::ppcState.downcount -= data; + return true; + } + return false; +} + +static bool CheckDSI(u32 data) +{ + if (PowerPC::ppcState.Exceptions & EXCEPTION_DSI) + { + PowerPC::CheckExceptions(); + PowerPC::ppcState.downcount -= data; return true; } return false; @@ -156,22 +173,29 @@ void CachedInterpreter::Jit(u32 address) if (!ops[i].skip) { - if ((ops[i].opinfo->flags & FL_USE_FPU) && !js.firstFPInstructionFound) + bool check_fpu = (ops[i].opinfo->flags & FL_USE_FPU) && !js.firstFPInstructionFound; + bool endblock = (ops[i].opinfo->flags & FL_ENDBLOCK) != 0; + bool memcheck = (ops[i].opinfo->flags & FL_LOADSTORE) && jo.memcheck; + + if (check_fpu) { - m_code.emplace_back(CheckFPU, ops[i].address); + m_code.emplace_back(WritePC, ops[i].address); + m_code.emplace_back(CheckFPU, js.downcountAmount); js.firstFPInstructionFound = true; } - if (ops[i].opinfo->flags & FL_ENDBLOCK) + if (endblock || memcheck) m_code.emplace_back(WritePC, ops[i].address); m_code.emplace_back(GetInterpreterOp(ops[i].inst), ops[i].inst); - if (ops[i].opinfo->flags & FL_ENDBLOCK) + if (memcheck) + m_code.emplace_back(CheckDSI, js.downcountAmount); + if (endblock) m_code.emplace_back(EndBlock, js.downcountAmount); } } if (code_block.m_broken) { - m_code.emplace_back(WritePC, nextPC); + m_code.emplace_back(WriteBrokenBlockNPC, nextPC); m_code.emplace_back(EndBlock, js.downcountAmount); } m_code.emplace_back(); @@ -186,6 +210,7 @@ void CachedInterpreter::ClearCache() { m_code.clear(); JitBaseBlockCache::Clear(); + UpdateMemoryOptions(); } void CachedInterpreter::WriteDestroyBlock(const u8* location, u32 address)