src/hotspot/share/utilities/bitMap.cpp
changeset 52485 e5534cc91a10
parent 51491 187c84a5efe1
child 54679 3a2e45820d77
equal deleted inserted replaced
52484:18bd95c0e463 52485:e5534cc91a10
   261     clear_range_within_word(beg, boundary);
   261     clear_range_within_word(beg, boundary);
   262     clear_range_within_word(boundary, end);
   262     clear_range_within_word(boundary, end);
   263   }
   263   }
   264 }
   264 }
   265 
   265 
       
   266 bool BitMap::is_small_range_of_words(idx_t beg_full_word, idx_t end_full_word) {
       
   267   // There is little point to call large version on small ranges.
       
   268   // Need to check carefully, keeping potential idx_t underflow in mind.
       
   269   // The threshold should be at least one word.
       
   270   STATIC_ASSERT(small_range_words >= 1);
       
   271   return (beg_full_word + small_range_words >= end_full_word);
       
   272 }
       
   273 
   266 void BitMap::set_large_range(idx_t beg, idx_t end) {
   274 void BitMap::set_large_range(idx_t beg, idx_t end) {
   267   verify_range(beg, end);
   275   verify_range(beg, end);
   268 
   276 
   269   idx_t beg_full_word = word_index_round_up(beg);
   277   idx_t beg_full_word = word_index_round_up(beg);
   270   idx_t end_full_word = word_index(end);
   278   idx_t end_full_word = word_index(end);
   271 
   279 
   272   assert(end_full_word - beg_full_word >= 32,
   280   if (is_small_range_of_words(beg_full_word, end_full_word)) {
   273          "the range must include at least 32 bytes");
   281     set_range(beg, end);
       
   282     return;
       
   283   }
   274 
   284 
   275   // The range includes at least one full word.
   285   // The range includes at least one full word.
   276   set_range_within_word(beg, bit_index(beg_full_word));
   286   set_range_within_word(beg, bit_index(beg_full_word));
   277   set_large_range_of_words(beg_full_word, end_full_word);
   287   set_large_range_of_words(beg_full_word, end_full_word);
   278   set_range_within_word(bit_index(end_full_word), end);
   288   set_range_within_word(bit_index(end_full_word), end);
   282   verify_range(beg, end);
   292   verify_range(beg, end);
   283 
   293 
   284   idx_t beg_full_word = word_index_round_up(beg);
   294   idx_t beg_full_word = word_index_round_up(beg);
   285   idx_t end_full_word = word_index(end);
   295   idx_t end_full_word = word_index(end);
   286 
   296 
   287   if (end_full_word - beg_full_word < 32) {
   297   if (is_small_range_of_words(beg_full_word, end_full_word)) {
   288     clear_range(beg, end);
   298     clear_range(beg, end);
   289     return;
   299     return;
   290   }
   300   }
   291 
   301 
   292   // The range includes at least one full word.
   302   // The range includes at least one full word.
   366   verify_range(beg, end);
   376   verify_range(beg, end);
   367 
   377 
   368   idx_t beg_full_word = word_index_round_up(beg);
   378   idx_t beg_full_word = word_index_round_up(beg);
   369   idx_t end_full_word = word_index(end);
   379   idx_t end_full_word = word_index(end);
   370 
   380 
   371   assert(end_full_word - beg_full_word >= 32,
   381   if (is_small_range_of_words(beg_full_word, end_full_word)) {
   372          "the range must include at least 32 bytes");
   382     par_at_put_range(beg, end, value);
       
   383     return;
       
   384   }
   373 
   385 
   374   // The range includes at least one full word.
   386   // The range includes at least one full word.
   375   par_put_range_within_word(beg, bit_index(beg_full_word), value);
   387   par_put_range_within_word(beg, bit_index(beg_full_word), value);
   376   if (value) {
   388   if (value) {
   377     set_large_range_of_words(beg_full_word, end_full_word);
   389     set_large_range_of_words(beg_full_word, end_full_word);