Skip to content

Remove unnecessary runtime lookup for constrained callvirt - #73823

Merged
trylek merged 1 commit into
dotnet:mainfrom
trylek:SVMRuntimeLookupFix
Aug 24, 2022
Merged

Remove unnecessary runtime lookup for constrained callvirt#73823
trylek merged 1 commit into
dotnet:mainfrom
trylek:SVMRuntimeLookupFix

Conversation

@trylek

Copy link
Copy Markdown
Member

In my change adding support for default static virtual interface
method implementations I made a subtle bug that caused
behavioral change for some pre-existing constrained virtual calls
that newly started to require runtime lookup. This is unnecessary
and perf-negative, I have modified the code so that my change
kicks in only for static virtual methods.

Thanks

Tomas

/cc @dotnet/jit-contrib

@trylek

Copy link
Copy Markdown
MemberAuthor

Fixes: #73681

@trylek

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-coreclr outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jakobbotschjakobbotsch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. I've verified this returns the behavior of the example in #73606 back to what it was previously.

@jkotas

Copy link
Copy Markdown
Member

Is R2R codegen correct for this case?

@AaronRobinsonMSFTAaronRobinsonMSFT added this to the 7.0.0 milestone Aug 16, 2022
@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

@trylek Do we also need to update R2R as mentioned at #73823 (comment)?

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

Perhaps in this area?

//
// Initialize callee context used for inlining and instantiation arguments
//
targetMethod = methodAfterConstraintResolution;
if(targetMethod.HasInstantiation)
{
pResult->contextHandle = contextFromMethod(targetMethod);
pResult->exactContextNeedsRuntimeLookup = targetMethod.IsSharedByGenericInstantiations;
}
else
{
pResult->contextHandle = contextFromType(exactType);
pResult->exactContextNeedsRuntimeLookup = exactType.IsCanonicalSubtype(CanonicalFormKind.Any);

@markplesmarkples left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm for jitinterface logic (not familiar with r2r aspect)

@mangod9

Copy link
Copy Markdown
Member

@trylek is this good to merge. Appears that needs to be ported to 7 too?

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member

@trylek is this good to merge. Appears that needs to be ported to 7 too?

We still need a response to the R2R query. I think that @jkotas is correct in that more needs to be updated.

@trylek

Copy link
Copy Markdown
MemberAuthor

I'm doing my best to produce an update this afternoon.

In my change adding support for default static virtual interface
method implementations I made a subtle bug that caused
behavioral change for some pre-existing constrained virtual calls
that newly started to require runtime lookup. This is unnecessary
and perf-negative, I have modified the code so that my change
kicks in only for static virtual methods.
Thanks
Tomas
@trylek
trylekforce-pushed the SVMRuntimeLookupFix branch from d1d25ea to ad29661CompareAugust 23, 2022 18:32
@trylek

Copy link
Copy Markdown
MemberAuthor

I have finally gotten to debugging the jitted and crossgenned version of the test described in the issue #73606. To answer @jkotas' question, I believe there's no counterpart logic in Crossgen2 as Crossgen2 still globally skips functions containing static virtual method calls using the following conditional statement:

if((flags & CORINFO_CALLINFO_FLAGS.CORINFO_CALLINFO_CALLVIRT)==0&& pConstrainedResolvedToken !=null)

The fix presented in this PR basically just scales back my getCallInfo change to only apply to SVMs, not normal constrained callvirt; as there's no equivalent logic in the Crossgen2 version of getCallInfo, I don't think there is anything to change. I have rebased the change against the latest main and I'm rerunning tests, at this point I'm not aware of any remaining blocking issues.

@trylek

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-coreclr outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@trylek
trylek merged commit 24d185e into dotnet:mainAug 24, 2022
@trylek
trylek deleted the SVMRuntimeLookupFix branch August 24, 2022 20:57
@trylek

Copy link
Copy Markdown
MemberAuthor

/backport to release/7.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/2922253202

@ghostghost locked as resolved and limited conversation to collaborators Sep 24, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@trylek@jkotas@AaronRobinsonMSFT@mangod9@jakobbotsch@davidwrighton@markples