-
Notifications
You must be signed in to change notification settings - Fork 5.2k
JIT: work around issues invoking the unboxed entry when prejitting #52605
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
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.
Why not abort this in resolveVirtualMethod on the crossgen2? We could limit this to the cases when the devirtualized method body is shared. Do we want to give up on this optimizations for nongeneric valuetypes or unshared generic valuetypes?
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.
The fix would be something along the lines of adding
to the "if (impl.OwningType.IsValueType)" block in resolveVirtualMethod.
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.
I'm hoping whatever fix we take here is perhaps temporary.
So far the devirtualization hasn't lead to bad codegen -- just the follow-on attempt to update the call site to invoke the unboxed entry.
I suppose you could argue that we're lucky and the (nominal) unshared unboxing method and the shared unboxing method are really the same method and neither can be inlined, so currently nothing bad comes of confusing the two.
The runtime and crossgen1 should allow devirtualization here too. But currently that implementation of
resolveVirtualMethodis blocked because we present it with a mixture of an exact implementation type and a shared interface method (and hence type) and this leads the runtime to deduce that the exact type does not implement the interface.I find it fairly tricky to reason about correct behavior in these mixed shared/exact cases. We will see more and more of this as via PGO the jit is able to get a hold of exact types in many places where it would not have been possible before.
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.
I just meant that if we happen to ship with this for .NET 6, it would be unfortunate to disable all of this if it works only because it doesn't work for KeyValuePair (there are very few other popular generic structs).
#51982 is an example of a devirtualization problem with shared code (this one affects all of the: VM, crossgen and crossgen2). There are various weird corner cases like this that we probably don't have tests for.
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.
Evidently this is not the case -- looking at #51982 and #51983 it looks like the problems are more widespread.