From 85a02431257a77f5131981331a27165a5d253f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Petryka?= Date: Fri, 19 Jul 2024 01:14:25 +0200 Subject: [PATCH] Remove RuntimeHelpers.IsReference from NativeAOT --- .../src/System/Activator.NativeAot.cs | 2 +- .../Runtime/CompilerServices/RuntimeHelpers.NativeAot.cs | 6 ------ .../Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs | 6 +----- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Activator.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Activator.NativeAot.cs index a3b69bf6f52f69..ab710ed580453f 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Activator.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Activator.NativeAot.cs @@ -49,7 +49,7 @@ public static partial class Activator try { // Call the default constructor on the allocated instance. - if (RuntimeHelpers.IsReference()) + if (!typeof(T).IsValueType) { // Grab a pointer to the optimized allocator for the type and call it. IntPtr allocator = AllocatorOf(); diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.NativeAot.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.NativeAot.cs index 532da20332ab3d..6feed376c3f5d7 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.NativeAot.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.NativeAot.cs @@ -181,12 +181,6 @@ public static unsafe bool TryEnsureSufficientExecutionStack() return (t_sufficientStackLimit = limit); } - [Intrinsic] - internal static unsafe bool IsReference() - { - return !MethodTable.Of()->IsValueType; - } - [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static bool IsBitwiseEquatable() diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs index c0318b02959dc0..e8befd719c4fd5 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs @@ -43,11 +43,7 @@ public static MethodIL EmitIL(MethodDesc method) return null; bool result; - if (methodName == "IsReference") - { - result = elementType.IsGCPointer; - } - else if (methodName == "IsBitwiseEquatable") + if (methodName == "IsBitwiseEquatable") { // Ideally we could detect automatically whether a type is trivially equatable // (i.e., its operator == could be implemented via memcmp). But for now we'll