From a8f797d36bb5cb083386ea374fd906a2c0a75c38 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 12 Dec 2023 10:56:33 -0800 Subject: [PATCH] Dispatcher: Convert GetCompileBlockPtr to using PMF helper This was older code that was written before the PMF helper was available. Switch it over. --- .../Interface/Core/Dispatcher/Dispatcher.cpp | 16 +++------------- .../Interface/Core/Dispatcher/Dispatcher.h | 2 -- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp b/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp index e838509c4..0372df3cd 100644 --- a/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp +++ b/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp @@ -5,6 +5,7 @@ #include "Interface/Core/Dispatcher/Dispatcher.h" #include "Interface/Core/LookupCache.h" #include "Interface/Core/X86HelperGen.h" +#include "Utils/MemberFunctionToPointer.h" #include #include @@ -41,18 +42,6 @@ void Dispatcher::SleepThread(FEXCore::Context::ContextImpl *ctx, FEXCore::Core:: ctx->IdleWaitCV.notify_all(); } -uint64_t Dispatcher::GetCompileBlockPtr() { - using ClassPtrType = uintptr_t (FEXCore::Context::ContextImpl::*)(FEXCore::Core::CpuStateFrame *, uint64_t, uint64_t); - union PtrCast { - ClassPtrType ClassPtr; - uintptr_t Data; - }; - - PtrCast CompileBlockPtr; - CompileBlockPtr.ClassPtr = &FEXCore::Context::ContextImpl::CompileBlock; - return CompileBlockPtr.Data; -} - constexpr size_t MAX_DISPATCHER_CODE_SIZE = 4096 * 2; Dispatcher::Dispatcher(FEXCore::Context::ContextImpl *ctx, const DispatcherConfig &config) @@ -517,7 +506,8 @@ void Dispatcher::EmitDispatcher() { Bind(&l_Sleep); dc64(reinterpret_cast(SleepThread)); Bind(&l_CompileBlock); - dc64(GetCompileBlockPtr()); + FEXCore::Utils::MemberFunctionToPointerCast PMF(&FEXCore::Context::ContextImpl::CompileBlock); + dc64(PMF.GetConvertedPointer()); Start = reinterpret_cast(DispatchPtr); End = GetCursorAddress(); diff --git a/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.h b/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.h index c40d97a30..542347fb2 100644 --- a/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.h +++ b/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.h @@ -114,8 +114,6 @@ protected: static void SleepThread(FEXCore::Context::ContextImpl *ctx, FEXCore::Core::CpuStateFrame *Frame); - static uint64_t GetCompileBlockPtr(); - using AsmDispatch = void(*)(FEXCore::Core::CpuStateFrame *Frame); using JITCallback = void(*)(FEXCore::Core::CpuStateFrame *Frame, uint64_t RIP);