Skip to content

Create an on-stack instance of FindReferenceTargetsCallback. #116081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

AaronRobinsonMSFT
Copy link
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 Copilot AI review requested due to automatic review settings May 28, 2025 23:35
@AaronRobinsonMSFT
Copy link
Member Author

/cc @jkoritzinsky @agocke

Copy link
Contributor

@Copilot 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 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

Copy link
Contributor

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

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit e5866fe into dotnet:main May 29, 2025
92 of 94 checks passed
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the create_onstack_callback branch May 29, 2025 18:02
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.

2 participants