Jit64: Factor function hooking out of DoJit()

This commit is contained in:
Lioncash 2018-05-16 18:29:09 -04:00
parent f3c13402e8
commit 3400165171
2 changed files with 19 additions and 20 deletions

View File

@ -806,26 +806,8 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc
SetJumpTarget(noExtIntEnable);
}
u32 function = HLE::GetFirstFunctionIndex(op.address);
if (function != 0)
{
HLE::HookType type = HLE::GetFunctionTypeByIndex(function);
if (type == HLE::HookType::Start || type == HLE::HookType::Replace)
{
HLE::HookFlag flags = HLE::GetFunctionFlagsByIndex(function);
if (HLE::IsEnabled(flags))
{
HLEFunction(function);
if (type == HLE::HookType::Replace)
{
MOV(32, R(RSCRATCH), PPCSTATE(npc));
js.downcountAmount += js.st.numCycles;
WriteExitDestInRSCRATCH();
break;
}
}
}
}
if (HandleFunctionHooking(op.address))
break;
if (!op.skip)
{
@ -1042,3 +1024,18 @@ void Jit64::IntializeSpeculativeConstants()
}
}
}
bool Jit64::HandleFunctionHooking(u32 address)
{
return HLE::ReplaceFunctionIfPossible(address, [&](u32 function, HLE::HookType type) {
HLEFunction(function);
if (type != HLE::HookType::Replace)
return false;
MOV(32, R(RSCRATCH), PPCSTATE(npc));
js.downcountAmount += js.st.numCycles;
WriteExitDestInRSCRATCH();
return true;
});
}

View File

@ -234,6 +234,8 @@ private:
static void InitializeInstructionTables();
void CompileInstruction(PPCAnalyst::CodeOp& op);
bool HandleFunctionHooking(u32 address);
void AllocStack();
void FreeStack();