Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
Sonicadvance1 committed Nov 28, 2024

Verified

This commit was signed with the committer’s verified signature.
Sonicadvance1 Ryan Houdek
1 parent ee592ba commit f24ba29
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
@@ -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;
2 changes: 1 addition & 1 deletion FEXCore/include/FEXCore/Debug/InternalThreadState.h
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit f24ba29

Please sign in to comment.