Skip to content

[cDAC] NAOT Datadescriptor Updates#128034

Draft
max-charlamb wants to merge 1 commit into
dotnet:mainfrom
max-charlamb:dev/maxcharlamb/cdac-naot-datadescriptors
Draft

[cDAC] NAOT Datadescriptor Updates#128034
max-charlamb wants to merge 1 commit into
dotnet:mainfrom
max-charlamb:dev/maxcharlamb/cdac-naot-datadescriptors

Conversation

@max-charlamb
Copy link
Copy Markdown
Member

No description provided.

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 extends NativeAOT cDAC (cDAC data descriptor) support by (1) introducing an internal [System.Diagnostics.DataContract] marker attribute that ILC uses to emit managed type layout descriptors, (2) annotating key managed runtime types/fields (e.g., Task, Exception) for inclusion in those descriptors, and (3) expanding the NativeAOT native-side data descriptor to expose additional runtime/loader structures and fix list-head offsets.

Changes:

  • Add System.Diagnostics.DataContractAttribute (internal) and include it in CoreLib shared sources.
  • Annotate System.Threading.Tasks.Task (and selected fields) plus NativeAOT System.Exception fields with [DataContract].
  • Update NativeAOT cDAC native data descriptor/types (RuntimeInstance/TypeManager, new globals/contracts) and correct SList<> head-offset calculations.

Reviewed changes

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

Show a summary per file
File Description
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs Adds [DataContract] annotations to Task and several fields for managed layout emission.
src/libraries/System.Private.CoreLib/src/System/Diagnostics/DataContractAttribute.cs Introduces the internal marker attribute consumed by ILC for managed cDAC descriptors.
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems Includes the new attribute file in shared CoreLib compilation items.
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Exception.NativeAot.cs Annotates NativeAOT Exception fields for managed layout emission.
src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj Removes a now-redundant compile include for DataContractAttribute.cs (now coming via shared projitems).
src/coreclr/nativeaot/Runtime/TypeManager.h Adds cdac_data<TypeManager> offsets to expose selected private layout via cDAC.
src/coreclr/nativeaot/Runtime/threadstore.h Fixes ThreadStore list head offset to point at SList<T>::m_pHead.
src/coreclr/nativeaot/Runtime/RuntimeInstance.h Adds cdac_data<RuntimeInstance> offsets (including SList<> head offsets) for cDAC consumption.
src/coreclr/nativeaot/Runtime/datadescriptor/datadescriptor.inc Expands NativeAOT descriptor with loader-related types/globals/contracts and adds StressLog.ModuleOffset.
src/coreclr/nativeaot/Runtime/datadescriptor/datadescriptor.h Wires in TypeManager and declares g_pTheRuntimeInstance for descriptor globals.

Comment on lines +44 to +64

CDAC_TYPE_BEGIN(RuntimeInstance)
CDAC_TYPE_INDETERMINATE(RuntimeInstance)
CDAC_TYPE_FIELD(RuntimeInstance, T_POINTER, OsModuleList, cdac_data<RuntimeInstance>::OsModuleList)
CDAC_TYPE_FIELD(RuntimeInstance, T_POINTER, TypeManagerList, cdac_data<RuntimeInstance>::TypeManagerList)
CDAC_TYPE_FIELD(RuntimeInstance, T_POINTER, ManagedCodeStartRange, cdac_data<RuntimeInstance>::ManagedCodeStartRange)
CDAC_TYPE_FIELD(RuntimeInstance, T_UINT32, ManagedCodeRangeSize, cdac_data<RuntimeInstance>::ManagedCodeRangeSize)
CDAC_TYPE_END(RuntimeInstance)

CDAC_TYPE_BEGIN(TypeManagerEntry)
CDAC_TYPE_INDETERMINATE(TypeManagerEntry)
CDAC_TYPE_FIELD(TypeManagerEntry, T_POINTER, Next, offsetof(RuntimeInstance::TypeManagerEntry, m_pNext))
CDAC_TYPE_FIELD(TypeManagerEntry, T_POINTER, TypeManager, offsetof(RuntimeInstance::TypeManagerEntry, m_pTypeManager))
CDAC_TYPE_END(TypeManagerEntry)

CDAC_TYPE_BEGIN(OsModuleEntry)
CDAC_TYPE_INDETERMINATE(OsModuleEntry)
CDAC_TYPE_FIELD(OsModuleEntry, T_POINTER, Next, offsetof(RuntimeInstance::OsModuleEntry, m_pNext))
CDAC_TYPE_FIELD(OsModuleEntry, T_POINTER, OsModule, offsetof(RuntimeInstance::OsModuleEntry, m_osModule))
CDAC_TYPE_END(OsModuleEntry)

Comment on lines 196 to 200
// Contracts: declare which contracts this runtime supports
CDAC_GLOBAL_CONTRACT(Thread, n1)
CDAC_GLOBAL_CONTRACT(Exception, c1)
CDAC_GLOBAL_CONTRACT(Exception, n1)
CDAC_GLOBAL_CONTRACT(RuntimeTypeSystem, n1)
CDAC_GLOBAL_CONTRACT(StressLog, c2)

// Can be null, a single continuation, a list of continuations, or s_taskCompletionSentinel,
// in that order. The logic arround this object assumes it will never regress to a previous state.
[DataContract]
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.

I think DumpAsync can depend on symbols in NAOT case.

CDAC_GLOBAL_CONTRACT(Exception, n1)
CDAC_GLOBAL_CONTRACT(RuntimeTypeSystem, n1)
CDAC_GLOBAL_CONTRACT(StressLog, c2)
CDAC_GLOBAL_CONTRACT(Loader, n1)
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.

These new contract versions should be described in docs\design\datacontracts\....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants