Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

Description

The INodeWithSize interface was previously used to track and expose node sizes via a Size property, calculated during data emission. This interface has been completely removed, and all nodes now use IMAGE_REL_SYMBOL_SIZE relocations, allowing the object writer to resolve symbol sizes at link time.

Additionally, the ModuleInfoRow structure has been restructured to store the resolved length directly instead of using flags and end pointers, and the ReadyToRun header now requires alignment before each entry.

Changes

  • ReadyToRunHeaderNode.cs: Removed the INodeWithSize interface definition and all conditional logic. Now always emits IMAGE_REL_SYMBOL_SIZE relocation for all nodes. Removed HasEndPointer flag emission. Added alignment requirement before emitting each entry. Updated EntrySize calculation to reflect new structure (SectionId + Length + Start instead of SectionId + Flags + Start + End).

  • 33 node classes: Removed INodeWithSize interface implementation from all classes (no longer needed as marker interface)

  • ModuleInfoFlags enum: Removed from both managed code (ModuleHeaders.cs) and native code (ModuleHeaders.h)

  • ModuleInfoRow structure: Changed from having SectionId, Flags, Start, and End fields to having SectionId, Length, and Start fields. The length is now resolved at link time via IMAGE_REL_SYMBOL_SIZE relocation and stored directly in the structure.

  • TypeManager.h: Updated ModuleInfoRow structure definition. Removed HasEndPointer() and GetLength() methods - the Length field is now accessed directly.

  • TypeManager.cpp: Updated GetModuleSection to access the Length field directly instead of calling a getter method.

  • ProxyTypeMapObjectNode.cs and ExternalTypeMapObjectNode.cs: Removed Size properties that were previously used to track node sizes, as sizes are now resolved via IMAGE_REL_SYMBOL_SIZE relocations.

Before:

public sealed class MetadataNode : ObjectNode, ISymbolDefinitionNode, INodeWithSize
{
    private int? _size;
    int INodeWithSize.Size => _size.Value;
    
    public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
    {
        byte[] blob = factory.MetadataManager.GetMetadataBlob(factory);
        _size = blob.Length;  // Manual size tracking
        // ...
    }
}

// Usage in ReadyToRunHeaderNode
if (item.Node is INodeWithSize nodeWithSize)
{
    builder.EmitPointerReloc((ISymbolNode)item.Node, nodeWithSize.Size);
}

// ModuleInfoRow structure (native)
struct ModuleInfoRow {
    int32_t SectionId;
    int32_t Flags;
    void* Start;
    void* End;
    
    bool HasEndPointer();
    int GetLength();
};

After:

public sealed class MetadataNode : ObjectNode, ISymbolDefinitionNode
{
    public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
    {
        byte[] blob = factory.MetadataManager.GetMetadataBlob(factory);
        // Size tracking removed - resolved at link time
        // ...
    }
}

// Usage in ReadyToRunHeaderNode - always emits for all nodes
builder.RequireInitialPointerAlignment();
builder.EmitInt((int)item.Id);
builder.EmitReloc((ISymbolNode)item.Node, RelocType.IMAGE_REL_SYMBOL_SIZE);
builder.EmitPointerReloc((ISymbolNode)item.Node);

// ModuleInfoRow structure (native)
struct ModuleInfoRow {
    int32_t SectionId;
    int32_t Length;  // Accessed directly, no getter
    void* Start;
};

The IMAGE_REL_SYMBOL_SIZE relocation type (0x1000) is already used in the ReadyToRun compiler for the same purpose. This change simplifies the code by removing the interface abstraction, eliminating the flags mechanism, removing unnecessary getter methods, and storing resolved sizes directly in the module info structure.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…SIZE reloc

Co-authored-by: jkoritzinsky <1571408+jkoritzinsky@users.noreply.github.com>
@dotnet-policy-service
Copy link
Contributor

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

Co-authored-by: jkoritzinsky <1571408+jkoritzinsky@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove INodeWithSize interface and update size emission Replace INodeWithSize.Size property with IMAGE_REL_SYMBOL_SIZE relocation Feb 9, 2026
Copilot AI requested a review from jkoritzinsky February 9, 2026 22:27
Co-authored-by: jkoritzinsky <1571408+jkoritzinsky@users.noreply.github.com>
Copilot AI changed the title Replace INodeWithSize.Size property with IMAGE_REL_SYMBOL_SIZE relocation Remove INodeWithSize interface and use IMAGE_REL_SYMBOL_SIZE relocation Feb 9, 2026
Copilot AI requested a review from jkoritzinsky February 9, 2026 22:56
@jkoritzinsky
Copy link
Member

