Repository navigation
Flatten NativeAOT reflection metadata namespaces - #135847
MichalStrehovsky merged 6 commits into
Conversation
Replace namespace trees with shared full-name records and scope-level type and forwarder lists. Regenerate metadata readers and writers, migrate NativeAOT consumers, and remove NamespaceChain. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 070f14d8-a6c1-4b56-b431-ee470872268a
Reuse decoded scope records and immutable assembly identities through the existing per-scope dispenser. Cache named-type namespace handles to avoid repeated enclosing-type walks while preserving canonical assembly rebinding. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 070f14d8-a6c1-4b56-b431-ee470872268a
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 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 |
|
3c2faff is one of the reasons why I don't like native AOT metadata format being variable-length - the ScopeDefinition constructor now needs to decode the handle list of all TypeDefinitions in the assembly even if we only need to know name or flags because of how this metadata is constructed and the impossibility of indexing into a record. |
This reverts commit 3c2faff. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 070f14d8-a6c1-4b56-b431-ee470872268a
Move top-level type definitions and forwarders behind a TypeDefinitionGroup handle so scalar scope reads do not traverse these collections. Regenerate metadata readers and writers and update transform and reflection consumers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 070f14d8-a6c1-4b56-b431-ee470872268a
Store top-level type definitions and forwarders in schema-generated native hashtables using version-resilient UTF-8 name hashes. Keep nested collections linear and remove the redundant TypeDefinitionGroup indirection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b001f6bf-f70d-4bbf-868c-7d12aec8f113
|
/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-format migration needs human review, NativeAOT validation, measurements, and resolution of the forwarder regression.
1 open issue
What changed in this PR
Flattens NativeAOT reflection namespaces into full names and scope references, replacing namespace-tree traversal with assembly-level type tables.
Changes:
- Adds generated hash tables for type definitions and forwarders.
- Updates metadata producers, reflection lookup, and name formatting.
- Adds character-span hashing and removes namespace-chain infrastructure.
Builds, tests, and measurements were not run.
| File | Description |
|---|---|
| src/libraries/Common/src/Internal/VersionResilientHashCode.cs | Adds character-span name hashing. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/NativeFormatReaderGen.cs | Updates generated records and hash-table readers. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MetadataTypeHashingAlgorithms.cs | Hashes flattened namespace names. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/MdBinaryReaderGen.cs | Reads hash-table references. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/WriterGen.cs | Generates hash-table placement and serialization. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/SchemaDef.cs | Defines flattened namespaces and scope tables. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/ReaderGen.cs | Generates typed hash-table enumerators. |
| src/coreclr/tools/Common/Internal/Metadata/NativeFormat/Generator/MdBinaryReaderGen.cs | Generates hash-table decoding. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/Internal/Metadata/NativeFormat/Writer/NativeMetadataWriter.cs | Places tables and computes lookup hashes. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/Internal/Metadata/NativeFormat/Writer/NativeFormatWriterGen.cs | Updates generated metadata writers. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.TypeForwarders.cs | Associates forwarders with destination namespaces. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Type.cs | Registers top-level types on scopes. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler/Metadata/Transform.Namespace.cs | Creates flattened namespace records. |
| src/coreclr/tools/aot/ILCompiler.MetadataTransform/ILCompiler.MetadataTransform.csproj | Includes shared hashing code. |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs | Changes unresolved-forwarder retention. |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/AnalysisBasedMetadataManager.cs | Changes analysis-based forwarder retention. |
| src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/MetadataNameExtensions.cs | Reads direct namespace names and scopes. |
| src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/StackTraceMetadata.cs | Updates attribute matching and scope access. |
| src/coreclr/nativeaot/System.Private.StackTraceMetadata/src/Internal/StackTraceMetadata/MethodNameFormatter.cs | Formats flattened namespace names. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/TypeInfos/NativeFormat/NativeFormatRuntimeNamedTypeInfo.cs | Uses direct scopes and caches namespace strings. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/TypeResolver.NativeFormat.cs | Resolves namespace scopes directly. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/NamespaceChain.cs | Removes namespace-chain caching. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/MetadataReaderExtensions.NativeFormat.cs | Simplifies namespace helpers and table enumeration. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Assemblies/NativeFormat/NativeFormatRuntimeAssembly.GetTypeCore.CaseSensitive.cs | Uses hashed type lookup. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Assemblies/NativeFormat/NativeFormatRuntimeAssembly.GetTypeCore.CaseInsensitive.cs | Builds lookup dictionaries from scope tables. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/Assemblies/NativeFormat/NativeFormatRuntimeAssembly.cs | Enumerates types and forwarders from scopes. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj | Updates shared-source inclusion. |
| src/coreclr/nativeaot/System.Private.CoreLib/src/CompatibilitySuppressions.xml | Aligns suppressions with generated types. |
Review effort: Balanced
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 71dd5c69-d5b1-4974-89c6-79d586102144

.separate part, store as entire string.