From 494c1f3187bcc3ef3902b39e2c021531928e6844 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sun, 3 Aug 2008 16:56:31 +0000 Subject: [PATCH] JIT works in linux with ALL OPTIMIZATION OFF - well, at least it's faster than pure interpreter :P git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@128 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/ABI.cpp | 2 ++ Source/Core/Common/Src/x64Emitter.cpp | 2 ++ Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp | 17 +++++++++++++---- Source/Core/Core/Src/PowerPC/Jit64/JitCache.cpp | 4 ++++ Source/Core/Core/Src/PowerPC/Jit64/JitCache.h | 1 + Source/Core/DolphinWX/src/BootManager.cpp | 3 --- .../Plugin_VideoOGL/Src/PixelShaderManager.cpp | 2 +- .../Plugin_VideoOGL/Src/VertexLoader.cpp | 3 ++- 8 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Source/Core/Common/Src/ABI.cpp b/Source/Core/Common/Src/ABI.cpp index 2c4d2ceab9..06cc435aee 100644 --- a/Source/Core/Common/Src/ABI.cpp +++ b/Source/Core/Common/Src/ABI.cpp @@ -138,9 +138,11 @@ void ABI_PushAllCalleeSavedRegsAndAdjustStack() { PUSH(R13); PUSH(R14); PUSH(R15); + PUSH(RAX); //just to align stack. we don't care about it's value. } void ABI_PopAllCalleeSavedRegsAndAdjustStack() { + POP(RAX); POP(R15); POP(R14); POP(R13); diff --git a/Source/Core/Common/Src/x64Emitter.cpp b/Source/Core/Common/Src/x64Emitter.cpp index 680f1f9927..2b09cbaa12 100644 --- a/Source/Core/Common/Src/x64Emitter.cpp +++ b/Source/Core/Common/Src/x64Emitter.cpp @@ -26,6 +26,8 @@ namespace Gen void SetCodePtr(u8 *ptr) { + if (!ptr) + PanicAlert("SetCodePtr: wtf, ptr=%p", ptr); code = ptr; } const u8 *GetCodePtr() diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp index 04f5828b0f..be5b6c940f 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit.cpp @@ -258,6 +258,12 @@ namespace Jit64 // Yup, just don't do anything. } + // RESULTS (running kururin with optimizations on) + // at block 13968 they diverge. + // linux goes to 8010fe54 + // windoze goes to 8010feb0 + // after they they are completely out of sync. + // branches from the cmp result of r0, which comes from an lbz (loaded from stack) bool ImHereDebug = false; bool ImHereLog = false; std::map been_here; @@ -335,7 +341,6 @@ namespace Jit64 const u8* DoJit(u32 emaddress, JitBlock &b) { _assert_msg_(DYNA_REC, emaddress != 0, "ERROR - Trying to compile at 0. LR=%08x",LR); - //Step 1: Start from the "flattened" representation and assign/preload registers/locations u32 size; js.isLastInstruction = false; @@ -347,9 +352,7 @@ namespace Jit64 //Analyze the block, collect all instructions it is made of (including inlining, //if that is enabled), reorder instructions for optimal performance, and join joinable instructions. PPCAnalyst::CodeOp *ops = PPCAnalyst::Flatten(emaddress, size, js.st, js.gpa, js.fpa); - // This is where we would write the block number if my evil plan comes to fruition const u8 *start = AlignCode4(); //TODO: Test if this or AlignCode16 make a difference from GetCodePtr - b.checkedEntry = start; FixupBranch skip = J_CC(CC_NBE); MOV(32, M(&PC), Imm32(js.blockStart)); @@ -388,7 +391,13 @@ namespace Jit64 js.op = &ops[i]; js.instructionNumber = i; if (i == (int)size - 1) js.isLastInstruction = true; - PPCTables::CompileInstruction(ops[i].inst); + //PPCTables::CompileInstruction(ops[i].inst); +#ifndef _WIN32 + if (!js.isLastInstruction) + Default(ops[i].inst); + else +#endif + PPCTables::CompileInstruction(ops[i].inst); gpr.SanityCheck(); fpr.SanityCheck(); } diff --git a/Source/Core/Core/Src/PowerPC/Jit64/JitCache.cpp b/Source/Core/Core/Src/PowerPC/Jit64/JitCache.cpp index a140de146d..e32ec7e36d 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/JitCache.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/JitCache.cpp @@ -259,6 +259,10 @@ namespace Jit64 return (CompiledCode)blockCodePointers[blockNumber]; } + int GetCodeSize() { + return GetCodePtr() - codeCache; + } + //Block linker //Make sure to have as many blocks as possible compiled before calling this //It's O(N), so it's fast :) diff --git a/Source/Core/Core/Src/PowerPC/Jit64/JitCache.h b/Source/Core/Core/Src/PowerPC/Jit64/JitCache.h index bb20d24c22..b9f59b148d 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/JitCache.h +++ b/Source/Core/Core/Src/PowerPC/Jit64/JitCache.h @@ -55,6 +55,7 @@ namespace Jit64 CompiledCode GetCompiledCode(u32 address); CompiledCode GetCompiledCodeFromBlock(int blockNumber); + int GetCodeSize(); int GetNumBlocks(); u8 **GetCodePointers(); diff --git a/Source/Core/DolphinWX/src/BootManager.cpp b/Source/Core/DolphinWX/src/BootManager.cpp index c3635b5c99..fcd25ae564 100644 --- a/Source/Core/DolphinWX/src/BootManager.cpp +++ b/Source/Core/DolphinWX/src/BootManager.cpp @@ -57,9 +57,6 @@ bool BootCore(const std::string& _rFilename) // StartUp.bUseDualCore = false; StartUp.bUseDynarec = true; } - #ifndef _WIN32 - StartUp.bUseDynarec = false;//Never use Dynarec in Linux, crashes - #endif StartUp.m_BootType = SCoreStartupParameter::BOOT_ISO; StartUp.m_strFilename = _rFilename; StartUp.bRunCompareClient = false; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp index 00f5b64f81..f461a3a44c 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderManager.cpp @@ -576,4 +576,4 @@ void PixelShaderMngr::GetPixelShaderId(PixelShaderMngr::PIXELSHADERUID& uid) } uid.indstages = (u32)(pcurvalue-&uid.values[0]-2-uid.tevstages); -} \ No newline at end of file +} diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp index efb5b07049..2ef1e1887b 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp @@ -470,6 +470,7 @@ void VertexLoader::ProcessFormat() } // compile the pointer set function + u8 *old_code_ptr = GetWritableCodePtr(); SetCodePtr(m_compiledCode); Util::EmitPrologue(6); //INT3(); @@ -575,7 +576,7 @@ void VertexLoader::ProcessFormat() Crash(); } - SetCodePtr(0); + SetCodePtr(old_code_ptr); } void VertexLoader::PrepareRun()