-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[mini] Don't add unbox tramopline on generic DIM calls #58521
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
Conversation
|
Tagging subscribers to this area: Issue DetailsDon't unbox a valuetype Fixes #58394
|
Don't unbox a valuetype `this` if the generic method is a DIM Fixes dotnet#58394
600cabb to
f46f4e6
Compare
f46f4e6 to
e9bd9d4
Compare
| } else if (orig_vtable_slot) { | ||
| if (m_class_is_valuetype (m->klass)) | ||
| if (m_class_is_valuetype (m->klass)) { | ||
| g_assert (!mini_method_is_default_method (m)); |
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 don't you add the same condition as above?
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.
Good question.
I couldn't tell if we could ever end up in this branch with a valuetype klass and a default interface method.
I thought it would be better to add an assertion (because if it does ever happen the failure will be right at this spot) instead of skipping the need_unbox_tramp. If we erroneous add or don't add an unbox trampoline, we will get a crash later when we actually call the underlying managed method and it uses this in some way. That will be a crash in some unrelated managed code and it won't be obvious how to trace it back to this trampoline. With the assert if anyone comes up with a way to violate it the assumptions it will break in the place where we need to fix it.
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.
That's right. The assertion would definitely make debugging easier. But my confusion is that in the future, when someone hit this assertion, I feel the solution would be to skip adding unbox trampoline. Or you think more work would be needed on top of that?
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.
That's right. The assertion would definitely make debugging easier. But my confusion is that in the future, when someone hit this assertion, I feel the solution would be to skip adding unbox trampoline. Or you think more work would be needed on top of that?
I don't know. I can't tell from the code how we end up in this branch with a DIM. I'd need to see an example and I couldn't make one.
And also I can't tell if in that case the right thing would be to add an unbox, or to not add one. To be honest I was hoping one of our existing tests would break on the assert, and then I'd know that things were fine as is.
But nothing broke. So I still don't know whether that case can happen. And what we should do if it does happen.
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.
make sense!
|
We need to backport to release\6.0 once all validation is complete |
|
/backport to release/6.0 |
|
Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1195616255 |
|
/azp run sync-runtime-to-mono |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Don't unbox a valuetype
thisif the generic method is a DIMFixes #58394