[NativeAOT] Fix Activator.CreateInstance for shared generic structs#101021
[NativeAOT] Fix Activator.CreateInstance for shared generic structs#101021jkotas merged 3 commits intodotnet:mainfrom
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
MichalStrehovsky
left a comment
There was a problem hiding this comment.
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.