Repository navigation
[cDAC] Reduce SOSDacImpl.GetFieldDescData dependencies (add GetFieldDescNext; use GetFieldDescApproxTypeHandle) - #130643
Merged
max-charlamb merged 6 commits intoJul 14, 2026
Conversation
…on FieldDesc layout SOSDacImpl.GetFieldDescData computed the next FieldDesc as ptr + sizeof(FieldDesc), which requires the consumer to know the FieldDesc layout (via DataType.FieldDesc). "Next" is a synthetic notion -- a FieldDesc has no next pointer -- so producing it is an algorithm that belongs in the contract. Add GetFieldDescNext(TargetPointer) to IRuntimeTypeSystem; the CoreCLR implementation returns ptr + sizeof(FieldDesc). The consumer now calls the contract method and no longer references the FieldDesc data descriptor. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors SOS legacy GetFieldDescData to stop computing the “next FieldDesc” via inline pointer arithmetic, moving that algorithm behind the cDAC IRuntimeTypeSystem contract.
Changes:
- Adds
IRuntimeTypeSystem.GetFieldDescNext(TargetPointer)to represent the synthetic “next FieldDesc” computation as a contract algorithm. - Implements
GetFieldDescNextinRuntimeTypeSystem_1(CoreCLR) usingsizeof(FieldDesc)via the data descriptor size. - Updates
SOSDacImpl.GetFieldDescDatato call the new contract API when populatingDacpFieldDescData.NextField.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs | Switches NextField computation to the contract API. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs | Adds CoreCLR implementation of GetFieldDescNext. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs | Adds the new contract method to the FieldDesc inspection APIs. |
…tFieldDescData SOSDacImpl.GetFieldDescData decoded the field signature inline (via ISignature) to obtain the field type's TypeHandle. GetFieldDescApproxTypeHandle already encapsulates that exact decode, so call it instead and drop the ISignature dependency. Behavior is unchanged -- the catch-all in GetFieldDescApproxTypeHandle tracks the legacy DAC's EX_CATCH, and the DEBUG parity assert still passes. Co-authored-by: Copilot <[email protected]>
max-charlamb
marked this pull request as ready for review
July 13, 2026 20:20
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
…Type) Co-authored-by: Copilot <[email protected]>
noahfalk
approved these changes
Jul 14, 2026
Change the RTS FieldDesc-advance API from a null-returning GetFieldDescNext(TargetPointer) to a Try-pattern TryGetFieldDescNext(TargetPointer, out TargetPointer) that returns false when called on the last FieldDesc of a type. The implementation locates the enclosing type via the FieldDesc's enclosing MethodTable and computes the end of the contiguous FieldDesc list (mirroring GetFieldDescList) so callers never receive a past-the-end pointer. SOSDacImpl surfaces the 'no next field' result as 0 to match the legacy DAC ABI, and the DEBUG parity assert tolerates that against the DAC's past-the-end pointer. Updates RuntimeTypeSystem.md and adds a unit test. Co-authored-by: Copilot <[email protected]>
noahfalk
approved these changes
Jul 14, 2026
max-charlamb
enabled auto-merge (squash)
July 14, 2026 18:56
Member
Author
|
/ba-g osx test infra timeout |
This was referenced Jul 15, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Two small refactors that reduce what
SOSDacImpl.GetFieldDescDatadoes directly, delegating to theRuntimeTypeSystemcontract instead.1.
GetFieldDescNext-- stop depending onFieldDesclayoutThe consumer computed the next
FieldDescinline asptr + sizeof(FieldDesc)(viaDataType.FieldDesc). "Next" is a synthetic notion -- aFieldDeschas no next pointer -- so producing it is an algorithm that belongs in the contract.TargetPointer GetFieldDescNext(TargetPointer fieldDescPointer)toIRuntimeTypeSystem.fieldDescPointer + sizeof(FieldDesc)(same value as before, now behind the contract).SOSDacImpl.GetFieldDescDatacalls it and no longer references theFieldDescdata descriptor.2. Use
GetFieldDescApproxTypeHandlefor the field-type MethodTableGetFieldDescDatadecoded the field signature inline (viaISignature) to get the field type'sTypeHandle.GetFieldDescApproxTypeHandlealready encapsulates that exact decode, so the consumer now calls it and drops itsISignaturedependency.Behavior is unchanged for CoreCLR (the
catch-all inGetFieldDescApproxTypeHandletracks the legacy DAC'sEX_CATCH), and the#if DEBUGlegacy-DAC parity check still passes.Testing
Note
This PR was created with GitHub Copilot.