bool ParMarkBitMap::mark_obj(HeapWord* addr, size_t size) { const idx_t beg_bit = addr_to_bit(addr); if (_beg_bits.par_set_bit(beg_bit)) { const idx_t end_bit = addr_to_bit(addr + size - 1); bool end_bit_ok = _end_bits.par_set_bit(end_bit); assert(end_bit_ok, "concurrency problem"); DEBUG_ONLY(Atomic::inc_ptr(&mark_bitmap_count)); DEBUG_ONLY(Atomic::add_ptr(size, &mark_bitmap_size)); return true; } return false; }
size_t ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, oop end_obj) const { assert(beg_addr <= (HeapWord*)end_obj, "bad range"); assert(is_marked(end_obj), "end_obj must be live"); idx_t live_bits = 0; // The bitmap routines require the right boundary to be word-aligned. const idx_t end_bit = addr_to_bit((HeapWord*)end_obj); const idx_t range_end = BitMap::word_align_up(end_bit); idx_t beg_bit = find_obj_beg(addr_to_bit(beg_addr), range_end); while (beg_bit < end_bit) { idx_t tmp_end = find_obj_end(beg_bit, range_end); assert(tmp_end < end_bit, "missing end bit"); live_bits += tmp_end - beg_bit + 1; beg_bit = find_obj_beg(tmp_end + 1, range_end); } return bits_to_words(live_bits); }
size_t ParMarkBitMap::live_words_in_range(HeapWord* beg_addr, HeapWord* end_addr) const { assert(beg_addr <= end_addr, "bad range"); idx_t live_bits = 0; // The bitmap routines require the right boundary to be word-aligned. const idx_t end_bit = addr_to_bit(end_addr); const idx_t range_end = BitMap::word_align_up(end_bit); idx_t beg_bit = find_obj_beg(addr_to_bit(beg_addr), range_end); while (beg_bit < end_bit) { idx_t tmp_end = find_obj_end(beg_bit, range_end); if (tmp_end < end_bit) { live_bits += tmp_end - beg_bit + 1; beg_bit = find_obj_beg(tmp_end + 1, range_end); } else { live_bits += end_bit - beg_bit; // No + 1 here; end_bit is not counted. return bits_to_words(live_bits); } } return bits_to_words(live_bits); }
inline bool ParMarkBitMap::is_marked(HeapWord* addr) const { return is_marked(addr_to_bit(addr)); }