Skip to content

Commit

Permalink
FEXCore: Constify CTX ptr in InternalThreadState
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Sonicadvance1 committed Nov 28, 2024
1 parent ee592ba commit f24ba29
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions FEXCore/Source/Interface/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,6 @@ void ContextImpl::InitializeCompiler(FEXCore::Core::InternalThreadState* Thread)

Dispatcher->InitThreadPointers(Thread);

Thread->CTX = this;

Thread->PassManager->AddDefaultPasses(this);
Thread->PassManager->AddDefaultValidationPasses();

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion FEXCore/include/FEXCore/Debug/InternalThreadState.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<SignalEvent> SignalReason {SignalEvent::Nothing};

NonMovableUniquePtr<FEXCore::Threads::Thread> ExecutionThread;
Expand Down

0 comments on commit f24ba29

Please sign in to comment.