# HG changeset patch # User kbarrett # Date 1493835228 14400 # Node ID d577822ca75cc22f90285ef7ca914ea0457c524f # Parent 54713555867ee2c7cac1954fd40f284240af8d51 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 diff -r 54713555867e -r d577822ca75c hotspot/src/share/vm/utilities/bitMap.inline.hpp --- 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");