From 78aa01e06e5043cb5b3b09f81577b78b756ad620 Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 21 Aug 2015 17:30:46 +0200 Subject: [PATCH] Jit64: Faster linking of continuous blocks We compile the blocks as they are executed, so it's common to link them continuously. We end with calling JMP after every block, but often just with a distance of 0. So just emitting NOPs instead also "calls" the next block, but easier for the CPU. --- Source/Core/Core/PowerPC/JitCommon/JitCache.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp index c3e3e2fdfc..840dd672c5 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp @@ -324,9 +324,20 @@ using namespace Gen; { XEmitter emit(location); if (*location == 0xE8) + { emit.CALL(address); + } else - emit.JMP(address, true); + { + // If we're going to link with the next block, there is no need + // to emit JMP. So just NOP out the gap to the next block. + // Support up to 3 additional bytes because of alignment. + s64 offset = address - emit.GetCodePtr(); + if (offset > 0 && offset <= 5 + 3) + emit.NOP(offset); + else + emit.JMP(address, true); + } } void JitBlockCache::WriteDestroyBlock(const u8* location, u32 address)