mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-01 14:59:13 +00:00
[dynarmic] x86 direct immediate call for host calls within 2G (#3508)
Signed-off-by: lizzie <[email protected]> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3508 Reviewed-by: DraVee <[email protected]> Reviewed-by: CamilleLaVey <[email protected]> Co-authored-by: lizzie <[email protected]> Co-committed-by: lizzie <[email protected]>
This commit is contained in:
1 parent
7d81a724ef
commit
89bcb73d47
1 file changed
+13
-2
@@ -71,11 +71,22 @@ void EmitX64::EmitBreakpoint(EmitContext&, IR::Inst*) {
|
||||
code.int3();
|
||||
}
|
||||
|
||||
constexpr bool IsWithin2G(uintptr_t ref, uintptr_t target) {
|
||||
const u64 distance = target - (ref + 5);
|
||||
return !(distance >= 0x8000'0000ULL && distance <= ~0x8000'0000ULL);
|
||||
}
|
||||
|
||||
void EmitX64::EmitCallHostFunction(EmitContext& ctx, IR::Inst* inst) {
|
||||
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
|
||||
ctx.reg_alloc.HostCall(code, nullptr, args[1], args[2], args[3]);
|
||||
code.mov(rax, args[0].GetImmediateU64());
|
||||
code.call(rax);
|
||||
auto target = args[0].GetImmediateU64();
|
||||
if (IsWithin2G(uintptr_t(code.getCurr()), target)) {
|
||||
auto const f = std::bit_cast<void(*)(void)>(target);
|
||||
code.call(f);
|
||||
} else {
|
||||
code.mov(rax, target);
|
||||
code.call(rax);
|
||||
}
|
||||
}
|
||||
|
||||
void EmitX64::PushRSBHelper(Xbyak::Reg64 loc_desc_reg, Xbyak::Reg64 index_reg, IR::LocationDescriptor target) {
|
||||
|
||||
Reference in new issue
Block a user