[AArch64] Implements block linking.

Before block linking was enabled but it wasn't ever implemented.
Implements link blocks and destroy block functions and moves the downcount check in the WriteExit function so it doesn't get overwritten when linking.
This commit is contained in:
Ryan Houdek 2014-12-02 19:13:28 -06:00
parent ca04601b14
commit 51ad798105
3 changed files with 14 additions and 5 deletions

View File

@ -97,6 +97,8 @@ void JitArm64::DoDownCount()
// Exits // Exits
void JitArm64::WriteExit(u32 destination) void JitArm64::WriteExit(u32 destination)
{ {
DoDownCount();
//If nobody has taken care of this yet (this can be removed when all branches are done) //If nobody has taken care of this yet (this can be removed when all branches are done)
JitBlock *b = js.curBlock; JitBlock *b = js.curBlock;
JitBlock::LinkData linkData; JitBlock::LinkData linkData;
@ -104,8 +106,6 @@ void JitArm64::WriteExit(u32 destination)
linkData.exitPtrs = GetWritableCodePtr(); linkData.exitPtrs = GetWritableCodePtr();
linkData.linkStatus = false; linkData.linkStatus = false;
DoDownCount();
// Link opportunity! // Link opportunity!
int block; int block;
if (jo.enableBlocklink && (block = blocks.GetBlockNumberFromStartAddress(destination)) >= 0) if (jo.enableBlocklink && (block = blocks.GetBlockNumberFromStartAddress(destination)) >= 0)
@ -163,13 +163,12 @@ void JitArm64::SingleStep()
pExecAddr(); pExecAddr();
} }
void JitArm64::Jit(u32 em_address) void JitArm64::Jit(u32)
{ {
if (GetSpaceLeft() < 0x10000 || blocks.IsFull() || SConfig::GetInstance().m_LocalCoreStartupParameter.bJITNoBlockCache) if (GetSpaceLeft() < 0x10000 || blocks.IsFull() || SConfig::GetInstance().m_LocalCoreStartupParameter.bJITNoBlockCache)
{ {
ClearCache(); ClearCache();
} }
int block_num = blocks.AllocateBlock(PowerPC::ppcState.pc); int block_num = blocks.AllocateBlock(PowerPC::ppcState.pc);
JitBlock *b = blocks.GetBlock(block_num); JitBlock *b = blocks.GetBlock(block_num);
const u8* BlockPtr = DoJit(PowerPC::ppcState.pc, &code_buffer, b); const u8* BlockPtr = DoJit(PowerPC::ppcState.pc, &code_buffer, b);
@ -282,6 +281,7 @@ const u8* JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
b->codeSize = (u32)(GetCodePtr() - normalEntry); b->codeSize = (u32)(GetCodePtr() - normalEntry);
b->originalSize = code_block.m_num_instructions; b->originalSize = code_block.m_num_instructions;
FlushIcache(); FlushIcache();
return start; return start;
} }

View File

@ -47,7 +47,7 @@ public:
void Run(); void Run();
void SingleStep(); void SingleStep();
void Jit(u32 em_address); void Jit(u32);
const char *GetName() const char *GetName()
{ {

View File

@ -8,9 +8,18 @@
void JitArm64BlockCache::WriteLinkBlock(u8* location, const u8* address) void JitArm64BlockCache::WriteLinkBlock(u8* location, const u8* address)
{ {
ARM64XEmitter emit(location);
emit.B(address);
emit.FlushIcache();
} }
void JitArm64BlockCache::WriteDestroyBlock(const u8* location, u32 address) void JitArm64BlockCache::WriteDestroyBlock(const u8* location, u32 address)
{ {
ARM64XEmitter emit((u8 *)location);
emit.MOVI2R(W0, address);
emit.MOVI2R(X30, (u64)jit->GetAsmRoutines()->dispatcher);
emit.STR(INDEX_UNSIGNED, W0, X29, PPCSTATE_OFF(pc));
emit.BR(X30);
emit.FlushIcache();
} }