Add cDAC ObjectiveCMarshal contract and IsTrackedReferenceWithFinalizer API#125895
Draft
Add cDAC ObjectiveCMarshal contract and IsTrackedReferenceWithFinalizer API#125895
Conversation
…er on RuntimeTypeSystem Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/b1b4479b-2345-4f90-b6b6-ea9f33340c64
Co-authored-by: rcj1 <77995559+rcj1@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/b1b4479b-2345-4f90-b6b6-ea9f33340c64
Copilot created this pull request from a session on behalf of
rcj1
March 21, 2026 21:14
View session
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
3 tasks
| Collectible = 0x00200000, // GC depends on this bit. | ||
|
|
||
| ContainsGCPointers = 0x01000000, | ||
| IsTrackedReferenceWithFinalizer = 0x04000000, |
Member
There was a problem hiding this comment.
We need to add this to the RuntimeTypeSystem.md markdown file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements cDAC APIs for Objective-C interop diagnostics as a new
ObjectiveCMarshalcontract, plus addsIsTrackedReferenceWithFinalizerto theRuntimeTypeSystemcontract. Based on draft PR #118250, adjusted per review feedback (contract renamed,TargetNUIntinstead ofnuint, APIs in dedicated contract).Note
This PR was generated with GitHub Copilot.
Changes
New
ObjectiveCMarshalcDAC ContractIObjectiveCMarshal(Abstractions/Contracts/IObjectiveCMarshal.cs): Interface with a single API:Returns the tagged memory pointer for an Objective-C tracked reference object (or
TargetPointer.Nullif none). Setssizeto2 * pointerSizebytes only on success.ObjectiveCMarshal_1(Contracts/ObjectiveCMarshal_1.cs): Version 1 implementation — reads the sync block from the object header, then extractsInteropSyncBlockInfo.TaggedMemory.ObjectiveCMarshalFactory(Contracts/ObjectiveCMarshalFactory.cs): Contract factory.Registered in
ContractRegistryandCachingContractRegistry.datadescriptor.inc: AddedTaggedMemoryfield toInteropSyncBlockInfotype (under#ifdef FEATURE_OBJCMARSHAL) andCDAC_GLOBAL_CONTRACT(ObjectiveCMarshal, 1)(also guarded).syncblk.h: AddedTaggedMemoryoffset tocdac_data<InteropSyncBlockInfo>under#ifdef FEATURE_OBJCMARSHAL.InteropSyncBlockInfo.cs(Data class): AddedTaggedMemoryproperty usingTryGetValueto handle the optionalFEATURE_OBJCMARSHALfield.IsTrackedReferenceWithFinalizeronRuntimeTypeSystemAdded
IsTrackedReferenceWithFinalizer = 0x04000000toWFLAGS_HIGHenum inMethodTableFlags_1.cs, plus a convenience propertybool IsTrackedReferenceWithFinalizer.Added
IsTrackedReferenceWithFinalizer(TypeHandle)toIRuntimeTypeSystem.csand implemented it inRuntimeTypeSystem_1.cs.SOSDacImpl.cs—ISOSDacInterface11Replaced the stub implementations of
IsTrackedTypeandGetTaggedMemorywith full cDAC implementations:IsTrackedType: usesIRuntimeTypeSystem.IsTrackedReferenceWithFinalizerandIObjectiveCMarshal.GetTaggedMemory; returnsS_OKif tracked,S_FALSEif not,E_INVALIDARGfor null inputs.GetTaggedMemory: usesIObjectiveCMarshal.GetTaggedMemory; returnsS_OKwith address and size if tagged memory exists,S_FALSEotherwise.Both methods include
#if DEBUGassertions against the legacy DAC implementation for validation.Documentation
docs/design/datacontracts/ObjectiveCMarshal.md: New contract documentation.docs/design/datacontracts/RuntimeTypeSystem.md: AddedIsTrackedReferenceWithFinalizerto API listing and pseudocode.Testing
All 1322 existing cDAC unit tests pass. The new contract will be exercised when running on an Apple platform with
FEATURE_OBJCMARSHALenabled.