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 legacy behavior around non-virtual interface calls #23032

Merged
merged 6 commits into from Mar 7, 2019

Conversation

@MichalStrehovsky
Copy link
Member

MichalStrehovsky commented Mar 5, 2019

For reasons that are not possible to look up in the CLR source history anymore, we treat non-virtual calls to instance interface methods as virtual.

I recently tweaked that behavior to remain backwards compatible with existing code (scoping it down to abstract methods only), but per request from the C# language team, we're going to do a conscious break here. It's likely only obfuscators will be broken.

While doing that, I noticed we don't have a good behavior defined for this situation in general (e.g. calls to abstract non-interface methods would NullRef, assert, and eventually throw a BadImageFormat). So I'm fixing that too to avoid the nullref/assert. I chose to do the throw in getCallInfo because in a way, this check is similar to the other check that getCallInfo is doing on line 5191 (throw for callvirt to a static method). This is subtly different to desktop behavior where we would nullref/assert/throw only when executing the method and not while compiling the callsite. But it's the callsite that has the wrong IL.

Fixes #22407.

@MichalStrehovsky MichalStrehovsky added this to the 3.0 milestone Mar 5, 2019
@MichalStrehovsky MichalStrehovsky added this to TODO in Default Interface Methods via automation Mar 5, 2019
@MichalStrehovsky MichalStrehovsky requested a review from davidwrighton Mar 5, 2019
@MichalStrehovsky MichalStrehovsky moved this from TODO to In Progress in Default Interface Methods Mar 5, 2019
@@ -5415,6 +5409,14 @@ void CEEInfo::getCallInfo(

if (directCall)
{
// Direct calls to abstract methods are not allowed
if (pTargetMD->IsAbstract() &&

This comment has been minimized.

Copy link
@jkotas

jkotas Mar 5, 2019

Member

This will fetch MethodAttrs that is not a free operation. We are fetching the MethodAttrs on all (or almost all) paths with this change, and some of the paths will fetch it more than once. It may be a good idea to fetch it once upfront.

@MichalStrehovsky

This comment has been minimized.

Copy link
Member Author

MichalStrehovsky commented Mar 5, 2019

The test we inherited from the default interface method prototype branch is doing exactly the thing it shouldn't do (rely on the bad behavior) for unexplained reasons.
@jkotas
jkotas approved these changes Mar 6, 2019
@jkotas jkotas merged commit 502de2a into dotnet:master Mar 7, 2019
70 checks passed
70 checks passed
CentOS7.1 x64 Checked Innerloop Build and Test Build finished.
Details
CentOS7.1 x64 Debug Innerloop Build Build finished.
Details
OSX10.12 x64 Checked Innerloop Build and Test Build finished.
Details
Ubuntu arm Cross Checked Innerloop Build and Test Build finished.
Details
Ubuntu arm Cross Checked crossgen_comparison Build and Test Build finished.
Details
Ubuntu arm Cross Checked no_tiered_compilation_innerloop Build and Test Build finished.
Details
Ubuntu arm Cross Release crossgen_comparison Build and Test Build finished.
Details
Ubuntu x64 Checked CoreFX Tests Build finished.
Details
Ubuntu x64 Checked Innerloop Build and Test Build finished.
Details
Ubuntu x64 Checked Innerloop Build and Test (Jit - TieredCompilation=0) Build finished.
Details
Ubuntu x64 Formatting Build finished.
Details
WIP Ready for review
Details
Windows_NT x64 Checked CoreFX Tests Build finished.
Details
Windows_NT x64 Checked Innerloop Build and Test Build finished.
Details
Windows_NT x64 Checked Innerloop Build and Test (Jit - TieredCompilation=0) Build finished.
Details
Windows_NT x64 Formatting Build finished.
Details
Windows_NT x64 Release CoreFX Tests Build finished.
Details
Windows_NT x64 full_opt ryujit CoreCLR Perf Tests Correctness Build finished.
Details
Windows_NT x64 min_opt ryujit CoreCLR Perf Tests Correctness Build finished.
Details
Windows_NT x86 Checked Innerloop Build and Test Build finished.
Details
Windows_NT x86 Checked Innerloop Build and Test (Jit - TieredCompilation=0) Build finished.
Details
Windows_NT x86 Release Innerloop Build and Test Build finished.
Details
Windows_NT x86 full_opt ryujit CoreCLR Perf Tests Correctness Build finished.
Details
Windows_NT x86 min_opt ryujit CoreCLR Perf Tests Correctness Build finished.
Details
coreclr-ci Build #20190306.76 succeeded
Details
coreclr-ci (Build Linux arm checked) Build Linux arm checked succeeded
Details
coreclr-ci (Build Linux arm debug) Build Linux arm debug succeeded
Details
coreclr-ci (Build Linux arm release) Build Linux arm release succeeded
Details
coreclr-ci (Build Linux arm64 checked) Build Linux arm64 checked succeeded
Details
coreclr-ci (Build Linux arm64 debug) Build Linux arm64 debug succeeded
Details
coreclr-ci (Build Linux arm64 release) Build Linux arm64 release succeeded
Details
coreclr-ci (Build Linux_musl arm64 checked) Build Linux_musl arm64 checked succeeded
Details
coreclr-ci (Build Linux_musl arm64 debug) Build Linux_musl arm64 debug succeeded
Details
coreclr-ci (Build Linux_musl arm64 release) Build Linux_musl arm64 release succeeded
Details
coreclr-ci (Build Linux_musl x64 checked) Build Linux_musl x64 checked succeeded
Details
coreclr-ci (Build Linux_musl x64 debug) Build Linux_musl x64 debug succeeded
Details
coreclr-ci (Build Linux_musl x64 release) Build Linux_musl x64 release succeeded
Details
coreclr-ci (Build Linux_rhel6 x64 checked) Build Linux_rhel6 x64 checked succeeded
Details
coreclr-ci (Build Linux_rhel6 x64 debug) Build Linux_rhel6 x64 debug succeeded
Details
coreclr-ci (Build Linux_rhel6 x64 release) Build Linux_rhel6 x64 release succeeded
Details
coreclr-ci (Build Windows_NT arm Checked) Build Windows_NT arm Checked succeeded
Details
coreclr-ci (Build Windows_NT arm Debug) Build Windows_NT arm Debug succeeded
Details
coreclr-ci (Build Windows_NT arm64 Checked) Build Windows_NT arm64 Checked succeeded
Details
coreclr-ci (Build Windows_NT arm64 Debug) Build Windows_NT arm64 Debug succeeded
Details
coreclr-ci (Build Windows_NT x64 Checked) Build Windows_NT x64 Checked succeeded
Details
coreclr-ci (Build Windows_NT x64 Debug) Build Windows_NT x64 Debug succeeded
Details
coreclr-ci (Build Windows_NT x86 Checked) Build Windows_NT x86 Checked succeeded
Details
coreclr-ci (Build Windows_NT x86 Debug) Build Windows_NT x86 Debug succeeded
Details
coreclr-ci (Test Pri0 Linux x64 checked) Test Pri0 Linux x64 checked succeeded
Details
coreclr-ci (Test Pri0 Linux_musl arm64 checked) Test Pri0 Linux_musl arm64 checked succeeded
Details
coreclr-ci (Test Pri0 OSX x64 checked) Test Pri0 OSX x64 checked succeeded
Details
coreclr-ci (Test Pri0 Windows_NT arm checked) Test Pri0 Windows_NT arm checked succeeded
Details
coreclr-ci (Test Pri0 Windows_NT arm64 checked) Test Pri0 Windows_NT arm64 checked succeeded
Details
coreclr-ci (Test Pri0 Windows_NT x64 checked) Test Pri0 Windows_NT x64 checked succeeded
Details
coreclr-ci (Test Pri0 Windows_NT x86 checked) Test Pri0 Windows_NT x86 checked succeeded
Details
coreclr-ci (Test pri0 Linux arm checked) Test pri0 Linux arm checked succeeded
Details
coreclr-ci (Test pri0 Linux arm64 checked) Test pri0 Linux arm64 checked succeeded
Details
coreclr-ci (Test pri0 Linux_musl x64 checked) Test pri0 Linux_musl x64 checked succeeded
Details
coreclr-ci (Test pri0 Linux_rhel6 x64 checked) Test pri0 Linux_rhel6 x64 checked succeeded
Details
coreclr-ci (build Linux x64 Checked) build Linux x64 Checked succeeded
Details
coreclr-ci (build Linux x64 Debug) build Linux x64 Debug succeeded
Details
coreclr-ci (build Linux x64 Release) build Linux x64 Release succeeded
Details
coreclr-ci (build OSX x64 Checked) build OSX x64 Checked succeeded
Details
coreclr-ci (build OSX x64 Debug) build OSX x64 Debug succeeded
Details
coreclr-ci (build OSX x64 Release) build OSX x64 Release succeeded
Details
coreclr-ci (build Windows_NT arm Release) build Windows_NT arm Release succeeded
Details
coreclr-ci (build Windows_NT arm64 Release) build Windows_NT arm64 Release succeeded
Details
coreclr-ci (build Windows_NT x64 Release) build Windows_NT x64 Release succeeded
Details
coreclr-ci (build Windows_NT x86 Release) build Windows_NT x86 Release succeeded
Details
license/cla All CLA requirements met.
Details
Default Interface Methods automation moved this from In Progress to Done Mar 7, 2019
@MichalStrehovsky MichalStrehovsky deleted the MichalStrehovsky:abstractCall branch Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.