Skip to content

Merge ThreadTasks into ThreadState, remove ThreadTasks#127884

Merged
jkotas merged 2 commits intomainfrom
copilot/merge-threadtasks-into-threadstate
May 7, 2026
Merged

Merge ThreadTasks into ThreadState, remove ThreadTasks#127884
jkotas merged 2 commits intomainfrom
copilot/merge-threadtasks-into-threadstate

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

ThreadTasks was a single-entry enum (TT_CleanupSyncBlock) backed by a separate m_ThreadTasks field on Thread, even though ThreadState had an unused bit (0x00000020) and already supported atomic set/reset via InterlockedOr/InterlockedAnd on m_State. The old code even contained a TODO noting the two should probably be merged.

Copilot AI review requested due to automatic review settings May 6, 2026 20:36
Copilot AI review requested due to automatic review settings May 6, 2026 20:36
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @VSadov
See info in area-owners.md if you want to be subscribed.

@jkotas jkotas marked this pull request as ready for review May 6, 2026 20:55
Copilot AI review requested due to automatic review settings May 6, 2026 20:55
@jkotas jkotas requested a review from max-charlamb May 6, 2026 20:55
@jkotas
Copy link
Copy Markdown
Member

jkotas commented May 6, 2026

Related to #127848

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR simplifies CoreCLR thread bookkeeping by merging the single ThreadTasks flag (TT_CleanupSyncBlock) into the existing ThreadState bitfield, using a previously-unused state bit. This removes the dedicated m_ThreadTasks field and relies on the already-established atomic update patterns for m_State.

Changes:

  • Introduces TS_SyncBlockCleanup (0x00000020) in ThreadState and routes sync-block cleanup queries/updates through m_State.
  • Removes the ThreadTasks enum and the m_ThreadTasks member from Thread, along with its constructor initialization and alignment assertion.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/coreclr/vm/threads.h Adds TS_SyncBlockCleanup, removes ThreadTasks / m_ThreadTasks, and switches cleanup flag operations to use atomic updates on m_State.
src/coreclr/vm/threads.cpp Removes m_ThreadTasks initialization and updates the alignment comment/asserts accordingly.

Copy link
Copy Markdown
Member

@VSadov VSadov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@jkotas jkotas merged commit 06ca675 into main May 7, 2026
108 of 110 checks passed
@jkotas jkotas deleted the copilot/merge-threadtasks-into-threadstate branch May 7, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants