Skip to content

[cDAC] Remove GetClassPointer from the public IRuntimeTypeSystem surface - #130625

Merged
max-charlamb merged 2 commits into
dotnet:mainfrom
max-charlamb:max-charlamb/cdac-internalize-getclasspointer
Jul 13, 2026
Merged

max-charlamb merged 2 commits into
dotnet:mainfrom
max-charlamb:max-charlamb/cdac-internalize-getclasspointer

Conversation

@max-charlamb

Copy link
Copy Markdown
Member

Summary

IRuntimeTypeSystem.GetClassPointer returned a raw EEClass* — a CoreCLR-internal structure with no meaning outside the runtime type system — on the public cDAC contract surface. This PR removes it from the interface and makes it internal to RuntimeTypeSystem_1, in line with the principle that contracts should expose what a diagnostic consumer needs rather than runtime internals.

It had only two consumers outside the RuntimeTypeSystem implementation, both of which used it indirectly:

  • DacDbiImpl.IsValidObject re-implemented the MethodTable -> EEClass -> MethodTable self-consistency check (a port of the runtime's MethodTable::ValidateWithPossibleAV). GetTypeHandle already performs exactly this validation, so IsValidObject now simply relies on GetTypeHandle succeeding.
  • CdacTypeHandle (CallingConvention) read the EEClass optional fields to obtain the SystemV AMD64 eightbyte register-passing classification. That is now exposed through a semantic, cDAC-owned API on IRuntimeTypeSystem.

Changes

  • Remove GetClassPointer from IRuntimeTypeSystem; keep it as an internal helper on RuntimeTypeSystem_1.
  • Add bool TryGetSystemVAmd64EightByteClassification(TypeHandle, out SystemVAmd64EightByteClassification) with cDAC-owned result types:
    • SystemVAmd64Classification enum (mirrors the ABI classification; consumers no longer cast raw bytes to the runtime-internal SystemVClassificationType).
    • Layered SystemVAmd64EightByte { Classification, Size }, with SystemVAmd64EightByteClassification { First, Second? } — the optional second eightbyte replaces a separate count, making invalid states unrepresentable.
  • Simplify DacDbiImpl.IsValidObject to rely on GetTypeHandle validation.
  • Map the cDAC classification enum to the shared JIT SystemVClassificationType explicitly at the CallingConvention adapter boundary.
  • Remove the now-internal GetClassPointer assertions from MethodTableTests (the surrounding IsCanonicalMethodTable coverage remains).
  • Update docs/design/datacontracts/RuntimeTypeSystem.md (API listing, data-descriptor table for EEClass.OptionalFields / EEClassOptionalFields / SystemVEightByteRegistersInfo, and pseudocode).

Testing

  • dotnet build src/native/managed/cdac/cdac.slnx -c Debug — succeeds, 0 warnings/errors.
  • cDAC unit tests: 2693 passed, 0 failed, 16 skipped.

Note

This PR was generated with the assistance of GitHub Copilot.

GetClassPointer returned a raw EEClass* -- a runtime-internal detail -- on the public contract interface. Its two consumers outside RuntimeTypeSystem_1 used it only indirectly:

- DacDbiImpl.IsValidObject re-implemented the MethodTable -> EEClass -> MethodTable validation (a port of MethodTable::ValidateWithPossibleAV) that GetTypeHandle already performs; it now relies on GetTypeHandle succeeding.

- CdacTypeHandle (CallingConvention) read the EEClass optional fields for the SystemV AMD64 eightbyte register classification; this is now exposed via a semantic, cDAC-owned TryGetSystemVAmd64EightByteClassification API (layered SystemVAmd64EightByte structs, optional second eightbyte).

GetClassPointer is now internal to RuntimeTypeSystem_1.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: f2aa5dc4-0c99-43f0-af14-734143849c4a

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 refines the cDAC RuntimeTypeSystem contract surface by removing a raw runtime-internal pointer API (GetClassPointer) and replacing one consumer scenario with a more semantic, contract-owned API for SystemV AMD64 eightbyte classification. It also simplifies legacy DBI object validation logic by relying on existing type-handle validation, and updates docs/tests accordingly.

Changes:

  • Remove GetClassPointer from IRuntimeTypeSystem surface and keep it as an internal helper in RuntimeTypeSystem_1.
  • Introduce TryGetSystemVAmd64EightByteClassification(...) on IRuntimeTypeSystem plus cDAC-owned result types, and adapt CdacTypeHandle to consume it via an explicit mapping layer.
  • Simplify DacDbiImpl.IsValidObject to treat successful GetTypeHandle resolution as validity; update tests and RuntimeTypeSystem.md API/docs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/native/managed/cdac/tests/UnitTests/MethodTableTests.cs Removes assertions that depended on the now-non-public GetClassPointer.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Simplifies IsValidObject to rely on GetTypeHandle validation behavior.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs Makes GetClassPointer internal and adds TryGetSystemVAmd64EightByteClassification implementation.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/CallingConvention/CdacTypeHandle.cs Switches to the new API and explicitly maps cDAC classification to shared SystemVClassificationType.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs Adds new public contract API + new public result types; removes GetClassPointer from the interface.
docs/design/datacontracts/RuntimeTypeSystem.md Updates contract API listing, descriptor table, and pseudocode for the new API.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

@max-charlamb
max-charlamb marked this pull request as ready for review July 13, 2026 16:03
…g defaults, doc read-at-offset style

- Make GetClassPointer private (was internal; no external callers).

- Simplify throwing default interface methods to expression body (drop redundant out-param init).

- RuntimeTypeSystem.md: use GetClassData for the EEClass read and read-at-offset style for the eightbyte fields instead of naming Data.* types.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: f2aa5dc4-0c99-43f0-af14-734143849c4a
Copilot AI review requested due to automatic review settings July 13, 2026 18:00
@max-charlamb
max-charlamb requested a review from rcj1 July 13, 2026 18:03

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

@max-charlamb
max-charlamb enabled auto-merge (squash) July 13, 2026 18:23
@max-charlamb

Copy link
Copy Markdown
Member Author

/ba-g Build Analysis stuck on message ADO dropped

@max-charlamb
max-charlamb merged commit ad68fe7 into dotnet:main Jul 13, 2026
79 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 14, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
…ace (#130625)

## Summary

`IRuntimeTypeSystem.GetClassPointer` returned a raw `EEClass*` — a
CoreCLR-internal structure with no meaning outside the runtime type
system — on the public cDAC contract surface. This PR removes it from
the interface and makes it `internal` to `RuntimeTypeSystem_1`, in line
with the principle that contracts should expose what a diagnostic
consumer needs rather than runtime internals.

It had only two consumers outside the `RuntimeTypeSystem`
implementation, both of which used it indirectly:

- **`DacDbiImpl.IsValidObject`** re-implemented the `MethodTable ->
EEClass -> MethodTable` self-consistency check (a port of the runtime's
`MethodTable::ValidateWithPossibleAV`). `GetTypeHandle` already performs
exactly this validation, so `IsValidObject` now simply relies on
`GetTypeHandle` succeeding.
- **`CdacTypeHandle`** (CallingConvention) read the `EEClass` optional
fields to obtain the SystemV AMD64 eightbyte register-passing
classification. That is now exposed through a semantic, cDAC-owned API
on `IRuntimeTypeSystem`.

## Changes

- Remove `GetClassPointer` from `IRuntimeTypeSystem`; keep it as an
`internal` helper on `RuntimeTypeSystem_1`.
- Add `bool TryGetSystemVAmd64EightByteClassification(TypeHandle, out
SystemVAmd64EightByteClassification)` with cDAC-owned result types:
- `SystemVAmd64Classification` enum (mirrors the ABI classification;
consumers no longer cast raw bytes to the runtime-internal
`SystemVClassificationType`).
- Layered `SystemVAmd64EightByte { Classification, Size }`, with
`SystemVAmd64EightByteClassification { First, Second? }` — the optional
second eightbyte replaces a separate count, making invalid states
unrepresentable.
- Simplify `DacDbiImpl.IsValidObject` to rely on `GetTypeHandle`
validation.
- Map the cDAC classification enum to the shared JIT
`SystemVClassificationType` explicitly at the CallingConvention adapter
boundary.
- Remove the now-internal `GetClassPointer` assertions from
`MethodTableTests` (the surrounding `IsCanonicalMethodTable` coverage
remains).
- Update `docs/design/datacontracts/RuntimeTypeSystem.md` (API listing,
data-descriptor table for `EEClass.OptionalFields` /
`EEClassOptionalFields` / `SystemVEightByteRegistersInfo`, and
pseudocode).

## Testing

- `dotnet build src/native/managed/cdac/cdac.slnx -c Debug` — succeeds,
0 warnings/errors.
- cDAC unit tests: 2693 passed, 0 failed, 16 skipped.

> [!NOTE]
> This PR was generated with the assistance of GitHub Copilot.

---------

Co-authored-by: Max Charlamb <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 13, 2026
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