Skip to content

Replace CoreCLR Wrapper type. - #137220

Merged
AaronRobinsonMSFT merged 8 commits into
dotnet:mainfrom
AaronRobinsonMSFT:arobins/remove-conditional-state-holder
Nov 11, 2026
Merged

AaronRobinsonMSFT merged 8 commits into
dotnet:mainfrom
AaronRobinsonMSFT:arobins/remove-conditional-state-holder

Conversation

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

Replace legacy CoreCLR holders with LifetimeHolder or targeted holder types, and remove obsolete templates.

NativeAOT's holder implementations are unchanged.

Note

This PR description was generated with GitHub Copilot.

AaronRobinsonMSFT and others added 8 commits November 7, 2026 17:40
Use LifetimeHolder for hijack-lock ownership through Thread::TryAcquireHijackLock. Replace thread-context guards with direct patch-skip checks and remove unused spin-lock try-acquire APIs.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: a55d02a1-d641-4165-9e80-339edfabe2b4
Co-authored-by: Copilot <[email protected]>

Copilot-Session: a55d02a1-d641-4165-9e80-339edfabe2b4
Co-authored-by: Copilot <[email protected]>
Copilot-Session: a55d02a1-d641-4165-9e80-339edfabe2b4
Co-authored-by: Copilot <[email protected]>
Copilot-Session: a55d02a1-d641-4165-9e80-339edfabe2b4
Co-authored-by: Copilot <[email protected]>
Copilot-Session: a55d02a1-d641-4165-9e80-339edfabe2b4
Co-authored-by: Copilot <[email protected]>
Copilot-Session: a55d02a1-d641-4165-9e80-339edfabe2b4
Co-authored-by: Copilot <[email protected]>
Copilot-Session: a55d02a1-d641-4165-9e80-339edfabe2b4
Co-authored-by: Copilot <[email protected]>

Copilot-Session: a55d02a1-d641-4165-9e80-339edfabe2b4
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Comment thread src/coreclr/debug/ee/debugger.h Resolved
Comment thread src/coreclr/vm/simplerwlock.hpp Resolved
@AaronRobinsonMSFT
AaronRobinsonMSFT marked this pull request as ready for review November 10, 2026 00:03
@AaronRobinsonMSFT AaronRobinsonMSFT changed the title Replace legacy CoreCLR holders Replace CoreCLR Wrapper type. Nov 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The cross-cutting ownership refactor affects VM locking, thread hijacking, debugger cleanup, and DAC behavior, requiring platform-specific builds and runtime tests that were unavailable during review.

No open issues 🎉

What changed in this PR

This PR modernizes CoreCLR resource and lock ownership by replacing legacy Wrapper holders with LifetimeHolder or specialized holders. NativeAOT holder implementations remain unchanged.

Changes:

  • Migrates resource cleanup and ownership transfer to Free() and Detach().
  • Introduces explicit lock-acquisition helpers and updates their callers.
  • Removes obsolete holder templates and helpers, retaining explicit DAC-specific cleanup behavior.
File Description
src/​coreclr/​vm/​threadsuspend.cpp Uses direct patch-skip checks and explicit hijack-lock acquisition.
src/​coreclr/​vm/​threads.h Adds a lifetime-based hijack-lock holder; removes the context-check holder.
src/​coreclr/​vm/​syncblk.cpp Migrates sync-block memory cleanup to LifetimeHolder.
src/​coreclr/​vm/​spinlock.h Removes unused conditional spin-lock helpers.
src/​coreclr/​vm/​simplerwlock.hpp Replaces DacHolder with explicit runtime and DAC variants.
src/​coreclr/​vm/​readytoruninfo.cpp Uses conditional load-lock acquisition through TakeLoadLock.
src/​coreclr/​vm/​proftoeeinterfaceimpl.cpp Uses explicit hijack-lock acquisition for profiler stack walks.
src/​coreclr/​vm/​prestub.cpp Updates JIT lock acquisition and release.
src/​coreclr/​vm/​methodtablebuilder.cpp Migrates method-data wrappers to MethodDataHolder.
src/​coreclr/​vm/​methodtable.inl Makes slot copying accept a method-data pointer.
src/​coreclr/​vm/​methodtable.h Defines lifetime-based method-data ownership.
src/​coreclr/​vm/​methodtable.cpp Updates class-initialization locks and method-data holders.
src/​coreclr/​vm/​loaderallocator.cpp Uses explicit list-lock acquisition during cleanup.
src/​coreclr/​vm/​listlock.h Introduces lifetime-based list and entry-lock holders.
src/​coreclr/​vm/​dllimport.cpp Updates IL-stub lock release and reacquisition.
src/​coreclr/​vm/​crst.h Replaces DAC holder aliases with explicit variants.
src/​coreclr/​vm/​comcallablewrapper.cpp Separates owned and borrowed refcounted handles.
src/​coreclr/​vm/​classlayoutinfo.cpp Updates native-layout lock acquisition.
src/​coreclr/​vm/​class.cpp Uses the replacement method-data holder and null check.
src/​coreclr/​vm/​assemblybinder.cpp Acquires assembly load locks through TakeLoadLock.
src/​coreclr/​vm/​assembly.cpp Updates assembly-registration lock acquisition.
src/​coreclr/​vm/​appdomain.hpp Defines lifetime-based load-lock holders and acquisition helpers.
src/​coreclr/​vm/​appdomain.cpp Migrates load-lock callers and explicit release operations.
src/​coreclr/​utilcode/​sstring.cpp Localizes the allocation holder used for message formatting.
src/​coreclr/​inc/​utilcode.h Removes the obsolete clr::SafeDelete helper.
src/​coreclr/​inc/​holder.h Removes legacy templates and specializes counter ownership.
src/​coreclr/​debug/​ee/​funceval.cpp Uses Free() for function-evaluation cleanup.
src/​coreclr/​debug/​ee/​debugger.h Migrates debugger resource holders and DAC lock aliases.
src/​coreclr/​debug/​ee/​debugger.cpp Updates external-memory access and ownership transfer.

Review effort: Balanced

@AaronRobinsonMSFT
AaronRobinsonMSFT merged commit 4487f7e into dotnet:main Nov 11, 2026
102 of 104 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Nov 11, 2026
@AaronRobinsonMSFT
AaronRobinsonMSFT deleted the arobins/remove-conditional-state-holder branch November 11, 2026 18:16
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants