< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahMarkBitMap.cpp

Print this page

 26 #include "precompiled.hpp"
 27 #include "gc/shenandoah/shenandoahMarkBitMap.inline.hpp"
 28 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 29 #include "utilities/globalDefinitions.hpp"
 30 
 31 ShenandoahMarkBitMap::ShenandoahMarkBitMap(MemRegion heap, MemRegion storage) :
 32   _shift(LogMinObjAlignment),
 33   _covered(heap),
 34   _map((BitMap::bm_word_t*) storage.start()),
 35   _size((heap.word_size() * 2) >> _shift) {
 36 }
 37 
 38 size_t ShenandoahMarkBitMap::compute_size(size_t heap_size) {
 39   return ReservedSpace::allocation_align_size_up(heap_size / mark_distance());
 40 }
 41 
 42 size_t ShenandoahMarkBitMap::mark_distance() {
 43   return MinObjAlignmentInBytes * BitsPerByte / 2;
 44 }
 45 














 46 HeapWord* ShenandoahMarkBitMap::get_next_marked_addr(const HeapWord* addr,
 47                                                      const HeapWord* limit) const {





 48   assert(limit != NULL, "limit must not be NULL");



 49   // Round addr up to a possible object boundary to be safe.
 50   size_t const addr_offset = address_to_index(align_up(addr, HeapWordSize << LogMinObjAlignment));
 51   size_t const limit_offset = address_to_index(limit);
 52   size_t const nextOffset = get_next_one_offset(addr_offset, limit_offset);
 53   return index_to_address(nextOffset);

 54 }
 55 
 56 void ShenandoahMarkBitMap::clear_range_within_word(idx_t beg, idx_t end) {
 57   // With a valid range (beg <= end), this test ensures that end != 0, as
 58   // required by inverted_bit_mask_for_range.  Also avoids an unnecessary write.
 59   if (beg != end) {
 60     bm_word_t mask = inverted_bit_mask_for_range(beg, end);
 61     *word_addr(beg) &= mask;
 62   }
 63 }
 64 
 65 void ShenandoahMarkBitMap::clear_range(idx_t beg, idx_t end) {
 66   verify_range(beg, end);
 67 
 68   idx_t beg_full_word = to_words_align_up(beg);
 69   idx_t end_full_word = to_words_align_down(end);
 70 
 71   if (beg_full_word < end_full_word) {
 72     // The range includes at least one full word.
 73     clear_range_within_word(beg, bit_index(beg_full_word));

 26 #include "precompiled.hpp"
 27 #include "gc/shenandoah/shenandoahMarkBitMap.inline.hpp"
 28 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 29 #include "utilities/globalDefinitions.hpp"
 30 
 31 ShenandoahMarkBitMap::ShenandoahMarkBitMap(MemRegion heap, MemRegion storage) :
 32   _shift(LogMinObjAlignment),
 33   _covered(heap),
 34   _map((BitMap::bm_word_t*) storage.start()),
 35   _size((heap.word_size() * 2) >> _shift) {
 36 }
 37 
 38 size_t ShenandoahMarkBitMap::compute_size(size_t heap_size) {
 39   return ReservedSpace::allocation_align_size_up(heap_size / mark_distance());
 40 }
 41 
 42 size_t ShenandoahMarkBitMap::mark_distance() {
 43   return MinObjAlignmentInBytes * BitsPerByte / 2;
 44 }
 45 
 46 bool ShenandoahMarkBitMap::is_bitmap_clear_range(const HeapWord* start, const HeapWord* end) const {
 47   // Similar to get_next_marked_addr(), without assertion.
 48   // Round addr up to a possible object boundary to be safe.
 49   if (start == end) {
 50     return true;
 51   }
 52   size_t const addr_offset = address_to_index(align_up(start, HeapWordSize << LogMinObjAlignment));
 53   size_t const limit_offset = address_to_index(end);
 54   size_t const next_offset = get_next_one_offset(addr_offset, limit_offset);
 55   HeapWord* result = index_to_address(next_offset);
 56   return (result == end);
 57 }
 58 
 59 
 60 HeapWord* ShenandoahMarkBitMap::get_next_marked_addr(const HeapWord* addr,
 61                                                      const HeapWord* limit) const {
 62 #ifdef ASSERT
 63   ShenandoahHeap* heap = ShenandoahHeap::heap();
 64   ShenandoahHeapRegion* r = heap->heap_region_containing(addr);
 65   ShenandoahMarkingContext* ctx = heap->marking_context();
 66   HeapWord* tams = ctx->top_at_mark_start(r);
 67   assert(limit != NULL, "limit must not be NULL");
 68   assert(limit <= tams, "limit must be less than TAMS");
 69 #endif
 70 
 71   // Round addr up to a possible object boundary to be safe.
 72   size_t const addr_offset = address_to_index(align_up(addr, HeapWordSize << LogMinObjAlignment));
 73   size_t const limit_offset = address_to_index(limit);
 74   size_t const nextOffset = get_next_one_offset(addr_offset, limit_offset);
 75   HeapWord* result = index_to_address(nextOffset);
 76   return result;
 77 }
 78 
 79 void ShenandoahMarkBitMap::clear_range_within_word(idx_t beg, idx_t end) {
 80   // With a valid range (beg <= end), this test ensures that end != 0, as
 81   // required by inverted_bit_mask_for_range.  Also avoids an unnecessary write.
 82   if (beg != end) {
 83     bm_word_t mask = inverted_bit_mask_for_range(beg, end);
 84     *word_addr(beg) &= mask;
 85   }
 86 }
 87 
 88 void ShenandoahMarkBitMap::clear_range(idx_t beg, idx_t end) {
 89   verify_range(beg, end);
 90 
 91   idx_t beg_full_word = to_words_align_up(beg);
 92   idx_t end_full_word = to_words_align_down(end);
 93 
 94   if (beg_full_word < end_full_word) {
 95     // The range includes at least one full word.
 96     clear_range_within_word(beg, bit_index(beg_full_word));
< prev index next >