Repository navigation
Use sequential blobs for NativeAOT attribute and constant metadata - #136357
Conversation
Encode custom attributes and default values as ECMA-shaped NativeFormat blobs while retaining compressed string/type handles. Simplify NativeAOT parsing and update enum, GUID, and stack-trace consumers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0f7ac0ae-31cc-43ab-925d-b7bf74bff1ad
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Prune unused primitive collections and serializers, remove the unused NotPersisted schema flag, and collapse the sequence comparison helper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1dd7eab4-f8ce-4856-bc24-5f85b04ea804
Encode string values as inline UTF-8 SerStrings instead of metadata handles. Store constant blobs as byte arrays and parse GUID attributes directly without resolving constructor signatures. This change is mostly for size measurement. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f2846059-49b6-42a1-8411-ac728be88865
This reverts commit 141e149.
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
This is now ready for review. RuntimeCustomAttributeData.NativeAot.cs can now share a lot more with CoreCLR but that will be a separate PR. Looks like we also got an extra bit saving in handle type so we can do bit shifts in a more space saving way. Also a separate PR. |
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
🔵 Needs a closer look
The metadata wire-format rewrite spans compiler emission and NativeAOT consumers, and source-only review lacked the end-to-end runtime validation needed to establish compatibility.
No open issues 🎉
What changed in this PR
This PR changes NativeAOT custom attributes and default values to sequential, ECMA-shaped blobs while retaining compressed string and type handles. It updates metadata generation and reflection consumers together.
Changes:
- Replace specialized constant and named-argument records with blob-backed metadata.
- Add sequential blob reading and writing, including relocatable handles.
- Adapt custom-attribute parsing, default values, enum values, GUID lookup, and stack-trace formatting.
| File | Description |
|---|---|
| src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatReader.String.cs | Generalizes length-prefixed byte reading. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeMetadataReader.cs | Exposes byte collections as spans. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeFormatReaderCommonGen.cs | Updates constant codes and handle kinds. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MdBinaryReaderGen.cs | Updates generated readers for the new schema. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MdBinaryReader.cs | Removes obsolete primitive readers. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/WriterGen.cs | Generates blob visitation, comparison, and serialization. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/SchemaDef.cs | Defines blob-backed constants and attributes. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/ReaderGen.cs | Generates blob collection access. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/BlobReader.cs | Adds sequential primitive and handle decoding. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/Internal/Metadata/NativeFormat/Writer/NativeMetadataWriter.cs | Updates diagnostics and removes obsolete comparers. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/Internal/Metadata/NativeFormat/Writer/NativeFormatWriterGen.cs | Updates generated metadata records. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/Internal/Metadata/NativeFormat/Writer/MetadataBlob.cs | Adds blob storage and relocatable references. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/Internal/Metadata/NativeFormat/Writer/MdBinaryWriterGen.cs | Updates generated serialization overloads. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/Internal/Metadata/NativeFormat/Writer/MdBinaryWriter.cs | Removes obsolete primitive writers. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/Internal/Metadata/NativeFormat/Writer/ConstantValues.cs | Removes superseded constant formatting helpers. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.CustomAttribute.cs | Transcodes attribute arguments into sequential blobs. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Constant.cs | Transcodes default constants into typed blobs. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler.MetadataTransform.csproj | Includes blob support files. |
| src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/MethodNameFormatter.cs | Uses typed string-handle collections. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.NativeAot.cs | Uses the new constant handle. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/RuntimeCustomAttributeData.NativeAot.cs | Parses and instantiates attributes from sequential blobs. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeNamedTypeInfo.cs | Reads GUID arguments and enum constants from blobs. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/NativeFormat/DefaultValueParser.cs | Accepts typed constant handles. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/MetadataReaderExtensions.NativeFormat.cs | Decodes constants by type code. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj | Includes the shared blob reader. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/CompatibilitySuppressions.xml | Aligns suppressions with the revised metadata types. |
Review effort: Balanced
Resolve NativeFormat schema conflicts and regenerate sources with UpdateNativeFormatSources.cmd. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 35982d34-c05d-4e6c-894e-d2fc2bbf62a0
Preserve BadImageFormatException for invalid reader metadata and document the mirrored System.Reflection.Metadata definitions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 35982d34-c05d-4e6c-894e-d2fc2bbf62a0
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: bbe5596f-be51-49e6-86ed-e84e6a4008df
Encode custom attributes and default values as ECMA-shaped NativeFormat blobs while retaining compressed string/type handles. Simplify NativeAOT parsing and update enum, GUID, and stack-trace consumers.