Uh oh!
There was an error while loading. Please reload this page.
Stop spilling ldvirtftn - #120866
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors devirtualization handling by renaming a field and removing function pointer spilling for ldvirtftn operations. The change aims to improve performance by avoiding unnecessary temporary storage while preparing for further Generic Virtual Method (GVM) devirtualization improvements.
Key changes:
- Renamed
wasArrayInterfaceDevirttoneedsMethodContextto better reflect its broader purpose - Removed spilling of
ldvirtftnfunction pointers to temporary locals - Added better handling for cloned "this" pointers in virtual function calls
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/jitinterface.cpp | Updated field assignments from wasArrayInterfaceDevirt to needsMethodContext |
| src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp | Updated SuperPMI recording/replay to use the renamed field |
| src/coreclr/tools/superpmi/superpmi-shared/agnostic.h | Renamed struct field from wasArrayInterfaceDevirt to needsMethodContext |
| src/coreclr/jit/importercalls.cpp | Removed function pointer spilling, improved "this" pointer handling, updated field references |
| src/coreclr/jit/compiler.hpp | Fixed comment for helper function |
| src/coreclr/inc/corinfo.h | Updated struct definition and comments to use the new field name |
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.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
ba46914 to
ee4bd19CompareUh oh!
There was an error while loading. Please reload this page.
ee4bd19 to
1c781c1Comparebc516bb to
a2a1d86Comparehez2010
commented
Oct 19, 2025
trigger mihubot since spmi jobs are broken @MihuBot |
It looks like what you're trying to achieve is the devirtualization of indirect calls (GVM specifically), but you seems to be focused on a very specific case where the actual type is created right before the call (judging by your example in #112596 and the fact that you try to avoid spills). I think we should focus on implementing #44610 for PGO first, e.g. usingSystem.Runtime.CompilerServices;for(inti=0;i<200;i++){Test(newMyValueProcessor());Thread.Sleep(16);}[MethodImpl(MethodImplOptions.NoInlining)]staticvoidTest(IProcessorp){p.Process(42);// should devirtualize, but doesn't today.}publicinterfaceIProcessor{voidProcess<T>(Titem);}publicclassMyValueProcessor:IProcessor{publicvoidProcess<T>(Titem){Console.WriteLine(item?.ToString());}}today we give up on instrumenting indirect calls. And then, if you also want to have it divirtualized without the PGO (e.g. NAOT) you can just create fake (speculative) GDVs (which then will be folded once we hit a phase that can see through locals). Instead of just un-spilling the target that might be changed by the args? cc @AndyAyersMS @dotnet/jit-contrib |
Uh oh!
There was an error while loading. Please reload this page.
Test failure is #105124. Other than this CI is passing. |
MichalStrehovsky
commented
Nov 17, 2025
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Uh oh!
There was an error while loading. Please reload this page.
jakobbotsch
commented
Nov 18, 2025
I will take a look at the x86 asserts when I have some time. |
hez2010
commented
Nov 18, 2025
btw I guess we may want to stop spilling the call target for |
jakobbotsch
commented
Nov 18, 2025
I think it will require its own evaluation of diffs and extending the optimization. I would leave it for a separate change. |
jakobbotsch
commented
Nov 26, 2025
/azp run jit-cfg |
|
Azure Pipelines successfully started running 1 pipeline(s). |
jakobbotsch
commented
Nov 26, 2025
cc @dotnet/jit-contrib PTAL @AndyAyersMS@EgorBo This PR stops spilling the target for calls implemented via The problem with removing the spill is code size regressions. Diffs. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
AndyAyersMS
left a comment
There was a problem hiding this comment.
Generally LGTM.
Are we able to CSE or hoist these lookups out of loops?
Uh oh!
There was an error while loading. Please reload this page.
jakobbotsch
commented
Nov 27, 2025
Doesn't look like it. We don't have an entry for |
Uh oh!
There was an error while loading. Please reload this page.
jakobbotsch
commented
Nov 27, 2025
Thanks! |
We first need to stop spilling ldvirtftn before we can take the next step on GVM devirt.
Let's stop spilling them and see what we need to take to handle potential regressions.
Contributes to #112596
Fixes#121711