Merge pull request #2898 from degasus/linking

JitArm64: Faster linking of continuous blocks
This commit is contained in:
Ryan Houdek 2015-08-23 18:09:02 -05:00
commit 80fa9af9b1
2 changed files with 21 additions and 19 deletions

View File

@ -160,24 +160,14 @@ void JitArm64::WriteExit(u32 destination)
linkData.exitPtrs = GetWritableCodePtr();
linkData.linkStatus = false;
// Link opportunity!
int block;
if (jo.enableBlocklink && (block = blocks.GetBlockNumberFromStartAddress(destination)) >= 0)
{
// It exists! Joy of joy!
B(blocks.GetBlock(block)->checkedEntry);
linkData.linkStatus = true;
}
else
{
ARM64Reg WA = gpr.GetReg();
ARM64Reg XA = EncodeRegTo64(WA);
MOVI2R(WA, destination);
STR(INDEX_UNSIGNED, WA, X29, PPCSTATE_OFF(pc));
MOVI2R(XA, (u64)asm_routines.dispatcher);
BR(XA);
gpr.Unlock(WA);
}
// the code generated in JitArm64BlockCache::WriteDestroyBlock must fit in this block
ARM64Reg WA = gpr.GetReg();
ARM64Reg XA = EncodeRegTo64(WA);
MOVI2R(WA, destination);
STR(INDEX_UNSIGNED, WA, X29, PPCSTATE_OFF(pc));
MOVI2R(XA, (u64)asm_routines.dispatcher);
BR(XA);
gpr.Unlock(WA);
b->linkData.push_back(linkData);
}

View File

@ -9,12 +9,24 @@
void JitArm64BlockCache::WriteLinkBlock(u8* location, const u8* address)
{
ARM64XEmitter emit(location);
emit.B(address);
s64 offset = address - location;
// different size of the dispatcher call, so they are still continuous
if (offset > 0 && offset <= 28 && offset % 4 == 0)
{
for (int i = 0; i < offset / 4; i++)
emit.HINT(HINT_NOP);
}
else
{
emit.B(address);
}
emit.FlushIcache();
}
void JitArm64BlockCache::WriteDestroyBlock(const u8* location, u32 address)
{
// must fit within the code generated in JitArm64::WriteExit
ARM64XEmitter emit((u8 *)location);
emit.MOVI2R(W0, address);
emit.MOVI2R(X30, (u64)jit->GetAsmRoutines()->dispatcher);