This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Remove legacy behavior around non-virtual interface calls #23032
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jkotas
reviewed
Mar 5, 2019
src/vm/jitinterface.cpp
Outdated
@@ -5415,6 +5409,14 @@ void CEEInfo::getCallInfo( | |||
|
|||
if (directCall) | |||
{ | |||
// Direct calls to abstract methods are not allowed | |||
if (pTargetMD->IsAbstract() && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Cc @sergiy-k |
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
approved these changes
Mar 6, 2019
MichalStrehovsky
added
the
breaking-change
Issue or PR that represents a breaking API or functional change over a prerelease.
label
May 1, 2019
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
…eclr#23032) * Throw BadImageFormat for direct calls to abstract methods * Remove legacy behavior around non-virtual interface calls * Try fixing failing tests 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. Commit migrated from dotnet/coreclr@502de2a
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
breaking-change
Issue or PR that represents a breaking API or functional change over a prerelease.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thatgetCallInfo
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.