-
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
[NativeAOT] Fix Activator.CreateInstance for shared generic structs #101021
Conversation
The default constructor has to be invoked using fat pointer in shared generic structs.
6767b01
to
e49c6c3
Compare
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Activator.NativeAot.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Runtime.Tests/TestStructs/System.TestStructs.il
Show resolved
Hide resolved
/azp run runtime-nativeaot-outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
cc @AaronRobinsonMSFT Bug that I have noticed as I was replying to your email |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/TypeLoaderExports.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/TypeLoaderExports.cs
Outdated
Show resolved
Hide resolved
…e/TypeLoaderExports.cs
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! I wanted to ask by how much this makes things slower, but optimizing the "no default ctor" case can be a separate thing. I think I can add a RuntimeHelpers.MightHaveDefaultConstructor<T>
that can be used to avoid this extra work (and more) in the 99% common case.
This should be taken care of by runtime/src/coreclr/tools/Common/TypeSystem/IL/NativeAotILProvider.cs Lines 114 to 130 in fa1164c
|
Keep forgetting how this works. I guess the throw on line 46 might be unreachable for value types then? |
It may be reachable for value types with private default constructor. |
…otnet#101021) The default constructor has to be invoked using fat pointer in shared generic structs.
…otnet#101021) The default constructor has to be invoked using fat pointer in shared generic structs.
The default constructor has to be invoked using fat pointer in shared generic structs.