[cDAC] NAOT Datadescriptor Updates#128034
Conversation
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
There was a problem hiding this comment.
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 NativeAOTSystem.Exceptionfields 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. |
|
|
||
| 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) | ||
|
|
| // 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] |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
These new contract versions should be described in docs\design\datacontracts\....
7eddf35 to
de3a52b
Compare
No description provided.