Skip to content

Create an on-stack instance of FindReferenceTargetsCallback. - #116081

Merged
AaronRobinsonMSFT merged 2 commits into
dotnet:mainfrom
AaronRobinsonMSFT:create_onstack_callback
May 29, 2025
Merged

Create an on-stack instance of FindReferenceTargetsCallback.#116081
AaronRobinsonMSFT merged 2 commits into
dotnet:mainfrom
AaronRobinsonMSFT:create_onstack_callback

Conversation

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

This would remove the transient static value that must be manually managed. It also removes an
unnecessary FixedAddressValueType static field.

This would remove the transient static value that must be
manually managed. It also removes an odd
FixedAddressValueType instance.
@AaronRobinsonMSFT AaronRobinsonMSFT added this to the 10.0.0 milestone May 28, 2025
Copilot AI review requested due to automatic review settings May 28, 2025 23:35
@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

/cc @jkoritzinsky @agocke

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.

Pull Request Overview

This PR refactors the TrackerObjectManager to eliminate a transient static field by creating an on‑stack instance of FindReferenceTargetsCallback.

  • Removed the static s_findReferencesTargetCallback field and its associated static GCHandle.
  • Replaced static callback usage with an on‑stack ref struct instance to better manage lifetime and thread-safety.
Comments suppressed due to low confidence (1)

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/TrackerObjectManager.NativeAot.cs:204

  • [nitpick] The type name 'Instance' is generic and may cause confusion when reading the code. Consider renaming it to something more descriptive, such as 'OnStackCallback', to clearly indicate its purpose.
internal ref struct Instance

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants