From f24ba29068fe58b0b66a190a0e7f3fb9c3962f75 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Thu, 28 Nov 2024 02:27:28 -0800 Subject: [PATCH] FEXCore: Constify CTX ptr in InternalThreadState The CTX pointer in the InternalThreadState object will not and must not change, since it is associated with that CTX object. Contify it to codify it. --- FEXCore/Source/Interface/Core/Core.cpp | 6 +++--- FEXCore/include/FEXCore/Debug/InternalThreadState.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/FEXCore/Source/Interface/Core/Core.cpp b/FEXCore/Source/Interface/Core/Core.cpp index 34f9c79098..60e7fadcd9 100644 --- a/FEXCore/Source/Interface/Core/Core.cpp +++ b/FEXCore/Source/Interface/Core/Core.cpp @@ -402,8 +402,6 @@ void ContextImpl::InitializeCompiler(FEXCore::Core::InternalThreadState* Thread) Dispatcher->InitThreadPointers(Thread); - Thread->CTX = this; - Thread->PassManager->AddDefaultPasses(this); Thread->PassManager->AddDefaultValidationPasses(); @@ -418,7 +416,9 @@ void ContextImpl::InitializeCompiler(FEXCore::Core::InternalThreadState* Thread) FEXCore::Core::InternalThreadState* ContextImpl::CreateThread(uint64_t InitialRIP, uint64_t StackPointer, const FEXCore::Core::CPUState* NewThreadState, uint64_t ParentTID) { - FEXCore::Core::InternalThreadState* Thread = new FEXCore::Core::InternalThreadState {}; + FEXCore::Core::InternalThreadState* Thread = new FEXCore::Core::InternalThreadState { + .CTX = this, + }; Thread->CurrentFrame->State.gregs[X86State::REG_RSP] = StackPointer; Thread->CurrentFrame->State.rip = InitialRIP; diff --git a/FEXCore/include/FEXCore/Debug/InternalThreadState.h b/FEXCore/include/FEXCore/Debug/InternalThreadState.h index 3dc710a9db..803ed2a14f 100644 --- a/FEXCore/include/FEXCore/Debug/InternalThreadState.h +++ b/FEXCore/include/FEXCore/Debug/InternalThreadState.h @@ -87,7 +87,7 @@ struct InternalThreadState : public FEXCore::Allocator::FEXAllocOperators { std::atomic_bool ThreadSleeping {false}; } RunningEvents; - FEXCore::Context::Context* CTX; + FEXCore::Context::Context* const CTX; std::atomic SignalReason {SignalEvent::Nothing}; NonMovableUniquePtr ExecutionThread;