diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index 9a628430a7..31031ef70c 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -414,6 +414,9 @@ const u8* JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB SetJumpTarget(bail); } + // Normal entry doesn't need to check for downcount. + b->normalEntry = GetCodePtr(); + // Conditionally add profiling code. if (Profiler::g_ProfileBlocks) { @@ -452,9 +455,6 @@ const u8* JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB } } - const u8 *normalEntry = GetCodePtr(); - b->normalEntry = normalEntry; - gpr.Start(js.gpa); fpr.Start(js.fpa); diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64Cache.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64Cache.cpp index fe9280bf58..85664e7bb3 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64Cache.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64Cache.cpp @@ -9,19 +9,21 @@ void JitArm64BlockCache::WriteLinkBlock(u8* location, const JitBlock& block) { - const u8* address = block.checkedEntry; ARM64XEmitter emit(location); - s64 offset = address - location; - // different size of the dispatcher call, so they are still continuous - if (offset > 0 && offset <= 28 && offset % 4 == 0) + // Are we able to jump directly to the normal entry? + s64 distance = ((s64)block.normalEntry - (s64)location) >> 2; + if (distance >= -0x40000 && distance <= 0x3FFFF) { - for (int i = 0; i < offset / 4; i++) - emit.HINT(HINT_NOP); + emit.B(CC_LE, block.normalEntry); + + // We can't write DISPATCHER_PC here, as blink linking is only for 8bytes. + // So we'll hit two jumps when calling Advance. + emit.B(block.checkedEntry); } else { - emit.B(address); + emit.B(block.checkedEntry); } emit.FlushIcache(); }