inline void CMSBitMap::iterate(BitMapClosure* cl, HeapWord* left, HeapWord* right) { assert_locked(); left = MAX2(_bmStartWord, left); right = MIN2(_bmStartWord + _bmWordSize, right); if (right > left) { _bm.iterate(cl, heapWordToOffset(left), heapWordToOffset(right)); } }
inline void CMSBitMap::par_markRange(MemRegion mr) { assert_locked(); mr = mr.intersection(MemRegion(_bmStartWord, _bmWordSize)); assert(!mr.is_empty(), "unexpected empty region"); // convert address range into offset range size_t start_ofs = heapWordToOffset(mr.start()); size_t end_ofs = heapWordToOffset(mr.end()); // Range size is usually just 1 bit. _bm.par_set_range(start_ofs, end_ofs, BitMap::small_range); }
// Return the HeapWord address corrsponding to the next "0" bit // (inclusive). inline HeapWord* CMSBitMap::getNextUnmarkedWordAddress( HeapWord* start_addr, HeapWord* end_addr) const { assert_locked(); size_t nextOffset = _bm.get_next_zero_offset( heapWordToOffset(start_addr), heapWordToOffset(end_addr)); HeapWord* nextAddr = offsetToHeapWord(nextOffset); assert(nextAddr >= start_addr && nextAddr <= end_addr, "get_next_zero postcondition"); assert((nextAddr == end_addr) || isUnmarked(nextAddr), "get_next_zero postcondition"); return nextAddr; }
inline bool G1CMBitMapRO::iterate(BitMapClosure* cl, MemRegion mr) { HeapWord* start_addr = MAX2(startWord(), mr.start()); HeapWord* end_addr = MIN2(endWord(), mr.end()); if (end_addr > start_addr) { // Right-open interval [start-offset, end-offset). BitMap::idx_t start_offset = heapWordToOffset(start_addr); BitMap::idx_t end_offset = heapWordToOffset(end_addr); start_offset = _bm.get_next_one_offset(start_offset, end_offset); while (start_offset < end_offset) { if (!cl->do_bit(start_offset)) { return false; } HeapWord* next_addr = MIN2(nextObject(offsetToHeapWord(start_offset)), end_addr); BitMap::idx_t next_offset = heapWordToOffset(next_addr); start_offset = _bm.get_next_one_offset(next_offset, end_offset); } } return true; }
inline bool G1CMBitMap::parMark(HeapWord* addr) { check_mark(addr); return _bm.par_set_bit(heapWordToOffset(addr)); }
inline void G1CMBitMap::clear(HeapWord* addr) { check_mark(addr); _bm.clear_bit(heapWordToOffset(addr)); }
inline void G1CMBitMap::mark(HeapWord* addr) { check_mark(addr); _bm.set_bit(heapWordToOffset(addr)); }
// The argument addr should be the start address of a valid object HeapWord* G1CMBitMapRO::nextObject(HeapWord* addr) { oop obj = (oop) addr; HeapWord* res = addr + obj->size(); assert(offsetToHeapWord(heapWordToOffset(res)) == res, "sanity"); return res; }
inline void CMSBitMap::par_clear_range(MemRegion mr) { NOT_PRODUCT(region_invariant(mr)); // Range size is usually just 1 bit. _bm.par_clear_range(heapWordToOffset(mr.start()), heapWordToOffset(mr.end()), BitMap::small_range); }
inline void CMSBitMap::par_clear(HeapWord* addr) { assert_locked(); assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize), "outside underlying space?"); _bm.par_at_put(heapWordToOffset(addr), false); }
inline bool CMSBitMap::par_mark(HeapWord* addr) { assert_locked(); assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize), "outside underlying space?"); return _bm.par_at_put(heapWordToOffset(addr), true); }
inline void CMSBitMap::mark(HeapWord* addr) { assert_locked(); assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize), "outside underlying space?"); _bm.set_bit(heapWordToOffset(addr)); }
inline bool CMSBitMap::isUnmarked(HeapWord* addr) const { assert_locked(); assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize), "outside underlying space?"); return !_bm.at(heapWordToOffset(addr)); }
inline void CMSBitMap::par_clear_large_range(MemRegion mr) { NOT_PRODUCT(region_invariant(mr)); // Range size must be greater than 32 bytes. _bm.par_clear_range(heapWordToOffset(mr.start()), heapWordToOffset(mr.end()), BitMap::large_range); }