-
Notifications
You must be signed in to change notification settings - Fork 107
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
Remove LINQ expression dependencies on NativeAOT #1429
Remove LINQ expression dependencies on NativeAOT #1429
Conversation
Seems like we are missing some types in
|
I just copied those from what was being registered in |
|
033cff4
to
6073923
Compare
e175069
to
71bb101
Compare
1df5c4b
to
19964df
Compare
d25239f
to
4fa67b3
Compare
Can confirm that this fully removes the IL3050 warning from LINQ expressions when publishing! 🎉 Removing the assembly entirely is handled by #1435. |
87d21e4
to
5f5ee04
Compare
Worth noting, this also saves ~128 KB! |
|
||
internal static unsafe Delegate GetValueDelegateForAbi() | ||
{ | ||
if (typeof(T) == typeof(int) || |
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.
So because of this, I feel like most of the types listed here won't come to this code path. Do you think having some specific nullable optimizations for each type is better or do you think have a generic version that handles all here is better? The main difference I see is with the former, we can list them as UnManagedCallersOnly
whereas here we would need to do GetfunctionPointerForDelegate
. Or should we keep both as is, and have this as a fallback in case that code path wasn't used?
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.
Oh, that's interesting, I didn't notice that. To clarify, all changes in this PR were solely driven by trying to fix all AOT warnings and allow all of that LINQ expression code to be trimmed out, basically I did the minimum amount of changes to satisfy that. I'm still seeing generic instantiations for all of these types, for instance:
So I'm inclined to say keeping both code paths can't hurt, and it might still help with trimming since it would make those generic instantiations get the specialized paths (even though we're not 100% sure they're actually executed at runtime). I would say perhaps let's just keep this for now and then we can potentially look into removing code once we've double checked that it is never in fact used anywhere, and also that it doesn't regress trimming? 🤔
What do you think?
"Do you think having some specific nullable optimizations for each type is better or do you think have a generic version that handles all here is better?"
Mmh good question. I can't say I have an exact answer here. It also depends on whether we'll be able to fully eliminate all other generic instantiations. If not, I wonder whether the additional code size and complexity is worth it. In theory there shouldn't be much overhead from just that single proxy delegate. But this is also something we could always revisit later, not a big deal I think either way.
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.
Sounds good, we can keep both for now.
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.
Note that in your sceenshot, that is all BoxedIReferenceArrayImpl which is different from BoxedIReferenceImpl
. I know we have worked to do with arrays possibly.
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.
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.
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.
For the first set, those come from here. I wasn't sure if I wanted to create specializations for each one so I had created a BoxedValueIreferenceImpl that takes both the type and the ABI type as generics so it was AOT compatible and had implemented it that way. With your changes, there might be opportunity in a future PR to make it again use the one generic one if that is better.
This PR attempts to fix the IL3050 warnings in CsWinRT due to System.Linq.Expressions being pulled in. The goal is to just remove that dependency entirely when on NativeAOT, and allow the linker to correctly trim all of that code, which should also improve the binary size a bit more. There were a few issues preventing this from happening:
RuntimeFeature
) were using unsupported patterns (see here)Nullable<T>
)This PR fixes both of those issues for all occurrences.