-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Second round of changing null checks to !! #65108
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: @dotnet/area-meta Issue DetailsRound 2, following #64720. This should be most of what remains, with the exception of a few older libraries (e.g. System.Management) I haven't looked at yet.
|
|
Unrelated to this PR, but I wonder if we should add some love to this feature in JIT, because it looks simple and light-weight and users might start [ab]using it a lot just in sake of safety. I check 3 arguments for null here and it emits 3 NOTE: the arguments are different. E.g.: -L0015: mov ecx, 1
-L001a: mov edx, 0x1120c030
-L001f: call 0x71f187c0
-L0024: mov ecx, eax
-L0026: call dword ptr [0x1120c938]
-L002c: int3
-L002d: mov ecx, 7
-L0032: mov edx, 0x1120c030
-L0037: call 0x71f187c0
-L003c: mov ecx, eax
-L003e: call dword ptr [0x1120c938]
-L0044: int3
-L0045: mov ecx, 0xd
-L004a: mov edx, 0x1120c030
-L004f: call 0x71f187c0
-L0054: mov ecx, eax
-L0056: call dword ptr [0x1120c938]
-L005c: int3
+L0015: mov ecx, 1
+ jmp short L004a
+L002d: mov ecx, 7
+ jmp short L004a
+L0045: mov ecx, 0xd
+L004a: mov edx, 0x1120c030
+L004f: call 0x71f187c0
+L0054: mov ecx, eax
+L0056: call dword ptr [0x1120c938]
+L005c: int3
|
5429885 to
62b32bf
Compare
Yes? 😄 |
|
Would it help if the compiler generated a helper method per argument name instead of passing it as an argument? Or at least in cases where the argument name repeated a lot? |
Yes, but it increases .dll size |
Every method adds non-trivial metadata overhead. If we were going to go such a route, I expect we'd prefer the ExceptionArgument route we use manually in some assemblies like Corelib, but we explicitly discussed and decided against that route for the general feature. |
|
I suppose it is called I would expect there is a cut-off at some point where it's a win even for size to special-case e.g. "value" after it repeats 100 times. |
62b32bf to
db4f626
Compare
|
@RikkiGibson, @jaredpar, just FYI... we're getting close to being done with the rollout... after this one I think we're mostly in the weeds. |
@EgorBo |
src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/BinderHelper.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs
Show resolved
Hide resolved
| private readonly Stream _stream; | ||
|
|
||
| internal SyncStream(Stream stream) => _stream = stream ?? throw new ArgumentNullException(nameof(stream)); | ||
| internal SyncStream(Stream stream!!) => _stream = stream; |
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.
source.dot.net claims that there's only one caller of this ctor (lines 722-723) and it is already guaranteeing non-null.
If we wanted, we could probably change this to Debug.Assert.
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.
Makes sense. I'll change that up subsequently (unless I need to restart CI, in which case I'll do it here).
src/libraries/System.Private.DataContractSerialization/src/System/Text/Base64Encoding.cs
Show resolved
Hide resolved
src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBaseReader.cs
Show resolved
Hide resolved
...s/System.Reflection.Metadata/src/System/Reflection/Metadata/Ecma335/Encoding/BlobEncoders.cs
Show resolved
Hide resolved
|
Thanks for reviewing, @bartonjs! |
Round 2, following #64720. This should be most of what remains, with the exception of a few older libraries (e.g. System.Management) I haven't looked at yet.