JitArm64: Use B() instead of BR() to jumo to ASM.

Avoid indirect jumps as good as possible. This is a noticeable speedup.
This commit is contained in:
degasus 2016-05-13 23:13:35 +02:00
parent b2be9bd7f7
commit cf3c65fbd0
3 changed files with 8 additions and 19 deletions

View File

@ -197,9 +197,8 @@ void JitArm64::WriteExit(u32 destination)
b->linkData.push_back(linkData); b->linkData.push_back(linkData);
// the code generated in JitArm64BlockCache::WriteDestroyBlock must fit in this block // the code generated in JitArm64BlockCache::WriteDestroyBlock must fit in this block
MOVI2R(X30, (u64)dispatcher);
MOVI2R(DISPATCHER_PC, destination); MOVI2R(DISPATCHER_PC, destination);
BR(X30); B(dispatcher);
} }
void JitArm64::WriteExit(ARM64Reg Reg) void JitArm64::WriteExit(ARM64Reg Reg)
@ -214,8 +213,7 @@ void JitArm64::WriteExit(ARM64Reg Reg)
if (Profiler::g_ProfileBlocks) if (Profiler::g_ProfileBlocks)
EndTimeProfile(js.curBlock); EndTimeProfile(js.curBlock);
MOVI2R(X30, (u64)dispatcher); B(dispatcher);
BR(X30);
} }
void JitArm64::WriteExceptionExit(u32 destination, bool only_external) void JitArm64::WriteExceptionExit(u32 destination, bool only_external)
@ -241,8 +239,7 @@ void JitArm64::WriteExceptionExit(u32 destination, bool only_external)
if (Profiler::g_ProfileBlocks) if (Profiler::g_ProfileBlocks)
EndTimeProfile(js.curBlock); EndTimeProfile(js.curBlock);
MOVI2R(X30, (u64)dispatcher); B(dispatcher);
BR(X30);
} }
void JitArm64::WriteExceptionExit(ARM64Reg dest, bool only_external) void JitArm64::WriteExceptionExit(ARM64Reg dest, bool only_external)
@ -273,8 +270,7 @@ void JitArm64::WriteExceptionExit(ARM64Reg dest, bool only_external)
if (Profiler::g_ProfileBlocks) if (Profiler::g_ProfileBlocks)
EndTimeProfile(js.curBlock); EndTimeProfile(js.curBlock);
MOVI2R(X30, (u64)dispatcher); B(dispatcher);
BR(X30);
} }
void JitArm64::DumpCode(const u8* start, const u8* end) void JitArm64::DumpCode(const u8* start, const u8* end)
@ -413,12 +409,8 @@ const u8* JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
// Downcount flag check, Only valid for linked blocks // Downcount flag check, Only valid for linked blocks
{ {
FixupBranch bail = B(CC_PL); FixupBranch bail = B(CC_PL);
ARM64Reg WA = gpr.GetReg();
ARM64Reg XA = EncodeRegTo64(WA);
MOVI2R(DISPATCHER_PC, js.blockStart); MOVI2R(DISPATCHER_PC, js.blockStart);
MOVI2R(XA, (u64)doTiming); B(doTiming);
BR(XA);
gpr.Unlock(WA);
SetJumpTarget(bail); SetJumpTarget(bail);
} }
@ -453,8 +445,7 @@ const u8* JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
MOVI2R(W0, (u32)JitInterface::ExceptionType::EXCEPTIONS_PAIRED_QUANTIZE); MOVI2R(W0, (u32)JitInterface::ExceptionType::EXCEPTIONS_PAIRED_QUANTIZE);
MOVI2R(X1, (u64)&JitInterface::CompileExceptionCheck); MOVI2R(X1, (u64)&JitInterface::CompileExceptionCheck);
BLR(X1); BLR(X1);
MOVI2R(X1, (u64)dispatcher); B(dispatcher);
BR(X1);
SwitchToNearCode(); SwitchToNearCode();
SetJumpTarget(no_fail); SetJumpTarget(no_fail);
js.assumeNoPairedQuantize = true; js.assumeNoPairedQuantize = true;

View File

@ -29,9 +29,8 @@ void JitArm64BlockCache::WriteDestroyBlock(const u8* location, u32 address)
{ {
// must fit within the code generated in JitArm64::WriteExit // must fit within the code generated in JitArm64::WriteExit
ARM64XEmitter emit((u8 *)location); ARM64XEmitter emit((u8 *)location);
emit.MOVI2R(X30, (u64)jit->GetAsmRoutines()->dispatcher);
emit.MOVI2R(DISPATCHER_PC, address); emit.MOVI2R(DISPATCHER_PC, address);
emit.BR(X30); emit.B(jit->GetAsmRoutines()->dispatcher);
emit.FlushIcache(); emit.FlushIcache();
} }

View File

@ -589,8 +589,7 @@ void JitArm64::mfcr(UGeckoInstruction inst)
JITDISABLE(bJITSystemRegistersOff); JITDISABLE(bJITSystemRegistersOff);
gpr.Lock(W0, W1, W2, W30); gpr.Lock(W0, W1, W2, W30);
MOVI2R(X0, (u64)GetAsmRoutines()->mfcr); BL(GetAsmRoutines()->mfcr);
BLR(X0);
gpr.Unlock(W1, W2, W30); gpr.Unlock(W1, W2, W30);
gpr.BindToRegister(inst.RD, false); gpr.BindToRegister(inst.RD, false);