[experiment] check generic ctx in gtGetClassHandle#129434
Closed
EgorBo wants to merge 1 commit into
Closed
Conversation
Recover the exact return type of a non-inlined shared generic call from its instantiation parameter, so the result can be exactly devirtualized. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
Just a CI test for an alternative fix #129373 tries to make. |
Member
Author
|
@MihuBot -nuget -jitutils-repo EgorBo/jitutils -jitutils-branch pmi-deterministic-cctors |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts CoreCLR JIT’s Compiler::gtGetClassHandle handling of GT_CALL nodes (specifically CT_USER_FUNC) to attempt to recover a more precise instantiated return type for shared generic calls by using the call’s WellKnownArg::InstParam, similar in spirit to the existing inline-candidate sharpening.
Changes:
- Remove outdated comment implying exact generic context is always unavailable for
CT_USER_FUNCcalls. - When the return type from
eeGetMethodSigis a shared instantiation (e.g.,__Canon), attempt to re-query the signature in the exact context derived fromWellKnownArg::InstParamand use the refined return type when it is no longer shared.
Comment on lines
+20893
to
+20895
| // Static method on a generic type (or array method): the | ||
| // generic context is the exact owner class. | ||
| CORINFO_CLASS_HANDLE exactOwner = gtGetHelperArgClassHandle(instParam->GetNode()); |
This was referenced Jun 16, 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.
Experiment: in gtGetClassHandle's
CT_USER_FUNCbranch, recover the exact return type of a non-inlined shared generic call from its instantiation parameter (WellKnownArg::InstParam), mirroring the sharpening already done for inline candidates. This lets a subsequent virtual call on the result devirtualize exactly (e.g.NoInline(new Foo()).ToString()folds without a GDV guard) instead of seeingSystem.__Canon.Note
This PR was created with assistance from GitHub Copilot.