Uh oh!
There was an error while loading. Please reload this page.
Respect IsDynamicCodeSupported in more places in Linq.Expressions - #88539
Conversation
* CanEmitObjectArrayDelegate * CanCreateArbitraryDelegates These properties are all set to `false` when running on NativeAOT, so have them respect RuntimeFeature.IsDynamicCodeSupported. Fixdotnet#81803
…sting in CoreClr's System.Private.CoreLib. Allow System.Linq.Expressions to create an object[] delegate using Ref.Emit even though RuntimeFeature.IsDynamicCodeSupported is set to false (ex. using a feature switch). To enable this, add an internal method in CoreLib that temporarily allows the current thread to skip the RuntimeFeature check and allows DynamicMethod instances to be created. When System.Linq.Expressions needs to generate one of these delegates, it calls the internal method through Reflection and continues to use Ref.Emit to generate the delegate.
ghost
commented
Jul 7, 2023
Tagging subscribers to this area: @cston Issue Details
These properties are all set to However, CanEmitObjectArrayDelegate needs a work around because DynamicDelegateAugments.CreateObjectArrayDelegate does not exist in CoreClr's System.Private.CoreLib. Allow System.Linq.Expressions to create an object[] delegate using Ref.Emit even though RuntimeFeature.IsDynamicCodeSupported is set to false (ex. using a feature switch). To enable this, add an internal method in CoreLib that temporarily allows the current thread to skip the RuntimeFeature check and allows DynamicMethod instances to be created. When System.Linq.Expressions needs to generate one of these delegates, it calls the internal method through Reflection and continues to use Ref.Emit to generate the delegate. Fix #81803
|
Uh oh!
There was an error while loading. Please reload this page.
eerhardt
commented
Jul 10, 2023
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| { | ||
| // This can be flipped to true using feature switches at publishing time | ||
| // This can be flipped to false using feature switches at publishing time | ||
| internal static bool CanEmitObjectArrayDelegate => true; |
There was a problem hiding this comment.
Would it make sense to change this into
internalstaticboolCanEmitObjectArrayDelegate=> RuntimeFeature.CanEmitObjectArrayDelegate;If it remains a constant value it will still cause issues for iOS-like platforms as described in: #87924
My last comment: #87924 (comment) breaks down the benefits of having these conditional variables as feature switches.
There was a problem hiding this comment.
I think that would be a good enhancement to make in a future PR. It isn't necessary to fix the issue this PR is fixing - #81803.
eerhardt
commented
Jul 10, 2023
Frozen collection test failures in NativeAOT builds are #88628. |
Uh oh!
There was an error while loading. Please reload this page.
eerhardt
commented
Jul 11, 2023
Failure is #88582. |
These properties are all set to
falsewhen running on NativeAOT, so have them respect RuntimeFeature.IsDynamicCodeSupported when not running on NativeAOT.However, CanEmitObjectArrayDelegate needs a work around because DynamicDelegateAugments.CreateObjectArrayDelegate does not exist in CoreClr's System.Private.CoreLib.
Allow System.Linq.Expressions to create an object[] delegate using Ref.Emit even though RuntimeFeature.IsDynamicCodeSupported is set to false (ex. using a feature switch). To enable this, add an internal method in CoreLib that temporarily allows the current thread to skip the RuntimeFeature check and allows DynamicMethod instances to be created. When System.Linq.Expressions needs to generate one of these delegates, it calls the internal method through Reflection and continues to use Ref.Emit to generate the delegate.
Fix#81803