Skip to content

Conversation

@MichalStrehovsky
Copy link
Member

Fixes #77070.

The implementation of static virtuals was limited to compile-time resolution in .NET 7. I erroneously believed runtime resolution can only happen with MakeGenericType/MakeGenericMethod and therefore falls into the general "don't do dynamic code" bucket. But this is also reachable from generic instance virtual method resolution that is also dynamic-like (we don't attempt to precompute all runtime artifacts, only canonical code).

This contains compiler changes to start tracking static virtual method use within type loader templates the same way how we track instance generic virtual method use (i.e. those static virtual uses that happen at compile time are not tracked in this - only the dynamic ones). We also make sure the computed targets get generated into the appropriate table.

The other part of the change is a type loader change to call into the generic virtual method resolution logic when needed.

Cc @dotnet/ilc-contrib

The implementation of static virtuals was limited to compile-time resolution in .NET 7. I erroneously believed runtime resolution can only happen with `MakeGenericType`/`MakeGenericMethod` and therefore falls into the general "don't do dynamic code" bucket. But this is also reachable from generic instance virtual method resolution that is also dynamic-like (we don't attempt to precompute all runtime artifacts, only canonical code).

This contains compiler changes to start tracking static virtual method use within type loader templates the same way how we track instance generic virtual method use (i.e. those static virtual uses that happen at compile time are not tracked in this - only the dynamic ones). We also make sure the computed targets get generated into the appropriate table.

The other part of the change is a type loader change to call into the generic virtual method resolution logic when needed.
@ghost
Copy link

ghost commented Jan 13, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #77070.

The implementation of static virtuals was limited to compile-time resolution in .NET 7. I erroneously believed runtime resolution can only happen with MakeGenericType/MakeGenericMethod and therefore falls into the general "don't do dynamic code" bucket. But this is also reachable from generic instance virtual method resolution that is also dynamic-like (we don't attempt to precompute all runtime artifacts, only canonical code).

This contains compiler changes to start tracking static virtual method use within type loader templates the same way how we track instance generic virtual method use (i.e. those static virtual uses that happen at compile time are not tracked in this - only the dynamic ones). We also make sure the computed targets get generated into the appropriate table.

The other part of the change is a type loader change to call into the generic virtual method resolution logic when needed.

Cc @dotnet/ilc-contrib

Author: MichalStrehovsky
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Nice!

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@MichalStrehovsky
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky MichalStrehovsky merged commit 405565f into dotnet:main Jan 16, 2023
@MichalStrehovsky MichalStrehovsky deleted the fix77070 branch January 16, 2023 23:27
@ghost ghost locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NativeAOT RC2 crash with GVMs on linux-x64

2 participants