Skip to content

Conversation

@stephentoub
Copy link
Member

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.

@ghost ghost assigned stephentoub Feb 9, 2022
@ghost ghost added the area-Meta label Feb 9, 2022
@ghost
Copy link

ghost commented Feb 9, 2022

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

Issue Details

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.

Author: stephentoub
Assignees: stephentoub
Labels:

area-Meta

Milestone: -

@EgorBo
Copy link
Member

EgorBo commented Feb 9, 2022

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.
E.g.

https://sharplab.io/#v2:EYLgtghglgdgNAFxBAzmAPgAQEwEYCwAUJgMwAEOZAwmQN5FmMW4BsFALGQGID2PAFD2AArAKYBjBGR64AhLLjSREqT2zzFQsZOkl5ASgZN6hJmQC+Rc0A==

I check 3 arguments for null here and it emits 3 call throw; ret3. I wonder if we should try to merge calls to "noreturn" same methods. cc @dotnet/jit-contrib - not for performance, just for size (e.g. R2R)

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


@stephentoub
Copy link
Member Author

I wonder if we should add some love to this feature in JIT

Yes? 😄

@MihaZupan
Copy link
Member

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?

SharpLab

@EgorBo
Copy link
Member

EgorBo commented Feb 9, 2022

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?

SharpLab

Yes, but it increases .dll size

@stephentoub
Copy link
Member Author

Would it help if the compiler generated a helper method per argument name instead of passing it as an argument

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.

@MihaZupan
Copy link
Member

I suppose it is called <PrivateImplementationDetails> for a reason 😄

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.

@stephentoub
Copy link
Member Author

@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.

@AndyAyersMS
Copy link
Member

I wonder if we should add some love to this feature in JIT

@EgorBo fgTailMergeThrows does some of what we would need here, but it appears the pattern match needed is quite a bit more involved and may span multiple statements.

private readonly Stream _stream;

internal SyncStream(Stream stream) => _stream = stream ?? throw new ArgumentNullException(nameof(stream));
internal SyncStream(Stream stream!!) => _stream = stream;
Copy link
Member

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.

Copy link
Member Author

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).

@stephentoub
Copy link
Member Author

Thanks for reviewing, @bartonjs!

@stephentoub stephentoub merged commit 1ba0394 into dotnet:main Feb 11, 2022
@stephentoub stephentoub deleted the morenullchecks branch February 11, 2022 01:40
@ghost ghost locked as resolved and limited conversation to collaborators Mar 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants