From 3b35cb12f291bb2541b1b1712b9b447b39584cd3 Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 17 Apr 2010 03:00:35 +0000 Subject: [PATCH] Fixed the LI and LIS PPC instructions in the JIT. This fixes MGS:TS Konami logo hang. Made the JIT sanity checks more informative. Sanity checks are now only performed in the DEBUG and DEBUGFAST builds. This gives a tiny speed-up for everyone else. Fixes issue 2187. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5378 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/HW/Memmap.h | 2 +- Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp | 11 +++++++++-- .../Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp | 17 +++++++++-------- .../Core/Core/Src/PowerPC/Jit64/JitRegCache.h | 2 +- .../Core/Core/Src/PowerPC/Jit64/Jit_Integer.cpp | 1 + 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Source/Core/Core/Src/HW/Memmap.h b/Source/Core/Core/Src/HW/Memmap.h index 3a5157d253..be1212f8be 100644 --- a/Source/Core/Core/Src/HW/Memmap.h +++ b/Source/Core/Core/Src/HW/Memmap.h @@ -23,7 +23,7 @@ #include "Common.h" // Enable memory checks in the Debug/DebugFast builds, but NOT in release -#if _DEBUG || DEBUGFAST +#if defined(_DEBUG) || defined(DEBUGFAST) #define ENABLE_MEM_CHECK #endif diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp index 447859fbb4..c7e96f8362 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp @@ -567,8 +567,15 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc if (!ops[i].skip) Jit64Tables::CompileInstruction(ops[i].inst); - gpr.SanityCheck(); - fpr.SanityCheck(); +#if defined(_DEBUG) || defined(DEBUGFAST) + if (gpr.SanityCheck() || fpr.SanityCheck()) + { + char ppcInst[256]; + DisassembleGekko(ops[i].inst.hex, em_address, ppcInst, 256); + NOTICE_LOG(DYNA_REC, "Unflushed reg: %s", ppcInst); + } +#endif + if (js.cancel) break; } diff --git a/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp b/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp index d8100d434d..7485734a51 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.cpp @@ -163,21 +163,22 @@ void RegCache::FlushR(X64Reg reg) } } -void RegCache::SanityCheck() const +int RegCache::SanityCheck() const { for (int i = 0; i < 32; i++) { if (regs[i].away) { if (regs[i].location.IsSimpleReg()) { Gen::X64Reg simple = regs[i].location.GetSimpleReg(); - if (xlocks[simple]) { - PanicAlert("%08x : PPC Reg %i is in locked x64 register %i", /*js.compilerPC*/ 0, i, regs[i].location.GetSimpleReg()); - } - if (xregs[simple].ppcReg != i) { - PanicAlert("%08x : Xreg/ppcreg mismatch"); - } + if (xlocks[simple]) + return 1; + if (xregs[simple].ppcReg != i) + return 2; } + else if (regs[i].location.IsImm()) + return 3; } } + return 0; } void RegCache::DiscardRegContentsIfCached(int preg) @@ -397,7 +398,7 @@ void RegCache::Flush(FlushMode mode) } else { - _assert_msg_(DYNA_REC,0,"Jit64 - Flush unhandled case, reg %i", i); + _assert_msg_(DYNA_REC,0,"Jit64 - Flush unhandled case, reg %i PC: %08x", i, PC); } } } diff --git a/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.h b/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.h index 0e7ce20bcd..e93db1fd6d 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.h +++ b/Source/Core/Core/Src/PowerPC/Jit64/JitRegCache.h @@ -95,7 +95,7 @@ public: } virtual void Flush(FlushMode mode); virtual void Flush(PPCAnalyst::CodeOp *op) {Flush(FLUSH_ALL);} - void SanityCheck() const; + int SanityCheck() const; void KillImmediate(int preg); //TODO - instead of doload, use "read", "write" diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit_Integer.cpp index 15943c1a06..d36bc6f0fd 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit_Integer.cpp @@ -71,6 +71,7 @@ void Jit64::regimmop(int d, int a, bool binary, u32 value, Operation doop, void { // a == 0, which for these instructions imply value = 0 gpr.SetImmediate32(d, value); + gpr.StoreFromX64(d); } else {