8217639: Minimal and Zero builds fail after JDK-8217519 (Improve RegMask population count calculation)
authorshade
Wed, 23 Jan 2019 19:31:00 +0100
changeset 53450 cad3e5102aa6
parent 53449 ea002b56e2f3
child 53457 e3ed96060992
8217639: Minimal and Zero builds fail after JDK-8217519 (Improve RegMask population count calculation) Reviewed-by: kvn
test/hotspot/gtest/utilities/test_population_count.cpp
--- a/test/hotspot/gtest/utilities/test_population_count.cpp	Mon Jan 21 13:31:42 2019 +0800
+++ b/test/hotspot/gtest/utilities/test_population_count.cpp	Wed Jan 23 19:31:00 2019 +0100
@@ -29,18 +29,35 @@
 #include "utilities/globalDefinitions.hpp"
 #include "unittest.hpp"
 
+uint8_t test_popcnt_bitsInByte[BITS_IN_BYTE_ARRAY_SIZE] = {
+        0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
+        1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+        1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+        2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+        1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+        2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+        2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+        3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+        1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
+        2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+        2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+        3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+        2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
+        3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+        3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
+        4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
+};
 
 TEST(population_count, sparse) {
-  extern uint8_t bitsInByte[BITS_IN_BYTE_ARRAY_SIZE];
   // Step through the entire input range from a random starting point,
   // verify population_count return values against the lookup table
   // approach used historically
   uint32_t step = 4711;
   for (uint32_t value = os::random() % step; value < UINT_MAX - step; value += step) {
-    uint32_t lookup = bitsInByte[(value >> 24) & 0xff] +
-                      bitsInByte[(value >> 16) & 0xff] +
-                      bitsInByte[(value >> 8)  & 0xff] +
-                      bitsInByte[ value        & 0xff];
+    uint32_t lookup = test_popcnt_bitsInByte[(value >> 24) & 0xff] +
+                      test_popcnt_bitsInByte[(value >> 16) & 0xff] +
+                      test_popcnt_bitsInByte[(value >> 8)  & 0xff] +
+                      test_popcnt_bitsInByte[ value        & 0xff];
 
     EXPECT_EQ(lookup, population_count(value))
         << "value = " << value;