-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[mono] Skip exact interface matches when an interface has variance #103757
Conversation
Don't dereference random memory if get_virtual_method fails in interp
…kes two-pass hard Try to match the spec more closely by doing two passes per class
// Is any interface at this level of the type hierarchy variantly compatible with the desired interface? | ||
// If so, select the first compatible one we find. | ||
for (i = 0; i < vst_count; i++) { | ||
if (!mono_class_is_variant_compatible (itf, vst [i], FALSE)) |
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.
Question: how is this variance search table different from the interfaces_packed
table? Do we really need both? if the variance search table is more correct, can we get rid of the interfaces_packed table?
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 variance search table should be smaller. I can try to figure out whether we can get rid of interfaces_packed
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.
Two examples of what I was thinking in action:
System.IBinaryFloatParseAndFormatInfo`1 vst_size=1 io_count=39
System.Single vst_size=1 io_count=40
Don't build search tables for interfaces
Issue #103365 appears to be caused by us preferring an 'exact match' for interfaces even when variance means an inexact match may be what we should actually use, because the exact match is on a base class and the inexact one is on a derived class.
This PR changes mono's variance interface lookup to more closely match the spec, by doing two scans per class and walking up the class hierarchy. To reduce the performance cost of this more complex scan, a new 'variance search table' is maintained (created on demand) for each type, which only contains generically variant interfaces so that we're not checking against all interfaces.
I also noticed our list of interfaces implemented by Array was incomplete, so this PR updates it.