Skip to content

[NO-REVIEW] Test zero diff for #126947#128523

Closed
hez2010 wants to merge 39 commits into
dotnet:mainfrom
hez2010:test-zero-diff
Closed

[NO-REVIEW] Test zero diff for #126947#128523
hez2010 wants to merge 39 commits into
dotnet:mainfrom
hez2010:test-zero-diff

Conversation

@hez2010
Copy link
Copy Markdown
Contributor

@hez2010 hez2010 commented May 23, 2026

No description provided.

hez2010 and others added 30 commits April 15, 2026 21:21
Co-authored-by: Jakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
…m:hez2010/runtime into shared-gvm-devirt/1-tests-instparamlookup
Copilot AI review requested due to automatic review settings May 23, 2026 15:40
@hez2010
Copy link
Copy Markdown
Contributor Author

hez2010 commented May 23, 2026

@MihuBot

@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 23, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label May 23, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_INFO outputs (exactContext, needsMethodContext, isInstantiatingStub) with tokenLookupContext + instParamLookup.
  • Refactor JIT devirtualization and GDV paths to use impTransformDevirtualizedCall and 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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants