From a896bf909c0088ebf4d785686d2bfbeefb1fac5f Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Wed, 3 May 2017 14:13:48 -0400 Subject: [PATCH] 8178352: BitMap::get_next_zero_offset may give wrong result on Mac Invert and search initial word for trailing ones. Reviewed-by: stefank, cjplummer --- hotspot/src/share/vm/utilities/bitMap.inline.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/utilities/bitMap.inline.hpp b/hotspot/src/share/vm/utilities/bitMap.inline.hpp index e7b0f13dc92..0cc1133a3af 100644 --- a/hotspot/src/share/vm/utilities/bitMap.inline.hpp +++ b/hotspot/src/share/vm/utilities/bitMap.inline.hpp @@ -222,12 +222,12 @@ BitMap::get_next_zero_offset(idx_t l_offset, idx_t r_offset) const { 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");