JitArm64: Check downcount on block linking.

This skips one B() call.
This commit is contained in:
degasus 2016-05-13 23:42:34 +02:00
parent 10e716c623
commit b6f16352e4
2 changed files with 12 additions and 10 deletions

View File

@ -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);

View File

@ -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();
}