From 1456a38ed9ee3eda8022b9f162a45334723a0d7a Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 18 Jul 2018 03:13:15 -0700 Subject: [PATCH] Delete Span ifdefs that are no longer needed (#18982) --- .../shared/System/Memory.cs | 19 +--- .../shared/System/MemoryExtensions.cs | 15 +-- .../shared/System/ReadOnlyMemory.cs | 19 +--- .../shared/System/ReadOnlySpan.cs | 7 +- .../Runtime/InteropServices/MemoryMarshal.cs | 34 ------ .../shared/System/Span.cs | 7 +- .../shared/System/SpanHelpers.BinarySearch.cs | 2 - .../shared/System/SpanHelpers.Byte.cs | 100 +++++------------- 8 files changed, 33 insertions(+), 170 deletions(-) diff --git a/src/System.Private.CoreLib/shared/System/Memory.cs b/src/System.Private.CoreLib/shared/System/Memory.cs index 0abe3634ae..1a7556720d 100644 --- a/src/System.Private.CoreLib/shared/System/Memory.cs +++ b/src/System.Private.CoreLib/shared/System/Memory.cs @@ -8,9 +8,8 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute; using EditorBrowsableState = System.ComponentModel.EditorBrowsableState; -#if !FEATURE_PORTABLE_SPAN + using Internal.Runtime.CompilerServices; -#endif // FEATURE_PORTABLE_SPAN namespace System { @@ -282,11 +281,7 @@ namespace System // and then cast to a Memory. Such a cast can only be done with unsafe or marshaling code, // in which case that's the dangerous operation performed by the dev, and we're just following // suit here to make it work as best as possible. -#if FEATURE_PORTABLE_SPAN - return new Span(Unsafe.As>(s), MemoryExtensions.StringAdjustment, s.Length).Slice(_index, _length); -#else return new Span(ref Unsafe.As(ref s.GetRawStringData()), s.Length).Slice(_index, _length); -#endif // FEATURE_PORTABLE_SPAN } else if (_object != null) { @@ -345,11 +340,7 @@ namespace System // a readable ReadOnlyMemory or a writable Memory can still be pinned and // used for interop purposes. GCHandle handle = GCHandle.Alloc(s, GCHandleType.Pinned); -#if FEATURE_PORTABLE_SPAN - void* pointer = Unsafe.Add((void*)handle.AddrOfPinnedObject(), _index); -#else void* pointer = Unsafe.Add(Unsafe.AsPointer(ref s.GetRawStringData()), _index); -#endif // FEATURE_PORTABLE_SPAN return new MemoryHandle(pointer, handle); } else if (_object is T[] array) @@ -357,21 +348,13 @@ namespace System // Array is already pre-pinned if (_length < 0) { -#if FEATURE_PORTABLE_SPAN - void* pointer = Unsafe.Add(Unsafe.AsPointer(ref MemoryMarshal.GetReference(array)), _index); -#else void* pointer = Unsafe.Add(Unsafe.AsPointer(ref array.GetRawSzArrayData()), _index); -#endif // FEATURE_PORTABLE_SPAN return new MemoryHandle(pointer); } else { GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned); -#if FEATURE_PORTABLE_SPAN - void* pointer = Unsafe.Add((void*)handle.AddrOfPinnedObject(), _index); -#else void* pointer = Unsafe.Add(Unsafe.AsPointer(ref array.GetRawSzArrayData()), _index); -#endif // FEATURE_PORTABLE_SPAN return new MemoryHandle(pointer, handle); } } diff --git a/src/System.Private.CoreLib/shared/System/MemoryExtensions.cs b/src/System.Private.CoreLib/shared/System/MemoryExtensions.cs index 639bf06e10..739bc3145d 100644 --- a/src/System.Private.CoreLib/shared/System/MemoryExtensions.cs +++ b/src/System.Private.CoreLib/shared/System/MemoryExtensions.cs @@ -6,19 +6,13 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#if !netstandard using Internal.Runtime.CompilerServices; -#endif -#if netstandard -using nuint = System.NUInt; -#else #if BIT64 using nuint = System.UInt64; #else using nuint = System.UInt32; #endif // BIT64 -#endif // netstandard namespace System { @@ -1360,26 +1354,25 @@ namespace System { if (typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte)) { - // The cast to nuint is not redundant on netstandard. Do not remove it. - size = (nuint)sizeof(byte); + size = sizeof(byte); return true; } if (typeof(T) == typeof(char) || typeof(T) == typeof(short) || typeof(T) == typeof(ushort)) { - size = (nuint)sizeof(char); + size = sizeof(char); return true; } if (typeof(T) == typeof(int) || typeof(T) == typeof(uint)) { - size = (nuint)sizeof(int); + size = sizeof(int); return true; } if (typeof(T) == typeof(long) || typeof(T) == typeof(ulong)) { - size = (nuint)sizeof(long); + size = sizeof(long); return true; } diff --git a/src/System.Private.CoreLib/shared/System/ReadOnlyMemory.cs b/src/System.Private.CoreLib/shared/System/ReadOnlyMemory.cs index 78f328a880..02445ec5c6 100644 --- a/src/System.Private.CoreLib/shared/System/ReadOnlyMemory.cs +++ b/src/System.Private.CoreLib/shared/System/ReadOnlyMemory.cs @@ -8,9 +8,8 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute; using EditorBrowsableState = System.ComponentModel.EditorBrowsableState; -#if !FEATURE_PORTABLE_SPAN + using Internal.Runtime.CompilerServices; -#endif // FEATURE_PORTABLE_SPAN namespace System { @@ -199,11 +198,7 @@ namespace System else if (typeof(T) == typeof(char) && _object is string s) { Debug.Assert(_length >= 0); -#if FEATURE_PORTABLE_SPAN - return new ReadOnlySpan(Unsafe.As>(s), MemoryExtensions.StringAdjustment, s.Length).Slice(_index, _length); -#else return new ReadOnlySpan(ref Unsafe.As(ref s.GetRawStringData()), s.Length).Slice(_index, _length); -#endif // FEATURE_PORTABLE_SPAN } else if (_object != null) { @@ -257,11 +252,7 @@ namespace System else if (typeof(T) == typeof(char) && _object is string s) { GCHandle handle = GCHandle.Alloc(s, GCHandleType.Pinned); -#if FEATURE_PORTABLE_SPAN - void* pointer = Unsafe.Add((void*)handle.AddrOfPinnedObject(), _index); -#else void* pointer = Unsafe.Add(Unsafe.AsPointer(ref s.GetRawStringData()), _index); -#endif // FEATURE_PORTABLE_SPAN return new MemoryHandle(pointer, handle); } else if (_object is T[] array) @@ -269,21 +260,13 @@ namespace System // Array is already pre-pinned if (_length < 0) { -#if FEATURE_PORTABLE_SPAN - void* pointer = Unsafe.Add(Unsafe.AsPointer(ref MemoryMarshal.GetReference(array)), _index); -#else void* pointer = Unsafe.Add(Unsafe.AsPointer(ref array.GetRawSzArrayData()), _index); -#endif // FEATURE_PORTABLE_SPAN return new MemoryHandle(pointer); } else { GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned); -#if FEATURE_PORTABLE_SPAN - void* pointer = Unsafe.Add((void*)handle.AddrOfPinnedObject(), _index); -#else void* pointer = Unsafe.Add(Unsafe.AsPointer(ref array.GetRawSzArrayData()), _index); -#endif // FEATURE_PORTABLE_SPAN return new MemoryHandle(pointer, handle); } } diff --git a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs index 52a160dded..61af717836 100644 --- a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs +++ b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs @@ -5,9 +5,8 @@ using System.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; -#if !FEATURE_PORTABLE_SPAN + using System.Runtime.Versioning; -#endif // !FEATURE_PORTABLE_SPAN #pragma warning disable 0809 //warning CS0809: Obsolete member 'Span.Equals(object)' overrides non-obsolete member 'object.Equals(object)' @@ -26,9 +25,7 @@ namespace System /// public int Length { -#if !FEATURE_PORTABLE_SPAN [NonVersionable] -#endif // !FEATURE_PORTABLE_SPAN get { return _length; @@ -40,9 +37,7 @@ namespace System /// public bool IsEmpty { -#if !FEATURE_PORTABLE_SPAN [NonVersionable] -#endif // !FEATURE_PORTABLE_SPAN get { return _length == 0; diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs index 77f497512b..5e33ced6b8 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs @@ -7,9 +7,7 @@ using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Diagnostics; -#if !netstandard using Internal.Runtime.CompilerServices; -#endif namespace System.Runtime.InteropServices { @@ -43,11 +41,7 @@ namespace System.Runtime.InteropServices if ((length & ReadOnlyMemory.RemoveFlagsBitMask) == 0) { -#if FEATURE_PORTABLE_SPAN - segment = new ArraySegment(SpanHelpers.PerTypeValues.EmptyArray); -#else segment = ArraySegment.Empty; -#endif // FEATURE_PORTABLE_SPAN return true; } @@ -147,17 +141,10 @@ namespace System.Runtime.InteropServices public static T Read(ReadOnlySpan source) where T : struct { -#if netstandard - if (SpanHelpers.IsReferenceOrContainsReferences()) - { - ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T)); - } -#else if (RuntimeHelpers.IsReferenceOrContainsReferences()) { ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T)); } -#endif if (Unsafe.SizeOf() > source.Length) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length); @@ -173,17 +160,10 @@ namespace System.Runtime.InteropServices public static bool TryRead(ReadOnlySpan source, out T value) where T : struct { -#if netstandard - if (SpanHelpers.IsReferenceOrContainsReferences()) - { - ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T)); - } -#else if (RuntimeHelpers.IsReferenceOrContainsReferences()) { ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T)); } -#endif if (Unsafe.SizeOf() > (uint)source.Length) { value = default; @@ -200,17 +180,10 @@ namespace System.Runtime.InteropServices public static void Write(Span destination, ref T value) where T : struct { -#if netstandard - if (SpanHelpers.IsReferenceOrContainsReferences()) - { - ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T)); - } -#else if (RuntimeHelpers.IsReferenceOrContainsReferences()) { ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T)); } -#endif if ((uint)Unsafe.SizeOf() > (uint)destination.Length) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length); @@ -226,17 +199,10 @@ namespace System.Runtime.InteropServices public static bool TryWrite(Span destination, ref T value) where T : struct { -#if netstandard - if (SpanHelpers.IsReferenceOrContainsReferences()) - { - ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T)); - } -#else if (RuntimeHelpers.IsReferenceOrContainsReferences()) { ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T)); } -#endif if (Unsafe.SizeOf() > (uint)destination.Length) { return false; diff --git a/src/System.Private.CoreLib/shared/System/Span.cs b/src/System.Private.CoreLib/shared/System/Span.cs index 2bafa1daf8..ddbdba1134 100644 --- a/src/System.Private.CoreLib/shared/System/Span.cs +++ b/src/System.Private.CoreLib/shared/System/Span.cs @@ -5,9 +5,8 @@ using System.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; -#if !FEATURE_PORTABLE_SPAN + using System.Runtime.Versioning; -#endif // !FEATURE_PORTABLE_SPAN #pragma warning disable 0809 //warning CS0809: Obsolete member 'Span.Equals(object)' overrides non-obsolete member 'object.Equals(object)' @@ -26,9 +25,7 @@ namespace System /// public int Length { -#if !FEATURE_PORTABLE_SPAN [NonVersionable] -#endif // !FEATURE_PORTABLE_SPAN get { return _length; @@ -40,9 +37,7 @@ namespace System /// public bool IsEmpty { -#if !FEATURE_PORTABLE_SPAN [NonVersionable] -#endif // !FEATURE_PORTABLE_SPAN get { return _length == 0; diff --git a/src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs b/src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs index 00c491f37f..a81a5d3416 100644 --- a/src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs +++ b/src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs @@ -6,9 +6,7 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#if !netstandard using Internal.Runtime.CompilerServices; -#endif namespace System { diff --git a/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs b/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs index 0c7309b5c5..2890adb568 100644 --- a/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs +++ b/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs @@ -4,24 +4,15 @@ using System.Diagnostics; using System.Runtime.CompilerServices; +using System.Numerics; -#if !netstandard using Internal.Runtime.CompilerServices; -#endif - -#if !netstandard11 -using System.Numerics; -#endif -#if netstandard -using nuint = System.NUInt; -#else #if BIT64 using nuint = System.UInt64; #else using nuint = System.UInt32; #endif // BIT64 -#endif // netstandard namespace System { @@ -112,14 +103,13 @@ namespace System uint uValue = value; // Use uint for comparisons to avoid unnecessary 8->32 extensions IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr nLength = (IntPtr)length; -#if !netstandard11 + if (Vector.IsHardwareAccelerated && length >= Vector.Count * 2) { int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector.Count - 1); nLength = (IntPtr)((Vector.Count - unaligned) & (Vector.Count - 1)); } SequentialScan: -#endif while ((byte*)nLength >= (byte*)8) { nLength -= 8; @@ -169,13 +159,13 @@ namespace System index += 1; } -#if !netstandard11 + if (Vector.IsHardwareAccelerated && ((int)(byte*)index < length)) { nLength = (IntPtr)((length - (int)(byte*)index) & ~(Vector.Count - 1)); // Get comparison Vector - Vector vComparison = GetVector(value); + Vector vComparison = new Vector(value); while ((byte*)nLength > (byte*)index) { @@ -195,7 +185,6 @@ namespace System goto SequentialScan; } } -#endif return -1; Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549 return (int)(byte*)index; @@ -256,14 +245,13 @@ namespace System uint uValue = value; // Use uint for comparisons to avoid unnecessary 8->32 extensions IntPtr index = (IntPtr)length; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr nLength = (IntPtr)length; -#if !netstandard11 + if (Vector.IsHardwareAccelerated && length >= Vector.Count * 2) { int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector.Count - 1); nLength = (IntPtr)(((length & (Vector.Count - 1)) + unaligned) & (Vector.Count - 1)); } SequentialScan: -#endif while ((byte*)nLength >= (byte*)8) { nLength -= 8; @@ -310,13 +298,13 @@ namespace System if (uValue == Unsafe.AddByteOffset(ref searchSpace, index)) goto Found; } -#if !netstandard11 + if (Vector.IsHardwareAccelerated && ((byte*)index > (byte*)0)) { nLength = (IntPtr)((int)(byte*)index & ~(Vector.Count - 1)); // Get comparison Vector - Vector vComparison = GetVector(value); + Vector vComparison = new Vector(value); while ((byte*)nLength > (byte*)(Vector.Count - 1)) { @@ -336,7 +324,6 @@ namespace System goto SequentialScan; } } -#endif return -1; Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549 return (int)(byte*)index; @@ -364,14 +351,13 @@ namespace System uint uValue1 = value1; // Use uint for comparisons to avoid unnecessary 8->32 extensions IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr nLength = (IntPtr)length; -#if !netstandard11 + if (Vector.IsHardwareAccelerated && length >= Vector.Count * 2) { int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector.Count - 1); nLength = (IntPtr)((Vector.Count - unaligned) & (Vector.Count - 1)); } SequentialScan: -#endif uint lookUp; while ((byte*)nLength >= (byte*)8) { @@ -435,14 +421,14 @@ namespace System index += 1; } -#if !netstandard11 + if (Vector.IsHardwareAccelerated && ((int)(byte*)index < length)) { nLength = (IntPtr)((length - (int)(byte*)index) & ~(Vector.Count - 1)); // Get comparison Vector - Vector values0 = GetVector(value0); - Vector values1 = GetVector(value1); + Vector values0 = new Vector(value0); + Vector values1 = new Vector(value1); while ((byte*)nLength > (byte*)index) { @@ -465,7 +451,6 @@ namespace System goto SequentialScan; } } -#endif return -1; Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549 return (int)(byte*)index; @@ -494,14 +479,13 @@ namespace System uint uValue2 = value2; // Use uint for comparisons to avoid unnecessary 8->32 extensions IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr nLength = (IntPtr)length; -#if !netstandard11 + if (Vector.IsHardwareAccelerated && length >= Vector.Count * 2) { int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector.Count - 1); nLength = (IntPtr)((Vector.Count - unaligned) & (Vector.Count - 1)); } SequentialScan: -#endif uint lookUp; while ((byte*)nLength >= (byte*)8) { @@ -565,15 +549,15 @@ namespace System index += 1; } -#if !netstandard11 + if (Vector.IsHardwareAccelerated && ((int)(byte*)index < length)) { nLength = (IntPtr)((length - (int)(byte*)index) & ~(Vector.Count - 1)); // Get comparison Vector - Vector values0 = GetVector(value0); - Vector values1 = GetVector(value1); - Vector values2 = GetVector(value2); + Vector values0 = new Vector(value0); + Vector values1 = new Vector(value1); + Vector values2 = new Vector(value2); while ((byte*)nLength > (byte*)index) { @@ -600,7 +584,6 @@ namespace System goto SequentialScan; } } -#endif return -1; Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549 return (int)(byte*)index; @@ -628,14 +611,13 @@ namespace System uint uValue1 = value1; // Use uint for comparisons to avoid unnecessary 8->32 extensions IntPtr index = (IntPtr)length; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr nLength = (IntPtr)length; -#if !netstandard11 + if (Vector.IsHardwareAccelerated && length >= Vector.Count * 2) { int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector.Count - 1); nLength = (IntPtr)(((length & (Vector.Count - 1)) + unaligned) & (Vector.Count - 1)); } SequentialScan: -#endif uint lookUp; while ((byte*)nLength >= (byte*)8) { @@ -696,14 +678,14 @@ namespace System if (uValue0 == lookUp || uValue1 == lookUp) goto Found; } -#if !netstandard11 + if (Vector.IsHardwareAccelerated && ((byte*)index > (byte*)0)) { nLength = (IntPtr)((int)(byte*)index & ~(Vector.Count - 1)); // Get comparison Vector - Vector values0 = GetVector(value0); - Vector values1 = GetVector(value1); + Vector values0 = new Vector(value0); + Vector values1 = new Vector(value1); while ((byte*)nLength > (byte*)(Vector.Count - 1)) { @@ -727,7 +709,6 @@ namespace System goto SequentialScan; } } -#endif return -1; Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549 return (int)(byte*)index; @@ -756,14 +737,13 @@ namespace System uint uValue2 = value2; // Use uint for comparisons to avoid unnecessary 8->32 extensions IntPtr index = (IntPtr)length; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr nLength = (IntPtr)length; -#if !netstandard11 + if (Vector.IsHardwareAccelerated && length >= Vector.Count * 2) { int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector.Count - 1); nLength = (IntPtr)(((length & (Vector.Count - 1)) + unaligned) & (Vector.Count - 1)); } SequentialScan: -#endif uint lookUp; while ((byte*)nLength >= (byte*)8) { @@ -824,15 +804,15 @@ namespace System if (uValue0 == lookUp || uValue1 == lookUp || uValue2 == lookUp) goto Found; } -#if !netstandard11 + if (Vector.IsHardwareAccelerated && ((byte*)index > (byte*)0)) { nLength = (IntPtr)((int)(byte*)index & ~(Vector.Count - 1)); // Get comparison Vector - Vector values0 = GetVector(value0); - Vector values1 = GetVector(value1); - Vector values2 = GetVector(value2); + Vector values0 = new Vector(value0); + Vector values1 = new Vector(value1); + Vector values2 = new Vector(value2); while ((byte*)nLength > (byte*)(Vector.Count - 1)) { @@ -860,7 +840,6 @@ namespace System goto SequentialScan; } } -#endif return -1; Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549 return (int)(byte*)index; @@ -890,7 +869,6 @@ namespace System IntPtr i = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr n = (IntPtr)(void*)length; -#if !netstandard11 if (Vector.IsHardwareAccelerated && (byte*)n >= (byte*)Vector.Count) { n -= Vector.Count; @@ -906,7 +884,6 @@ namespace System return Unsafe.ReadUnaligned>(ref Unsafe.AddByteOffset(ref first, n)) == Unsafe.ReadUnaligned>(ref Unsafe.AddByteOffset(ref second, n)); } -#endif if ((byte*)n >= (byte*)sizeof(UIntPtr)) { @@ -938,7 +915,6 @@ namespace System return false; } -#if !netstandard11 // Vector sub-search adapted from https://github.com/aspnet/KestrelHttpServer/pull/1138 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateFirstFoundByte(Vector match) @@ -959,7 +935,6 @@ namespace System // Single LEA instruction with jitted const (using function result) return i * 8 + LocateFirstFoundByte(candidate); } -#endif public static unsafe int SequenceCompareTo(ref byte first, int firstLength, ref byte second, int secondLength) { @@ -974,7 +949,6 @@ namespace System IntPtr i = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr n = (IntPtr)(void*)minLength; -#if !netstandard11 if (Vector.IsHardwareAccelerated && (byte*)n > (byte*)Vector.Count) { n -= Vector.Count; @@ -989,7 +963,6 @@ namespace System } goto NotEqual; } -#endif if ((byte*)n > (byte*)sizeof(UIntPtr)) { @@ -1018,7 +991,6 @@ namespace System return firstLength - secondLength; } -#if !netstandard11 // Vector sub-search adapted from https://github.com/aspnet/KestrelHttpServer/pull/1138 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateLastFoundByte(Vector match) @@ -1039,9 +1011,7 @@ namespace System // Single LEA instruction with jitted const (using function result) return i * 8 + LocateLastFoundByte(candidate); } -#endif -#if !netstandard11 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateFirstFoundByte(ulong match) { @@ -1050,9 +1020,7 @@ namespace System // Shift all powers of two into the high byte and extract return (int)((powerOfTwoFlag * XorPowerOfTwoToHighByte) >> 57); } -#endif -#if !netstandard11 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateLastFoundByte(ulong match) { @@ -1065,24 +1033,7 @@ namespace System } return index; } -#endif - -#if !netstandard11 - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static Vector GetVector(byte vectorByte) - { -#if !netcoreapp - // Vector .ctor doesn't become an intrinsic due to detection issue - // However this does cause it to become an intrinsic (with additional multiply and reg->reg copy) - // https://github.com/dotnet/coreclr/issues/7459#issuecomment-253965670 - return Vector.AsVectorByte(new Vector(vectorByte * 0x01010101u)); -#else - return new Vector(vectorByte); -#endif - } -#endif -#if !netstandard11 private const ulong XorPowerOfTwoToHighByte = (0x07ul | 0x06ul << 8 | 0x05ul << 16 | @@ -1090,6 +1041,5 @@ namespace System 0x03ul << 32 | 0x02ul << 40 | 0x01ul << 48) + 1; -#endif } } -- 2.34.1