Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve generic virtual methods in managed type system #80035

Merged
merged 5 commits into from
Jan 2, 2023

Conversation

MichalStrehovsky
Copy link
Member

@MichalStrehovsky MichalStrehovsky commented Dec 29, 2022

Generic virtual method resolution currently happens on top of RuntimeTypeHandles (i.e. the runtime type system). This works as long as we only need to do generic virtual method resolution on top of types that exist in the runtime.

In order to lay foundation for fixing #77070, we need to be able to resolve not just with types that have a type handle, but also for types that we're in the process of building (e.g. due to MakeGeneric, or due to another generic virtual method dispatch).

This pull request rewrites generic virtual method dispatch to happen on top of the managed type system, instead of the runtime type system. It's a bit more than just a mechanical replacement because the existing algorithm was set up in a confusing way, with ref parameters that were changing what we were resolving and an odd slotChanged logic that I don't fully understand. I replaced the slotChanged with the straightforward thing (if we resolve interface method to a virtual method on a type, find the implementation of the virtual method on the current type). Tests seem to be passing. Also instead of a bunch of ref parameters we now just pass a MethodDesc.

This also includes a compiler change, because in order for the managed type system's casting logic to work, we need to be able to find out the variance of parameters on generic definitions. The compiler change is about generating this info.

Cc @dotnet/ilc-contrib

@MichalStrehovsky MichalStrehovsky added the NO-REVIEW Experimental/testing PR, do NOT review it label Dec 29, 2022
@ghost
Copy link

ghost commented Dec 29, 2022

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

Issue Details

null

Author: MichalStrehovsky
Assignees: -
Labels:

NO-REVIEW, area-NativeAOT-coreclr

Milestone: -

@MichalStrehovsky
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@MichalStrehovsky MichalStrehovsky changed the title WIP: Resolve generic virtual methods in type system Resolve generic virtual methods in type system Dec 30, 2022
@MichalStrehovsky MichalStrehovsky changed the title Resolve generic virtual methods in type system Resolve generic virtual methods in managed type system Dec 30, 2022
@MichalStrehovsky MichalStrehovsky removed the NO-REVIEW Experimental/testing PR, do NOT review it label Dec 30, 2022
@MichalStrehovsky
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

LGTM!

@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 b81b822 into dotnet:main Jan 2, 2023
@MichalStrehovsky MichalStrehovsky deleted the gvmresolvets branch January 2, 2023 07:48
@ghost ghost locked as resolved and limited conversation to collaborators Feb 1, 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.

2 participants