Skip to content

Conversation

@MichalStrehovsky
Copy link
Member

@MichalStrehovsky MichalStrehovsky commented Jul 25, 2025

Fixes #116032
Contributes to #116301

This adds a third way of referring to MethodTable objects within the compiler:

Unconstructed ("necessary") Metadata (πŸ†•) Constructed
Base type βœ” βœ” βœ”
Interfaces βœ” βœ” βœ”
GCDesc βœ”
VTable βœ”
Reflection metadata βœ” βœ”

With this just having a typeof of something within the compiler no longer materializes the vtable of the thing. This aligns us with how ILLinker thinks of typeof.

The size improvements are not too exciting:

Project Size before Size after Difference
TodosApi-linux 24253880 24188168 -65712
TodosApi-windows 25534976 25496064 -38912
avalonia.app-linux 19464848 18803504 -661344
avalonia.app-windows 20068864 19328000 -740864
hello-linux 1364944 1364944 0
hello-minimal-linux 1086264 1086264 0
hello-minimal-windows 839168 839168 0
hello-windows 1136640 1136640 0
kestrel-minimal-linux 5205720 5197464 -8256
kestrel-minimal-windows 4748800 4743168 -5632
reflection-linux 1964096 1964096 0
reflection-windows 1820672 1820672 0
webapiaot-linux 9694992 9678448 -16544
webapiaot-windows 10263552 10246144 -17408
winrt-component-full-windows 6695936 6674432 -21504
winrt-component-minimal-windows 1705472 1704960 -512

However, it kicks in pretty well for Avalonia because of one type with a big closure that is now unused.

I don't look at this as a size improvement PR, but a warning reduction PR since #116032 hit this when ILC was generating trim warnings that ILLink does not.

Cc @dotnet/ilc-contrib

@MichalStrehovsky MichalStrehovsky added the NO-REVIEW Experimental/testing PR, do NOT review it label Jul 25, 2025
@MichalStrehovsky MichalStrehovsky removed the NO-REVIEW Experimental/testing PR, do NOT review it label Jul 31, 2025
@MichalStrehovsky MichalStrehovsky changed the title Dependency graph expansion experiments Introduce MetadataEEType node halfway between Constructed and Necessary Jul 31, 2025
@MichalStrehovsky MichalStrehovsky marked this pull request as ready for review July 31, 2025 21:00
Copilot AI review requested due to automatic review settings July 31, 2025 21:00
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 introduces a new intermediate "MetadataEEType" node type in the native AOT compilation system, positioned between the existing "Necessary" and "Constructed" EEType levels. This change optimizes the type system by providing metadata-enabled types that don't require full construction overhead for reflection scenarios.

Key changes:

  • Introduces MetadataEETypeNode class and corresponding infrastructure
  • Adds ReadyToRunHelperId.MetadataTypeHandle helper type for generic lookups
  • Updates compilation logic to use the new three-tier type system (Necessary β†’ Metadata β†’ Constructed)

Reviewed Changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
DeadCodeElimination.cs Adds comprehensive test coverage for metadata method table behavior
MetadataEETypeNode.cs New node type implementing metadata-enabled EETypes without full construction
NodeFactory.cs Adds factory methods and caching for metadata type symbols
RyuJitCompilation.cs Updates compilation logic to use three-tier type system
Compilation.cs Modifies helper selection logic to choose appropriate type handle level
Multiple helper nodes Adds support for MetadataTypeHandle in all target architectures
GenericLookupResult.cs Implements metadata type handle generic lookup results
Various other files Updates references and dependencies to use new metadata type symbols

These are not allocated, one can't call `object.GetType` on them.
@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Aug 1, 2025
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky
Copy link
Member Author

@jkoritzinsky is this something you'd be comfortable reviewing? We can also do a Teams call.

@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky
Copy link
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

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

Test changes LGTM, thanks!

@MichalStrehovsky
Copy link
Member Author

/ba-g the arm issue is an infra issue tracked in dnceng repo but doesn't pair

@MichalStrehovsky MichalStrehovsky merged commit 5faa346 into dotnet:main Aug 6, 2025
159 of 165 checks passed
@MichalStrehovsky MichalStrehovsky deleted the sometests branch August 6, 2025 04:24
@github-actions github-actions bot locked and limited conversation to collaborators Sep 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-NativeAOT-coreclr linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ILC considers types as constructed for IsAssignableFrom

6 participants