< prev index next >

src/hotspot/share/utilities/bitMap.cpp

Print this page
rev 57601 : [mq]: metaspace-improvement


 592 }
 593 
 594 bool BitMap::is_empty() const {
 595   const bm_word_t* words = map();
 596   idx_t limit = word_index(size());
 597   for (idx_t index = 0; index < limit; ++index) {
 598     if (words[index] != 0) return false;
 599   }
 600   idx_t rest = bit_in_word(size());
 601   return (rest == 0) || (tail_of_map(words[limit], rest) == 0);
 602 }
 603 
 604 void BitMap::clear_large() {
 605   clear_large_range_of_words(0, size_in_words());
 606 }
 607 
 608 // Note that if the closure itself modifies the bitmap
 609 // then modifications in and to the left of the _bit_ being
 610 // currently sampled will not be seen. Note also that the
 611 // interval [leftOffset, rightOffset) is right open.
 612 bool BitMap::iterate(BitMapClosure* blk, idx_t leftOffset, idx_t rightOffset) {
 613   verify_range(leftOffset, rightOffset);
 614 
 615   idx_t startIndex = word_index(leftOffset);
 616   idx_t endIndex   = MIN2(word_index(rightOffset) + 1, size_in_words());
 617   for (idx_t index = startIndex, offset = leftOffset;
 618        offset < rightOffset && index < endIndex;
 619        offset = (++index) << LogBitsPerWord) {
 620     idx_t rest = map(index) >> (offset & (BitsPerWord - 1));
 621     for (; offset < rightOffset && rest != 0; offset++) {
 622       if (rest & 1) {
 623         if (!blk->do_bit(offset)) return false;
 624         //  resample at each closure application
 625         // (see, for instance, CMS bug 4525989)
 626         rest = map(index) >> (offset & (BitsPerWord -1));
 627       }
 628       rest = rest >> 1;
 629     }
 630   }
 631   return true;
 632 }




 592 }
 593 
 594 bool BitMap::is_empty() const {
 595   const bm_word_t* words = map();
 596   idx_t limit = word_index(size());
 597   for (idx_t index = 0; index < limit; ++index) {
 598     if (words[index] != 0) return false;
 599   }
 600   idx_t rest = bit_in_word(size());
 601   return (rest == 0) || (tail_of_map(words[limit], rest) == 0);
 602 }
 603 
 604 void BitMap::clear_large() {
 605   clear_large_range_of_words(0, size_in_words());
 606 }
 607 
 608 // Note that if the closure itself modifies the bitmap
 609 // then modifications in and to the left of the _bit_ being
 610 // currently sampled will not be seen. Note also that the
 611 // interval [leftOffset, rightOffset) is right open.
 612 bool BitMap::iterate(BitMapClosure* blk, idx_t leftOffset, idx_t rightOffset) const {
 613   verify_range(leftOffset, rightOffset);
 614 
 615   idx_t startIndex = word_index(leftOffset);
 616   idx_t endIndex   = MIN2(word_index(rightOffset) + 1, size_in_words());
 617   for (idx_t index = startIndex, offset = leftOffset;
 618        offset < rightOffset && index < endIndex;
 619        offset = (++index) << LogBitsPerWord) {
 620     idx_t rest = map(index) >> (offset & (BitsPerWord - 1));
 621     for (; offset < rightOffset && rest != 0; offset++) {
 622       if (rest & 1) {
 623         if (!blk->do_bit(offset)) return false;
 624         //  resample at each closure application
 625         // (see, for instance, CMS bug 4525989)
 626         rest = map(index) >> (offset & (BitsPerWord -1));
 627       }
 628       rest = rest >> 1;
 629     }
 630   }
 631   return true;
 632 }


< prev index next >