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;