Use AggressiveOptimization for intrinsics-based SpanHelpers (#22191)
authorBen Adams <thundercat@illyriad.co.uk>
Fri, 25 Jan 2019 16:17:58 +0000 (17:17 +0100)
committerJan Kotas <jkotas@microsoft.com>
Fri, 25 Jan 2019 16:17:58 +0000 (08:17 -0800)
* Use AggressiveOptimization for intrinsics-based SpanHelpers

* Remove from LastIndexOfAny

src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs
src/System.Private.CoreLib/shared/System/SpanHelpers.Char.cs

index 3062a40..443c7be 100644 (file)
@@ -101,6 +101,7 @@ namespace System
         }
 
         // Adapted from IndexOf(...)
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe bool Contains(ref byte searchSpace, byte value, int length)
         {
             Debug.Assert(length >= 0);
@@ -190,6 +191,7 @@ namespace System
             return true;
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe int IndexOf(ref byte searchSpace, byte value, int length)
         {
             Debug.Assert(length >= 0);
@@ -430,6 +432,7 @@ namespace System
             return -1;
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe int LastIndexOf(ref byte searchSpace, byte value, int length)
         {
             Debug.Assert(length >= 0);
@@ -534,6 +537,7 @@ namespace System
             return (int)(byte*)(offset + 7);
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe int IndexOfAny(ref byte searchSpace, byte value0, byte value1, int length)
         {
             Debug.Assert(length >= 0);
@@ -765,6 +769,7 @@ namespace System
             return (int)(byte*)(offset + 7);
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe int IndexOfAny(ref byte searchSpace, byte value0, byte value1, byte value2, int length)
         {
             Debug.Assert(length >= 0);
@@ -1265,6 +1270,7 @@ namespace System
 
         // Optimized byte-based SequenceEquals. The "length" parameter for this one is declared a nuint rather than int as we also use it for types other than byte
         // where the length can exceed 2Gb once scaled by sizeof(T).
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe bool SequenceEqual(ref byte first, ref byte second, nuint length)
         {
             if (Unsafe.AreSame(ref first, ref second))
@@ -1335,6 +1341,7 @@ namespace System
             return i * 8 + LocateFirstFoundByte(candidate);
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe int SequenceCompareTo(ref byte first, int firstLength, ref byte second, int secondLength)
         {
             Debug.Assert(firstLength >= 0);
index d57944e..b591152 100644 (file)
@@ -61,6 +61,7 @@ namespace System
             return -1;
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe int SequenceCompareTo(ref char first, int firstLength, ref char second, int secondLength)
         {
             Debug.Assert(firstLength >= 0);
@@ -124,6 +125,7 @@ namespace System
         }
 
         // Adapted from IndexOf(...)
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe bool Contains(ref char searchSpace, char value, int length)
         {
             Debug.Assert(length >= 0);
@@ -211,6 +213,7 @@ namespace System
             }
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe int IndexOf(ref char searchSpace, char value, int length)
         {
             Debug.Assert(length >= 0);
@@ -304,6 +307,7 @@ namespace System
             }
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe int IndexOfAny(ref char searchSpace, char value0, char value1, int length)
         {
             Debug.Assert(length >= 0);
@@ -401,6 +405,7 @@ namespace System
             }
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe int IndexOfAny(ref char searchSpace, char value0, char value1, char value2, int length)
         {
             Debug.Assert(length >= 0);
@@ -501,6 +506,7 @@ namespace System
             }
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe int IndexOfAny(ref char searchSpace, char value0, char value1, char value2, char value3, int length)
         {
             Debug.Assert(length >= 0);
@@ -603,6 +609,7 @@ namespace System
             }
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe int IndexOfAny(ref char searchSpace, char value0, char value1, char value2, char value3, char value4, int length)
         {
             Debug.Assert(length >= 0);
@@ -708,6 +715,7 @@ namespace System
             }
         }
 
+        [MethodImpl(MethodImplOptions.AggressiveOptimization)]
         public static unsafe int LastIndexOf(ref char searchSpace, char value, int length)
         {
             Debug.Assert(length >= 0);