-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Optimize equality operators #98196
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
Optimize equality operators #98196
Conversation
|
Some comments " |
src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs
Outdated
Show resolved
Hide resolved
| // Test d2 first to allow branch elimination when inlined for not null checks (!= null) | ||
| // so it can become a simple test |
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.
These comments aren't really "correct" anymore
We should likely ensure that the same general codegen and dead code elimination still happens when inlined (for RyuJIT and Mono).
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.
We should likely ensure that the same general codegen and dead code elimination still happens
+1. The MihuBot report has number of regressions. The regressions seem to be caused by dead code elimination no longer happening - a lot of new System.Object:Equals calls that did not exist 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.
The list of regressions seems to be a good data point about methods that use == null / != null, but that should better be using is null / is not null instead.
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 list of regressions seems to be a good data point about methods that use == null / != null, but that should better be using is null / is not null instead.
Are you interested in a submitting PR that fixes these? (Just in the shipping libraries, tests can and should stay as is.)
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.
use
== null/!= null, but that should better be usingis null/is not nullinstead.
Are custom .Equals implementations that might return true with a single null (like for example with Unity) not a concern here?
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.
We can look at it case-by-case. Most of the affected operator implementations check for the null upfront and won't call Equals with null.
Do you have an example of where it may be a problem?
|
Tagging subscribers to this area: @dotnet/area-system-runtime Issue DetailsAs requested in #97959 (comment) cc @jkotas
|
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
As requested in #97959 (comment)
cc @jkotas