Skip to content

[cDAC] Implement GetTieredVersions for cDAC#126164

Merged
barosiak merged 17 commits into
dotnet:mainfrom
barosiak:barosiak/GetTieredVersions
Apr 3, 2026
Merged

[cDAC] Implement GetTieredVersions for cDAC#126164
barosiak merged 17 commits into
dotnet:mainfrom
barosiak:barosiak/GetTieredVersions

Conversation

@barosiak

@barosiak barosiak commented Mar 26, 2026

Copy link
Copy Markdown
Member

Summary

Implement ISOSDacInterface5.GetTieredVersions for the cDAC. Each native code version is classified into the correct optimization tier by checking R2R image bounds and tiered-compilation eligibility.
Non-tiered methods and methods without generated code report Unknown instead of mirroring runtime policy calculations, keeping the contract surface minimal. The native DAC in request.cpp is updated to match.

Changes

Native (C++): Expose OptimizationTier on NativeCodeVersionNode and MethodDescCodeData. Simplify
native DAC GetTieredVersions to report Unknown for non-tiered methods.

Contracts & abstractions:

  • ICodeVersionsGetOptimizationTier, OptimizationTier enum
  • IRuntimeTypeSystemGetMethodDescOptimizationTier, IsEligibleForTieredCompilation
  • ILoaderIsReadyToRun

Legacy layer: Full SOSDacImpl.GetTieredVersions implementation with newly added DacpTieredVersionData struct and #if DEBUG validation against the legacy impl.

Data: OptimizationTier field in MethodDescCodeData and NativeCodeVersionNode.

Test Results

Parameterized tests covering explicit handles (all tier values), synthetic handles (RTS delegation + unknown-when-no-code-data), R2R detection, buffer truncation, invalid inputs, and non-tiered methods reporting Unknown.

@barosiak barosiak requested review from max-charlamb and rcj1 March 26, 2026 19:07
@barosiak barosiak self-assigned this Mar 26, 2026
Copilot AI review requested due to automatic review settings March 26, 2026 19:07
@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.

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

Implements ISOSDacInterface5.GetTieredVersions in the cDAC by exposing optimization-tier data through contracts/metadata and using it to classify native code versions (R2R vs tiered compilation tiers vs minopts/optimized fallbacks).

Changes:

  • Add optimization tier plumbing to contracts/data models (NativeCodeVersionNode, MethodDescCodeData) and expose EEConfig + debugger control globals needed for tier classification.
  • Implement SOSDacImpl.GetTieredVersions using the new contract APIs and map contract tiers to the legacy DacpTieredVersionData.OptimizationTier values.
  • Add unit tests for ICodeVersions.GetOptimizationTier (explicit/synthetic handles + missing-field fallback).

Reviewed changes

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

Show a summary per file
File Description
src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.CodeVersions.cs Extend mock NativeCodeVersionNode layout to optionally include OptimizationTier.
src/native/managed/cdac/tests/CodeVersionsTests.cs Add parameterized tests for ICodeVersions.GetOptimizationTier behaviors.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs Implement ISOSDacInterface5.GetTieredVersions using cDAC contracts and tier mapping logic.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ISOSDacInterface.cs Introduce DacpTieredVersionData struct and update GetTieredVersions signature to use it.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/NativeCodeVersionNode.cs Add optional OptimizationTier field reading from the target.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/MethodDescCodeData.cs Add optional OptimizationTier field reading from the target.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/EEConfig.cs New data model for reading EEConfig tiering/debug/minopts settings from the target.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs Add tier-related RTS APIs: per-method tier, initial tier, eligibility, and JIT-opt-disabled detection.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Loader_1.cs Add IsReadyToRun and GetDebuggerInfoBits, plus module flag plumbing for profiler opt-disable.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/CodeVersions_1.cs Add ICodeVersions.GetOptimizationTier implementation (explicit + synthetic).
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Constants.cs Expose new globals: CORDebuggerControlFlags and EEConfig.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/DataType.cs Add DataType.EEConfig.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeTypeSystem.cs Add tiering/JIT-opt-disabled APIs and DebuggerControlFlag enum.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ILoader.cs Add R2R + debugger-info APIs and new module flags/DebuggerAssemblyControlFlags.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/ICodeVersions.cs Add GetOptimizationTier API and NativeCodeVersionOptimizationTier enum.
src/coreclr/vm/eeconfig.h Export EEConfig fields via cdac_data<EEConfig> for contract reading.
src/coreclr/vm/datadescriptor/datadescriptor.inc Add CDAC descriptors for EEConfig and new globals/fields (OptimizationTier, EEConfig, CORDebuggerControlFlags).
src/coreclr/vm/codeversion.h Export NativeCodeVersionNode::m_optTier offset via cdac_data.

@rcj1

rcj1 commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Please update the docs for the contracts you updated

@jkotas

jkotas commented Mar 27, 2026

Copy link
Copy Markdown
Member

#119879 has earlier abandoned version of this change. It has discussion about needing to refactor the runtime implementation before it gets exposed via cDAC. Are we no longer planning to do that?

@rcj1

rcj1 commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

#119879 has earlier abandoned version of this change. It has discussion about needing to refactor the runtime implementation before it gets exposed via cDAC. Are we no longer planning to do that?

#125243

Copilot AI review requested due to automatic review settings March 27, 2026 22:19

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 25 out of 25 changed files in this pull request and generated 3 comments.

Comment thread docs/design/datacontracts/Loader.md
Comment thread src/coreclr/vm/ceeload.h Outdated
Comment thread src/coreclr/vm/eeconfig.h Outdated

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 19 out of 20 changed files in this pull request and generated 5 comments.

Comment thread src/native/managed/cdac/tests/CodeVersionsTests.cs
Comment thread docs/design/datacontracts/CodeVersions.md
Comment thread docs/design/datacontracts/RuntimeTypeSystem.md
Copilot AI review requested due to automatic review settings April 1, 2026 21:56

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 19 out of 20 changed files in this pull request and generated 4 comments.

Comment thread src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.CodeVersions.cs Outdated
Comment thread src/native/managed/cdac/tests/CodeVersionsTests.cs Outdated

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 19 out of 20 changed files in this pull request and generated 2 comments.

Comment thread docs/design/datacontracts/RuntimeTypeSystem.md

@max-charlamb max-charlamb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good modulo style nits

Co-authored-by: Max Charlamb <44248479+max-charlamb@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 2, 2026 19:36

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 19 out of 20 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings April 2, 2026 19:57
@barosiak barosiak enabled auto-merge (squash) April 2, 2026 19:58

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 19 out of 20 changed files in this pull request and generated 2 comments.

Comment thread src/native/managed/cdac/tests/MockDescriptors/MockDescriptors.CodeVersions.cs Outdated
@barosiak barosiak merged commit e2d5803 into dotnet:main Apr 3, 2026
122 checks passed
radekdoulik pushed a commit to radekdoulik/runtime that referenced this pull request Apr 9, 2026
## Summary
Implement `ISOSDacInterface5.GetTieredVersions` for the cDAC. Each
native code version is classified into the correct optimization tier by
checking R2R image bounds and tiered-compilation eligibility.
Non-tiered methods and methods without generated code report Unknown
instead of mirroring runtime policy calculations, keeping the contract
surface minimal. The native DAC in request.cpp is updated to match.

 ## Changes
**Native (C++):** Expose `OptimizationTier` on `NativeCodeVersionNode`
and `MethodDescCodeData`. Simplify
native DAC GetTieredVersions to report Unknown for non-tiered methods.
 
 **Contracts & abstractions:**
- `ICodeVersions` — `GetOptimizationTier`, `OptimizationTier` enum
- `IRuntimeTypeSystem` — `GetMethodDescOptimizationTier`,
`IsEligibleForTieredCompilation`
 - `ILoader` — `IsReadyToRun`

**Legacy layer:** Full `SOSDacImpl.GetTieredVersions` implementation
with newly added `DacpTieredVersionData` struct and `#if DEBUG`
validation against the legacy impl.
 
**Data:** `OptimizationTier` field in `MethodDescCodeData` and
`NativeCodeVersionNode`.
 
 ## Test Results
Parameterized tests covering explicit handles (all tier values),
synthetic handles (RTS delegation + unknown-when-no-code-data), R2R
detection, buffer truncation, invalid inputs, and non-tiered methods
reporting Unknown.

---------

Co-authored-by: Max Charlamb <44248479+max-charlamb@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators May 3, 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.

6 participants