[NO-REVIEW] Test zero diff for #126947#128523
Closed
hez2010 wants to merge 39 commits into
Closed
Conversation
Co-authored-by: Jakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
…m:hez2010/runtime into shared-gvm-devirt/1-tests-instparamlookup
…ests-instparamlookup
…ests-instparamlookup
…ests-instparamlookup
Contributor
Author
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates CoreCLR JIT/EE devirtualization plumbing to carry an explicit token-lookup context and instantiation-parameter lookup info, and wires the same changes through SuperPMI plus a new regression test scenario.
Changes:
- Replace
CORINFO_DEVIRTUALIZATION_INFOoutputs (exactContext,needsMethodContext,isInstantiatingStub) withtokenLookupContext+instParamLookup. - Refactor JIT devirtualization and GDV paths to use
impTransformDevirtualizedCalland the new lookup/context fields. - Update SuperPMI recording/replay structs and bump the JIT/EE version GUID; add a new JIT test for runtime-lookup + delegate/generic-virtual behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/JIT/Generics/VirtualMethods/generic_virtual_methods.cs | Adds a new regression test and supporting types to exercise runtime lookups/delegate + generic virtual behavior. |
| src/coreclr/vm/jitinterface.cpp | Updates resolveVirtualMethodHelper to populate tokenLookupContext and instParamLookup; fixes a comment typo. |
| src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp | Records/replays the updated devirtualization result shape; minor formatting fixes. |
| src/coreclr/tools/superpmi/superpmi-shared/agnostic.h | Updates the agnostic record for resolveVirtualMethod results with new fields. |
| src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs | Updates managed definitions of CORINFO_DEVIRTUALIZATION_INFO. |
| src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | Updates managed host implementation initialization and result reporting fields. |
| src/coreclr/jit/morph.cpp | Simplifies lookup-tree APIs to no longer require a resolved token parameter. |
| src/coreclr/jit/inline.h | Updates GDV candidate info to carry instantiation-parameter lookup and optional resolved tokens (R2R). |
| src/coreclr/jit/indirectcalltransformer.cpp | Refactors late devirt transformation to use impTransformDevirtualizedCall and new GDV fields. |
| src/coreclr/jit/importercalls.cpp | Refactors devirtualization and GDV candidate setup to use tokenLookupContext + instParamLookup. |
| src/coreclr/jit/compiler.h | Adds DevirtualizedCallInfo + impTransformDevirtualizedCall; updates lookup-tree API signatures. |
| src/coreclr/inc/jiteeversionguid.h | Bumps the JIT/EE interface version GUID due to contract changes. |
| src/coreclr/inc/corinfo.h | Updates native CORINFO_DEVIRTUALIZATION_INFO contract to new fields. |
Comment on lines
+219
to
+221
| Delegate m1 = test2.Foo<List<T>>(); | ||
| Delegate m2 = test2.Foo<List<List<T>>>; | ||
| Assert.Equal(m1, m2); |
Comment on lines
+227
to
+237
| public virtual Delegate Foo<U>() | ||
| { | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(U)); | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(List<U>)); | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(List<List<U>>)); | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(List<List<List<U>>>)); | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(List<List<List<List<U>>>>)); | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(List<List<List<List<List<U>>>>>)); | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(List<List<List<List<List<List<U>>>>>>)); | ||
| return Foo<U>; | ||
| } |
|
|
||
| internal class RuntimeLookupDelegateGenericVirtual | ||
| { | ||
| internal static readonly List<object> s_list = new(); |
Comment on lines
+229
to
+235
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(U)); | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(List<U>)); | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(List<List<U>>)); | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(List<List<List<U>>>)); | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(List<List<List<List<U>>>>)); | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(List<List<List<List<List<U>>>>>)); | ||
| RuntimeLookupDelegateGenericVirtual.s_list.Add(typeof(List<List<List<List<List<List<U>>>>>>)); |
Comment on lines
9406
to
9412
| { | ||
| // For R2R, getCallInfo triggers bookkeeping on the zap | ||
| // side and acquires the actual symbol to call so we need to call it here. | ||
| assert(pDerivedResolvedToken != nullptr); | ||
|
|
||
| // Look up the new call info. | ||
| CORINFO_CALL_INFO derivedCallInfo; |
| info->detail = CORINFO_DEVIRTUALIZATION_DETAIL.CORINFO_DEVIRTUALIZATION_UNKNOWN; | ||
| info->isInstantiatingStub = false; | ||
| info->needsMethodContext = false; | ||
| info->instParamLookup = default(CORINFO_LOOKUP); |
Comment on lines
+976
to
+979
| CORINFO_CONTEXT_HANDLE exactContext = inlineInfo->exactContextHandle; | ||
|
|
||
| Compiler::DevirtualizedCallInfo dcInfo; | ||
| dcInfo.tokenLookupContext = exactContext; |
|
|
||
| m_compiler->impTransformDevirtualizedCall(call, &methodHnd, &derivedMethodAttribs, &dcInfo, block, &context, | ||
| &exactContext COMMA_INDEBUG(inlineInfo->originalMethodHandle)); | ||
| context = exactContext; |
Comment on lines
+9346
to
+9364
| if (derivedSig.hasTypeArg()) | ||
| { | ||
| if (((SIZE_T)dcInfo->tokenLookupContext & CORINFO_CONTEXTFLAGS_MASK) == CORINFO_CONTEXTFLAGS_METHOD) | ||
| { | ||
| CORINFO_METHOD_HANDLE exactMethodHandle = | ||
| (CORINFO_METHOD_HANDLE)((SIZE_T)dcInfo->tokenLookupContext & ~CORINFO_CONTEXTFLAGS_MASK); | ||
|
|
||
| instParam = getLookupTree(dcInfo->pInstParamLookup, GTF_ICON_METHOD_HDL, exactMethodHandle); | ||
| } | ||
| else | ||
| { | ||
| assert(((SIZE_T)dcInfo->tokenLookupContext & CORINFO_CONTEXTFLAGS_MASK) == CORINFO_CONTEXTFLAGS_CLASS); | ||
|
|
||
| CORINFO_CLASS_HANDLE exactClassHandle = | ||
| (CORINFO_CLASS_HANDLE)((SIZE_T)dcInfo->tokenLookupContext & ~CORINFO_CONTEXTFLAGS_MASK); | ||
|
|
||
| instParam = getLookupTree(dcInfo->pInstParamLookup, GTF_ICON_CLASS_HDL, exactClassHandle); | ||
| } | ||
| } |
Open
3 tasks
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.
No description provided.