8178352: BitMap::get_next_zero_offset may give wrong result on Mac
Summary: Invert and search initial word for trailing ones.
Reviewed-by: stefank, cjplummer
--- a/hotspot/src/share/vm/utilities/bitMap.inline.hpp Fri Mar 03 23:08:35 2017 -0800
+++ b/hotspot/src/share/vm/utilities/bitMap.inline.hpp Wed May 03 14:13:48 2017 -0400
@@ -222,12 +222,12 @@
idx_t res_offset = l_offset;
// check bits including and to the _left_ of offset's position
- idx_t pos = res_offset & (BitsPerWord - 1);
- bm_word_t res = (map(index) >> pos) | left_n_bits((int)pos);
+ idx_t pos = bit_in_word(res_offset);
+ bm_word_t res = ~map(index) >> pos; // flip bits and shift for l_offset
- if (res != ~(bm_word_t)0) {
- // find the position of the 0-bit
- for (; res & 1; res_offset++) {
+ if (res != 0) {
+ // find the position of the 1-bit
+ for (; !(res & 1); res_offset++) {
res = res >> 1;
}
assert(res_offset >= l_offset, "just checking");