Uh oh!
There was an error while loading. Please reload this page.
Support devirtualizing non-shared GVMs in R2R - #123183
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR enables devirtualization of non-shared Generic Virtual Methods (GVMs) in ReadyToRun (R2R) compilation by recording the compile-time method handle before embedding it into a lookup, allowing it to be used for devirtualization later. Shared GVMs remain unsupported due to lacking a proper generic context.
Changes:
- Added
IsConstructedproperty toInstantiationto determine if all type parameters are concrete types - Removed the early rejection of GVM devirtualization in R2R compilation
- Enhanced devirtualization logic to properly handle generic method instantiations
- Extended JIT's devirtualization candidate detection to support R2R virtual function pointers
- Updated JIT-EE interface version GUID to reflect the API change
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/tools/Common/TypeSystem/Common/Instantiation.cs | Adds IsConstructed property to check if instantiation contains only concrete types (no generic parameters) |
| src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs | Removes CORINFO_DEVIRTUALIZATION_FAILED_GENERIC_VIRTUAL enum value as GVM devirtualization is now supported |
| src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | Removes early rejection check for generic virtual method devirtualization |
| src/coreclr/tools/Common/Compiler/DevirtualizationManager.cs | Enhances logic to instantiate generic methods and adds check to block shared GVMs |
| src/coreclr/jit/importer.cpp | Records compile-time method handle for R2R virtual function pointer helper calls |
| src/coreclr/jit/gentree.h | Adds compileTimeMethodHandle union field and extends IsGenericVirtual to include R2R helper |
| src/coreclr/jit/gentree.cpp | Adds R2R-specific logic to extract method handle for devirtualization candidates |
| src/coreclr/jit/compiler.cpp | Removes error message case for the deleted enum value |
| src/coreclr/inc/jiteeversionguid.h | Updates JIT-EE version identifier GUID for interface change |
| src/coreclr/inc/corinfo.h | Removes CORINFO_DEVIRTUALIZATION_FAILED_GENERIC_VIRTUAL enum value |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
hez2010
commented
Jan 16, 2026
It hit a weird assertion: aren't the two |
It seems that the failure only happens when specifying |
hez2010
commented
Jan 16, 2026
It turns out to be a verification-only issue. We need to use the method definition for comparison during verification instead. |
Tests are passing. Please take a look. @MichalStrehovsky |
MichalStrehovsky
left a comment
There was a problem hiding this comment.
Cc @davidwrighton for the JitInterface.cpp change, Cc @jakobbotsch for the RyuJIT change
Uh oh!
There was an error while loading. Please reload this page.
@MichalStrehovsky |
MichalStrehovsky
left a comment
There was a problem hiding this comment.
The managed parts LGTM, but I can't comment on the JIT part or jitinterface.cpp.
hez2010
commented
Jan 31, 2026
I have renamed the PR as it almost changes nothing to the JIT. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Implement the support for GVM devirtualization in managed type system. It shares the same issue in dotnet#122023 where we are still not able to devirt shared GVMs due to lacking a proper generic context, so let's do the non-shared case first. NativeAOT still not supported yet as it requires some work in the JIT to stop spilling the helper call for fat pointers. Contributes to dotnet#112596 /cc: @MichalStrehovsky@jakobbotsch --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Implement the support for GVM devirtualization in managed type system. It shares the same issue in dotnet#122023 where we are still not able to devirt shared GVMs due to lacking a proper generic context, so let's do the non-shared case first. NativeAOT still not supported yet as it requires some work in the JIT to stop spilling the helper call for fat pointers. Contributes to dotnet#112596 /cc: @MichalStrehovsky@jakobbotsch --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Implement the support for GVM devirtualization in managed type system.
It shares the same issue in #122023 where we are still not able to devirt shared GVMs due to lacking a proper generic context, so let's do the non-shared case first.
NativeAOT still not supported yet as it requires some work in the JIT to stop spilling the helper call for fat pointers.
Contributes to #112596
/cc: @MichalStrehovsky@jakobbotsch