Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary runtime lookup for constrained callvirt #73823

Merged
merged 1 commit into from
Aug 24, 2022

Conversation

trylek
Copy link
Member

@trylek trylek commented Aug 11, 2022

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
Member Author

trylek commented Aug 11, 2022

Fixes: #73681

@trylek
Copy link
Member Author

trylek commented Aug 11, 2022

/azp run runtime-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@jakobbotsch jakobbotsch left a comment

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
Member

jkotas commented Aug 12, 2022

Is R2R codegen correct for this case?

@AaronRobinsonMSFT AaronRobinsonMSFT added this to the 7.0.0 milestone Aug 16, 2022
@AaronRobinsonMSFT
Copy link
Member

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

@AaronRobinsonMSFT
Copy link
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);

Copy link
Member

@markples markples left a comment

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
Member

mangod9 commented Aug 22, 2022

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

@AaronRobinsonMSFT
Copy link
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
Member Author

trylek commented Aug 22, 2022

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
Copy link
Member Author

trylek commented Aug 23, 2022

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
Member Author

trylek commented Aug 23, 2022

/azp run runtime-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@trylek trylek merged commit 24d185e into dotnet:main Aug 24, 2022
@trylek trylek deleted the SVMRuntimeLookupFix branch August 24, 2022 20:57
@trylek
Copy link
Member Author

trylek commented Aug 24, 2022

/backport to release/7.0

@github-actions
Copy link
Contributor

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

@ghost ghost locked as resolved and limited conversation to collaborators Sep 24, 2022
Sign up for free to 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