< prev index next >

src/share/vm/utilities/bitMap.inline.hpp

Print this page
rev 8928 : 8211926: Catastrophic size_t underflow in BitMap::*_large methods
Reviewed-by: kbarrett, stuefe


 304 }
 305 
 306 
 307 // Returns a bit mask for a range of bits [beg, end) within a single word.  Each
 308 // bit in the mask is 0 if the bit is in the range, 1 if not in the range.  The
 309 // returned mask can be used directly to clear the range, or inverted to set the
 310 // range.  Note:  end must not be 0.
 311 inline BitMap::bm_word_t
 312 BitMap::inverted_bit_mask_for_range(idx_t beg, idx_t end) const {
 313   assert(end != 0, "does not work when end == 0");
 314   assert(beg == end || word_index(beg) == word_index(end - 1),
 315          "must be a single-word range");
 316   bm_word_t mask = bit_mask(beg) - 1;   // low (right) bits
 317   if (bit_in_word(end) != 0) {
 318     mask |= ~(bit_mask(end) - 1);       // high (left) bits
 319   }
 320   return mask;
 321 }
 322 
 323 inline void BitMap::set_large_range_of_words(idx_t beg, idx_t end) {

 324   memset(_map + beg, ~(unsigned char)0, (end - beg) * sizeof(uintptr_t));
 325 }
 326 
 327 inline void BitMap::clear_large_range_of_words(idx_t beg, idx_t end) {

 328   memset(_map + beg, 0, (end - beg) * sizeof(uintptr_t));
 329 }
 330 
 331 inline BitMap::idx_t BitMap::word_index_round_up(idx_t bit) const {
 332   idx_t bit_rounded_up = bit + (BitsPerWord - 1);
 333   // Check for integer arithmetic overflow.
 334   return bit_rounded_up > bit ? word_index(bit_rounded_up) : size_in_words();
 335 }
 336 
 337 inline BitMap::idx_t BitMap::get_next_one_offset(idx_t l_offset,
 338                                           idx_t r_offset) const {
 339   return get_next_one_offset_inline(l_offset, r_offset);
 340 }
 341 
 342 inline BitMap::idx_t BitMap::get_next_zero_offset(idx_t l_offset,
 343                                            idx_t r_offset) const {
 344   return get_next_zero_offset_inline(l_offset, r_offset);
 345 }
 346 
 347 inline void BitMap2D::clear() {


 304 }
 305 
 306 
 307 // Returns a bit mask for a range of bits [beg, end) within a single word.  Each
 308 // bit in the mask is 0 if the bit is in the range, 1 if not in the range.  The
 309 // returned mask can be used directly to clear the range, or inverted to set the
 310 // range.  Note:  end must not be 0.
 311 inline BitMap::bm_word_t
 312 BitMap::inverted_bit_mask_for_range(idx_t beg, idx_t end) const {
 313   assert(end != 0, "does not work when end == 0");
 314   assert(beg == end || word_index(beg) == word_index(end - 1),
 315          "must be a single-word range");
 316   bm_word_t mask = bit_mask(beg) - 1;   // low (right) bits
 317   if (bit_in_word(end) != 0) {
 318     mask |= ~(bit_mask(end) - 1);       // high (left) bits
 319   }
 320   return mask;
 321 }
 322 
 323 inline void BitMap::set_large_range_of_words(idx_t beg, idx_t end) {
 324   assert(beg <= end, "underflow");
 325   memset(_map + beg, ~(unsigned char)0, (end - beg) * sizeof(uintptr_t));
 326 }
 327 
 328 inline void BitMap::clear_large_range_of_words(idx_t beg, idx_t end) {
 329   assert(beg <= end, "underflow");
 330   memset(_map + beg, 0, (end - beg) * sizeof(uintptr_t));
 331 }
 332 
 333 inline BitMap::idx_t BitMap::word_index_round_up(idx_t bit) const {
 334   idx_t bit_rounded_up = bit + (BitsPerWord - 1);
 335   // Check for integer arithmetic overflow.
 336   return bit_rounded_up > bit ? word_index(bit_rounded_up) : size_in_words();
 337 }
 338 
 339 inline BitMap::idx_t BitMap::get_next_one_offset(idx_t l_offset,
 340                                           idx_t r_offset) const {
 341   return get_next_one_offset_inline(l_offset, r_offset);
 342 }
 343 
 344 inline BitMap::idx_t BitMap::get_next_zero_offset(idx_t l_offset,
 345                                            idx_t r_offset) const {
 346   return get_next_zero_offset_inline(l_offset, r_offset);
 347 }
 348 
 349 inline void BitMap2D::clear() {
< prev index next >