[local gc] Fix for BitScanForward64, it was ignoring the high byte check (#17142)
authorDavid Mason <davmason@microsoft.com>
Mon, 26 Mar 2018 20:25:32 +0000 (13:25 -0700)
committerGitHub <noreply@github.com>
Mon, 26 Mar 2018 20:25:32 +0000 (13:25 -0700)
src/gc/env/gcenv.base.h

index e1d40d6..b695abc 100644 (file)
@@ -253,12 +253,18 @@ inline uint8_t BitScanForward64(uint32_t *bitIndex, uint64_t mask)
     uint32_t hi = (mask >> 32) & 0xFFFFFFFF;
     uint32_t lo = mask & 0xFFFFFFFF;
     uint32_t fakeBitIndex = 0;
-    if (BitScanForward(&fakeBitIndex, hi))
+    
+    uint8_t result = BitScanForward(bitIndex, lo);
+    if (result == 0)
     {
-        *bitIndex = fakeBitIndex + 32;
+        result = BitScanForward(&fakeBitIndex, hi);
+        if (result != 0)
+        {
+            *bitIndex = fakeBitIndex + 32;
+        }
     }
 
-    return BitScanForward(bitIndex, lo);
+    return result;
  #else
     return _BitScanForward64((unsigned long*)bitIndex, mask);
  #endif // _WIN32