diff --git a/FEXCore/Source/Interface/Context/Context.cpp b/FEXCore/Source/Interface/Context/Context.cpp index 330f8726d..aff122f71 100644 --- a/FEXCore/Source/Interface/Context/Context.cpp +++ b/FEXCore/Source/Interface/Context/Context.cpp @@ -19,8 +19,8 @@ void InitializeStaticTables(OperatingMode Mode) { IR::InstallOpcodeHandlers(Mode); } -fextl::unique_ptr FEXCore::Context::Context::CreateNewContext() { - return fextl::make_unique(); +fextl::unique_ptr FEXCore::Context::Context::CreateNewContext(const FEXCore::HostFeatures& Features) { + return fextl::make_unique(Features); } void FEXCore::Context::ContextImpl::SetExitHandler(ExitHandler handler) { @@ -43,10 +43,6 @@ void FEXCore::Context::ContextImpl::SetCustomCPUBackendFactory(CustomCPUFactoryT CustomCPUFactory = std::move(Factory); } -void FEXCore::Context::ContextImpl::SetHostFeatures(const FEXCore::HostFeatures& Features) { - HostFeatures = Features; -} - void FEXCore::Context::ContextImpl::SetSignalDelegator(FEXCore::SignalDelegator* _SignalDelegation) { SignalDelegation = _SignalDelegation; } diff --git a/FEXCore/Source/Interface/Context/Context.h b/FEXCore/Source/Interface/Context/Context.h index 8e668c590..9952e98f6 100644 --- a/FEXCore/Source/Interface/Context/Context.h +++ b/FEXCore/Source/Interface/Context/Context.h @@ -96,8 +96,6 @@ public: void SetCustomCPUBackendFactory(CustomCPUFactoryType Factory) override; - void SetHostFeatures(const FEXCore::HostFeatures& Features) override; - void HandleCallback(FEXCore::Core::InternalThreadState* Thread, uint64_t RIP) override; uint64_t RestoreRIPFromHostPC(FEXCore::Core::InternalThreadState* Thread, uint64_t HostPC) override; @@ -264,7 +262,7 @@ public: SignalDelegator* SignalDelegation {}; X86GeneratedCode X86CodeGen; - ContextImpl(); + ContextImpl(const FEXCore::HostFeatures& Features); ~ContextImpl(); static void ThreadRemoveCodeEntry(FEXCore::Core::InternalThreadState* Thread, uint64_t GuestRIP); diff --git a/FEXCore/Source/Interface/Core/Core.cpp b/FEXCore/Source/Interface/Core/Core.cpp index 1ebcea8f7..6b2fdc92c 100644 --- a/FEXCore/Source/Interface/Core/Core.cpp +++ b/FEXCore/Source/Interface/Core/Core.cpp @@ -74,8 +74,9 @@ $end_info$ #include namespace FEXCore::Context { -ContextImpl::ContextImpl() - : CPUID {this} +ContextImpl::ContextImpl(const FEXCore::HostFeatures& Features) + : HostFeatures {Features} + , CPUID {this} , IRCaptureCache {this} { #ifdef BLOCKSTATS BlockData = std::make_unique(); diff --git a/FEXCore/include/FEXCore/Core/Context.h b/FEXCore/include/FEXCore/Core/Context.h index 9d0558ca9..e36144718 100644 --- a/FEXCore/include/FEXCore/Core/Context.h +++ b/FEXCore/include/FEXCore/Core/Context.h @@ -119,7 +119,7 @@ public: * * @return a new context object */ - FEX_DEFAULT_VISIBILITY static fextl::unique_ptr CreateNewContext(); + FEX_DEFAULT_VISIBILITY static fextl::unique_ptr CreateNewContext(const FEXCore::HostFeatures& Features); /** * @brief Allows setting up in memory code and other things prior to launchign code execution @@ -164,13 +164,6 @@ public: */ FEX_DEFAULT_VISIBILITY virtual void SetCustomCPUBackendFactory(CustomCPUFactoryType Factory) = 0; - /** - * @brief Informs the context what features the host supports. - * - * @param Features Filled out HostFeatures structure to copy - */ - FEX_DEFAULT_VISIBILITY virtual void SetHostFeatures(const FEXCore::HostFeatures& Features) = 0; - FEX_DEFAULT_VISIBILITY virtual void HandleCallback(FEXCore::Core::InternalThreadState* Thread, uint64_t RIP) = 0; ///< State reconstruction helpers diff --git a/Source/Tools/CodeSizeValidation/Main.cpp b/Source/Tools/CodeSizeValidation/Main.cpp index d35197ade..513ae7a85 100644 --- a/Source/Tools/CodeSizeValidation/Main.cpp +++ b/Source/Tools/CodeSizeValidation/Main.cpp @@ -597,11 +597,10 @@ int main(int argc, char** argv, char** const envp) { FEXCore::Context::InitializeStaticTables(TestHeaderData->Bitness == 64 ? FEXCore::Context::MODE_64BIT : FEXCore::Context::MODE_32BIT); // Create FEXCore context. - auto CTX = FEXCore::Context::Context::CreateNewContext(); - + fextl::unique_ptr CTX; { auto HostFeatures = FEX::FetchHostFeatures(); - CTX->SetHostFeatures(HostFeatures); + CTX = FEXCore::Context::Context::CreateNewContext(HostFeatures); } auto SignalDelegation = FEX::DummyHandlers::CreateSignalDelegator(); diff --git a/Source/Tools/FEXLoader/FEXLoader.cpp b/Source/Tools/FEXLoader/FEXLoader.cpp index c3612824f..56646286f 100644 --- a/Source/Tools/FEXLoader/FEXLoader.cpp +++ b/Source/Tools/FEXLoader/FEXLoader.cpp @@ -453,11 +453,10 @@ int main(int argc, char** argv, char** const envp) { // System allocator is now system allocator or FEX FEXCore::Context::InitializeStaticTables(Loader.Is64BitMode() ? FEXCore::Context::MODE_64BIT : FEXCore::Context::MODE_32BIT); - auto CTX = FEXCore::Context::Context::CreateNewContext(); - + fextl::unique_ptr CTX; { auto HostFeatures = FEX::FetchHostFeatures(); - CTX->SetHostFeatures(HostFeatures); + CTX = FEXCore::Context::Context::CreateNewContext(HostFeatures); } // Setup TSO hardware emulation immediately after initializing the context. diff --git a/Source/Tools/TestHarnessRunner/TestHarnessRunner.cpp b/Source/Tools/TestHarnessRunner/TestHarnessRunner.cpp index 926d01029..0dfb5bea1 100644 --- a/Source/Tools/TestHarnessRunner/TestHarnessRunner.cpp +++ b/Source/Tools/TestHarnessRunner/TestHarnessRunner.cpp @@ -249,8 +249,7 @@ int main(int argc, char** argv, char** const envp) { FEXCore::Context::InitializeStaticTables(Loader.Is64BitMode() ? FEXCore::Context::MODE_64BIT : FEXCore::Context::MODE_32BIT); auto HostFeatures = FEX::FetchHostFeatures(); - auto CTX = FEXCore::Context::Context::CreateNewContext(); - CTX->SetHostFeatures(HostFeatures); + auto CTX = FEXCore::Context::Context::CreateNewContext(HostFeatures); #ifndef _WIN32 auto SignalDelegation = FEX::HLE::CreateSignalDelegator(CTX.get(), {}); diff --git a/Source/Windows/ARM64EC/Module.cpp b/Source/Windows/ARM64EC/Module.cpp index e9d58e6b1..0c1a8d6ea 100644 --- a/Source/Windows/ARM64EC/Module.cpp +++ b/Source/Windows/ARM64EC/Module.cpp @@ -503,10 +503,9 @@ NTSTATUS ProcessInit() { SyscallHandler = fextl::make_unique(); Exception::HandlerConfig.emplace(); - CTX = FEXCore::Context::Context::CreateNewContext(); { auto HostFeatures = FEX::FetchHostFeatures(); - CTX->SetHostFeatures(HostFeatures); + CTX = FEXCore::Context::Context::CreateNewContext(HostFeatures); } CTX->SetSignalDelegator(SignalDelegator.get()); diff --git a/Source/Windows/WOW64/Module.cpp b/Source/Windows/WOW64/Module.cpp index 4780dca9b..db68f5faa 100644 --- a/Source/Windows/WOW64/Module.cpp +++ b/Source/Windows/WOW64/Module.cpp @@ -436,10 +436,9 @@ void BTCpuProcessInit() { SyscallHandler = fextl::make_unique(); Context::HandlerConfig.emplace(); - CTX = FEXCore::Context::Context::CreateNewContext(); { auto HostFeatures = FEX::FetchHostFeatures(); - CTX->SetHostFeatures(HostFeatures); + CTX = FEXCore::Context::Context::CreateNewContext(HostFeatures); } CTX->SetSignalDelegator(SignalDelegator.get());