@copilot please remove the HasEndPointer flag and the Flags field it goes in. Then, update the native ModuleInfoRow type to have a Start field and a Length field instead of Start and End and remove the Flags type there as well.

Finally, update the code in ReadyToRunHeaderNode to require alignment before emitting each entry.

Co-authored-by: jkoritzinsky <1571408+jkoritzinsky@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 10, 2026

@copilot please remove the HasEndPointer flag and the Flags field it goes in. Then, update the native ModuleInfoRow type to have a Start field and a Length field instead of Start and End and remove th...

Done. Removed HasEndPointer flag and ModuleInfoFlags enum. Updated ModuleInfoRow to have Start and Length fields instead of Start, End, and Flags. Added alignment requirement before emitting each entry. (5b50167)

Copilot AI changed the title Remove INodeWithSize interface and use IMAGE_REL_SYMBOL_SIZE relocation Remove INodeWithSize interface, use IMAGE_REL_SYMBOL_SIZE relocation, and restructure ModuleInfoRow Feb 10, 2026
Copy link
Member

@jkoritzinsky jkoritzinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please address this feedback

Co-authored-by: jkoritzinsky <1571408+jkoritzinsky@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 10, 2026

@copilot please address this feedback

All feedback addressed. (cc44d34)

…otnet/runtime into copilot/remove-inodewithsize-interface
@jkoritzinsky jkoritzinsky marked this pull request as ready for review February 10, 2026 22:14
Copilot AI review requested due to automatic review settings February 10, 2026 22:14
Copy link
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 removes the INodeWithSize mechanism for tracking emitted node sizes and switches NativeAOT module section size reporting to use RelocType.IMAGE_REL_SYMBOL_SIZE, alongside restructuring the NativeAOT ModuleInfoRow ABI to store a resolved Length directly.

Changes:

  • Removed INodeWithSize implementations and per-node manual size tracking (_size/Size properties) across many dependency analysis nodes.
  • Updated ReadyToRunHeaderNode to emit section entries as { SectionId, Length (IMAGE_REL_SYMBOL_SIZE), Start } and adjusted EntrySize accordingly.
  • Updated the NativeAOT runtime to consume the new ModuleInfoRow layout and removed the old flags/end-pointer length computation.

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/TypeMetadataMapNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StructMarshallingStubMapNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StaticsInfoHashtableNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceMethodMappingNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceLineNumbersNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/StackTraceDocumentsNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ResourceIndexNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ResourceDataNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionVirtualInvokeMapNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionInvokeMapNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReflectionFieldMapNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ReadyToRunHeaderNode.cs Emits IMAGE_REL_SYMBOL_SIZE for section lengths; updates EntrySize; removes INodeWithSize definition and old end-pointer logic.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ProxyTypeMapObjectNode.cs Removes INodeWithSize/Size property and assignment.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/PointerTypeMapNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NativeLayoutInfoNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ModuleInitializerListNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/MetadataNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceGenericVirtualMethodTableNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericVirtualMethodTableNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericTypesTemplateMap.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericTypesHashtableNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericMethodsTemplateMap.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/GenericMethodsHashtableNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/FunctionPointerMapNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternalTypeMapObjectNode.cs Removes INodeWithSize/Size property and assignment.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternalReferencesTableNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExactMethodInstantiationsNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DelegateMarshallingStubMapNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DehydratedDataNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ClassConstructorContextMap.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ByRefTypeMapNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfFrozenObjectsNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayOfEmbeddedDataNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ArrayMapNode.cs Removes INodeWithSize and manual _size tracking.
src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs Removes managed ModuleInfoFlags enum.
src/coreclr/tools/Common/Compiler/ObjectWriter/ObjectWriter.cs Always records symbol sizes for offset-0 symbols (enables IMAGE_REL_SYMBOL_SIZE resolution in NativeAOT builds).
src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h Removes native ModuleInfoFlags enum.
src/coreclr/nativeaot/Runtime/TypeManager.h Updates ModuleInfoRow layout to { SectionId, Length, Start }.
src/coreclr/nativeaot/Runtime/TypeManager.cpp Consumes ModuleInfoRow.Length directly; removes old flag/end-pointer length computation.

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants