-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Allow devirtualizing more interface calls #82927
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
There is an existing implementation of "does this introduce variance complexities"?
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsThere is an existing implementation of "does this introduce variance complexities"? Cc @dotnet/ilc-contrib
|
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| // no real upper bound on the number of actual classes implementing it | ||
| // due to MakeGenericType. | ||
| if (CanAssumeWholeProgramViewOnInterfaceUse(baseInterface)) | ||
| if (CanAssumeWholeProgramViewOnInterfaceUse(factory, type, baseInterface)) |
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.
Is this condition just a performance optimization that is trying to keep _disqualifiedInterfaces set small? In other words, if we deleted this condition, would anything break?
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.
Yes, I stared at it a bit and it doesn't look necessary. It wasn't a conscious perf optimization because it doesn't seem worth it. Deleted.
| // Interfaces implemented by arrays and array enumerators have weird casting rules | ||
| // due to array covariance (string[] castable to object[], or int[] castable to uint[]). | ||
| // Disqualify such interfaces. | ||
| if (!type.IsCanonicalSubtype(CanonicalFormKind.Any) && |
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.
Is the IsCanonicalSubtype early out correct? Consider:
var a = new int[1];
var b = (X<string>.MyEnum[])(object)a;
Console.WriteLine(b);
class X<T>
{
public enum MyEnum
{
}
}
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.
It was fine for that - we were disqualifying template types above (IsCanonical detects template types).
I moved these two checks together. It looks better.
jkotas
left a comment
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.
LGTM!
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There is an existing implementation of "does this introduce variance complexities"?
Cc @dotnet/ilc-contrib