Permalink
Browse files

Jit64: Factor function hooking out of DoJit()

  • Loading branch information...
lioncash committed May 16, 2018
1 parent f3c1340 commit 3400165171962c1405e486477a6668eb8a3af902
Showing with 19 additions and 20 deletions.
  1. +17 −20 Source/Core/Core/PowerPC/Jit64/Jit.cpp
  2. +2 −0 Source/Core/Core/PowerPC/Jit64/Jit.h
@@ -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;
});
}
@@ -234,6 +234,8 @@ class Jit64 : public Jitx86Base
static void InitializeInstructionTables();
void CompileInstruction(PPCAnalyst::CodeOp& op);
bool HandleFunctionHooking(u32 address);
void AllocStack();
void FreeStack();

0 comments on commit 3400165

Please sign in to comment.