Repository navigation
Fix devirtualization in crossgen2 - #146
Merged
Merged
Conversation
In some casesi that are only expressible in IL, devirtualization is
choosing a wrong virtual method. This causes a failure of the
JIT\Regression\JitBlue\GitHub_19222 test.
The test uses the following class hierarchy:
class A
{
public virtual void f() {}
}
class B : A
{
public override void f() {}
}
class C : B
{
public new void f() {}
}
class D : C
{
public new void f() {}
}
Then there is a local of type C to which we assign a reference to D.
After that the following virtual call is made:
callvirt instance int32 modopt([mscorlib]System.Runtime.CompilerServices.IsLong) A::f()
Devirtualization will choose C.f to call instead of the D.f.
This change disables devirtualization in such cases. Old crossgen does
the same thing.
davidwrighton
requested changes
Nov 20, 2019
davidwrighton
left a comment
Member
There was a problem hiding this comment.
Please fix to use the slot defining method check instead of IsNewSlot and such. The technique used is incorrect if the impl method is a non-newslot method that overrides a newslot .override of the original decl method.
Member
Author
|
@davidwrighton I've fixed it based on your feedback, can you please take a look again? |
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
In some casesi that are only expressible in IL, devirtualization is
choosing a wrong virtual method. This causes a failure of the
JIT\Regression\JitBlue\GitHub_19222 test.
The test uses the following class hierarchy:
Then there is a local of type C to which we assign a reference to D.
After that the following virtual call is made:
Devirtualization will choose C.f to call instead of the D.f.
This change disables devirtualization in such cases. Old crossgen does
the same thing.