Fix CoreFX build breaks
authorJan Kotas <jkotas@microsoft.com>
Fri, 15 Feb 2019 08:11:29 +0000 (00:11 -0800)
committerJan Kotas <jkotas@microsoft.com>
Fri, 15 Feb 2019 15:10:30 +0000 (07:10 -0800)
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Commit migrated from https://github.com/dotnet/coreclr/commit/19ad3d12128e87ddc93baebf8bc0cb2c2bb16b5b

src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/StubEnvironment.cs
src/libraries/System.Private.CoreLib/src/System/Numerics/Hashing/HashHelpers.cs

index 389ae10..7909e8d 100644 (file)
@@ -185,6 +185,7 @@ using Internal.Runtime.Augments;
 
 #if ES_BUILD_STANDALONE
 using EventDescriptor = Microsoft.Diagnostics.Tracing.EventDescriptor;
+using BitOps = Microsoft.Diagnostics.Tracing.Internal.BitOps;
 #else
 using System.Threading.Tasks;
 #endif
index 95ae545..e2b4c63 100644 (file)
@@ -6,6 +6,7 @@ using System;
 using System.Collections.Generic;
 
 #if ES_BUILD_STANDALONE
+using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Security;
 
@@ -51,6 +52,15 @@ namespace System.Diagnostics.Tracing.Internal
 
         private static System.Resources.ResourceManager rm = new System.Resources.ResourceManager("Microsoft.Diagnostics.Tracing.Messages", typeof(Environment).Assembly());
     }
+
+#if ES_BUILD_STANDALONE
+    internal static class BitOps
+    {
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public static uint RotateLeft(uint value, int offset)
+            => (value << offset) | (value >> (32 - offset));
+    }
+#endif
 }
 
 #if ES_BUILD_AGAINST_DOTNET_V35
index 29f8a56..fd9d708 100644 (file)
@@ -10,7 +10,10 @@ namespace System.Numerics.Hashing
 
         public static int Combine(int h1, int h2)
         {
-            return ((int)BitOps.RotateLeft((uint)h1, 5) + h1) ^ h2;
+            // RyuJIT optimizes this to use the ROL instruction
+            // Related GitHub pull request: dotnet/coreclr#1830
+            uint rol5 = ((uint)h1 << 5) | ((uint)h1 >> 27);
+            return ((int)rol5 + h1) ^ h2;
         }
     }
 }