Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Set resolvedCallvirt if virtual method can be resolved at compile time - #1099

Merged
MichalStrehovsky merged 1 commit into
dotnet:masterfrom
MichalStrehovsky:ldvirtftnNonvirtual
Apr 8, 2016
Merged

MichalStrehovsky merged 1 commit into
dotnet:masterfrom
MichalStrehovsky:ldvirtftnNonvirtual

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Found this with CoreCLR tests. The logic that special cases the
delegates expects resolvedCallVirt to be set, but we were never setting
it for this case. This pattern was copied from CoreCLR JitInterface and
it puzzles me as to how it could possibly work there.

We ended up asking for a ReadyToRun helper to resolve the virtual call
even though the method was not virtual.

Found this with CoreCLR tests. The logic that special cases the
delegates expects resolvedCallVirt to be set, but we were never setting
it for this case. This pattern was copied from CoreCLR JitInterface and
it puzzles me as to how it could possibly work there.

We ended up asking for a ReadyToRun helper to resolve the virtual call
even though the method was not virtual.
@nattress

nattress commented Apr 8, 2016

Copy link
Copy Markdown
Contributor

LGTM

{
// Delegate targets are always treated as direct calls here. (It would be nice to clean it up...).
directCall = true;
resolvedCallVirt = !targetMethod.IsVirtual || targetMethod.IsFinal || targetMethod.OwningType.IsSealed();

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.

There is comment above about getting this cleaned up, and the new line is duplicating condition from a couple of lines below.

Would it be better to get rid of this special treatment and move the check for LDFTN to be later when we are actually creating the entrypoint for JIT to use?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I would ideally want to fix this in the exact same way CoreCLR handles this, but I can't find where that happens (they clearly don't set the bool on CoreCLR even though they check for it and expect it to represent the reality).

I think there's value in trying to mirror the CoreCLR implementation and don't diverge too much because this method will get more complicated over time and the CoreCLR JitInterface has a decade of bug fixes in it (and admittedly, a decade of legacy quirks).

I will go with this as a minimally invasive fix to the structure of the method. We can always revisit.

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.

It works in CoreCLR because of it can deal with the virtual call that is not actually one till pretty late and then compensate for it. I do not think it makes sense to do it this way for CoreRT. Also - it make sense to not diverge JIT-EE interface implementation from CoreCLR for no good reason, but I would not write convoluted code to make it match.

This is actually my fault. I have added this hack for delegates when I was refactoring the JIT-EE interface a few years ago but forgot to remove it (TFS changeset 13508).

I have submitted #1106 to cleanup this up.

@MichalStrehovsky
MichalStrehovsky merged commit 99280b0 into dotnet:master Apr 8, 2016
@MichalStrehovsky
MichalStrehovsky deleted the ldvirtftnNonvirtual branch April 8, 2016 21:23
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.

4 participants