-
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
Implement 'ConditionalWeakTable<TKey,TValue>.GetOrAdd' APIs #111204
Implement 'ConditionalWeakTable<TKey,TValue>.GetOrAdd' APIs #111204
Conversation
Note regarding the
|
1 similar comment
Note regarding the
|
...libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
Show resolved
Hide resolved
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.
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- src/libraries/System.Runtime/ref/System.Runtime.cs: Evaluated as low risk
...libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
Show resolved
Hide resolved
...libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
Outdated
Show resolved
Hide resolved
...libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
Outdated
Show resolved
Hide resolved
Go over Corelib and maybe other core assemblies and switch them to use the new API where appropriate? There are not that many candidates. |
I've gone over uses I could find of the now hidden methods and replaced them. Particularly happy with how |
...te.CoreLib/src/System/Reflection/Runtime/Dispensers/DispenserThatReusesAsLongAsKeyIsAlive.cs
Outdated
Show resolved
Hide resolved
...nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs
Outdated
Show resolved
Hide resolved
...libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
Outdated
Show resolved
Hide resolved
...libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
Outdated
Show resolved
Hide resolved
...libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs
Outdated
Show resolved
Hide resolved
From rt-sz, after swapping the value typle to a local type (ebbd878):
Saved 2 KB and 4.5 KB. I'll take it 😄 |
Okay that's a lot more savings than I was expecting. Yeah using a different type is worth it. |
Yeah that's quite a bit, and it must all just be extra value tuple cruft that's unnecessarily kept, given that using a custom type still makes you pay for the generic instantiation. Unrelated to this PR, but @MichalStrehovsky this makes me wonder whether perhaps there could be something general that ILC could do in cases like these to minimize the size impact? 🤔 |
I think this is the same thing as here: #111544 (comment) We're using ValueTuple in a signature of a delegate. The compiler considers Invoke method on delegate implicitly reflected on. Reflected on methods need extra data structures for parameter types so that we can invoke them. ValueTuple is therefore a target of reflection/MakeGenericType. |
Wait, I thought we (you) had fixed that already a while back? I remember you made some change and we saw a whole lot of savings in CsWinRT thanks to that. IIRC you said delegate targets would only be considered reflection visible if someone were doing |
The thing I fixed is "do not indiscriminately mark targets of delegates as reflected on" (we were doing that because we didn't know if anyone accessed The thing that is considered reflected on in the case discussed here is the |
...time/tests/System.Runtime.Tests/System/Runtime/CompilerServices/ConditionalWeakTableTests.cs
Outdated
Show resolved
Hide resolved
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.
Thanks
Closes #89002
This PR implements the new APIs for
ConditionalWeakTable<TKey, TValue>
and hides some legacy ones: