[NativeAOT] Add managed type sub-descriptor for cDAC#127025
Closed
max-charlamb wants to merge 1 commit intodev/max-charlamb/nativeaot-datadescriptorfrom
Closed
[NativeAOT] Add managed type sub-descriptor for cDAC#127025max-charlamb wants to merge 1 commit intodev/max-charlamb/nativeaot-datadescriptorfrom
max-charlamb wants to merge 1 commit intodev/max-charlamb/nativeaot-datadescriptorfrom
Conversation
Add ILC infrastructure to emit managed type field offsets as a cDAC sub-descriptor, enabling diagnostic tools to inspect managed type instances without runtime metadata. Types opt-in via [CdacType] and [CdacField] attributes in CoreLib. ILC discovers annotated types at compile time, computes field offsets, and emits a ContractDescriptor (DotNetManagedContractDescriptor) that the native runtime references as a sub-descriptor. Includes: - CdacTypeAttribute / CdacFieldAttribute in NativeAOT CoreLib - ManagedDataDescriptorNode: emits ContractDescriptor with JSON layout - ManagedDataDescriptorProvider: attribute-based type discovery with validation (rejects generics, duplicates, empty names) - Thread.NativeAot.cs annotated with ManagedThread descriptor fields Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
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.
Note
This PR was created with assistance from GitHub Copilot.
Summary
Adds ILC infrastructure to emit managed type field offsets as a cDAC sub-descriptor, enabling diagnostic tools to inspect managed type instances without runtime metadata (critical for NativeAOT where metadata may be stripped).
Stacked on #127024 — review that PR first.
Changes
Attribute-based type discovery
Instead of hardcoding BCL implementation details in the compiler (as flagged in #126972 review), types opt-in via internal attributes in NativeAOT CoreLib:
[CdacType(""ManagedThread"")]on the type — specifies the cDAC descriptor type name[CdacField(""ManagedThreadId"")]on fields — specifies the cDAC field name (defaults to field name if omitted)ILC discovers annotated types by scanning the system module metadata, following the same pattern as
EagerStaticClassConstructionAttribute.Validation
The provider fails fast on misconfiguration:
Files
CdacTypeAttribute.cs/CdacFieldAttribute.cs— internal attributesThread.NativeAot.cs— annotated with ManagedThread descriptorManagedDataDescriptorNode.cs— emits ContractDescriptor with JSON layoutManagedDataDescriptorProvider.cs— attribute scanning and registrationdatadescriptor.h/.inc— managed sub-descriptor referenceValidation
build.cmd clr.aot+libs -rc release— 0 errors, 0 warnings