JIT: Add guarded devirtualization support for generic virtual methods - #132361
Open
hez2010 wants to merge 4 commits into
Open
JIT: Add guarded devirtualization support for generic virtual methods#132361hez2010 wants to merge 4 commits into
hez2010 wants to merge 4 commits into
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
14 tasks
This was referenced Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add guarded devirtualization support for generic virtual methods. And avoid splitting
CORINFO_HELP_VIRTUAL_FUNC_PTRwhen creating the check so that we only perform the lookup on the fallback path.This approach profiles both the class and the method (instantiation) for GVMs, where method profiling is necessary for shared generic virtual methods GDV because we can have different instantiations through a single shared call site. Then while creating the GDV check, check both the class and instantiation.
For simplicity, this profiles independent class and method histograms. But this can lose the correlation between the two values. For example, suppose a call site observes only these combinations:
AwithI.M<C1>: 50%BwithI.M<C2>: 50%The resulting profiles are:
A, 50%BI.M<C1>, 50%I.M<C2>Nothing prevents the JIT from choosing
AandI.M<C2>for the GDV check, which will never succeed and will result in a fast path that is never going to be hit.Ideally, we should profile a correlated pair of
<class handle, method handle>instead of profiling them separately, but we don't have the infra today. This won't be a problem for non-shared GVMs though.Example:
Codegen for
Testnow:Contributes to #112596
cc: @dotnet/jit-contrib