< prev index next >

src/share/vm/gc/g1/g1ConcurrentMark.inline.hpp

Print this page
rev 13284 : imported patch 8184346-cleanup-g1cmbitmap
rev 13286 : imported patch 8184346-erikd-mgerdin-review
rev 13287 : [mq]: 8184346-erikd-review

@@ -35,49 +35,35 @@
 inline bool G1ConcurrentMark::par_mark(oop obj) {
   return _nextMarkBitMap->par_mark((HeapWord*)obj);
 }
 
 inline bool G1CMBitMap::iterate(G1CMBitMapClosure* cl, MemRegion mr) {
-  HeapWord* start_addr = MAX2(_covered.start(), mr.start());
-  HeapWord* const end_addr = MIN2(_covered.end(), mr.end());
+  assert(!mr.is_empty(), "Does not support empty memregion to iterate over");
+  assert(_covered.contains(mr), "Given MemRegion from " PTR_FORMAT " to " PTR_FORMAT " not contained in heap area", p2i(mr.start()), p2i(mr.end()));
 
-  if (end_addr > start_addr) {
-    // Right-open interval [start-offset, end-offset).
-    BitMap::idx_t start_offset = addr_to_offset(start_addr);
-    BitMap::idx_t const end_offset = addr_to_offset(end_addr);
+  BitMap::idx_t const end_offset = addr_to_offset(mr.end());
+  BitMap::idx_t offset = _bm.get_next_one_offset(addr_to_offset(mr.start()), end_offset);
 
-    start_offset = _bm.get_next_one_offset(start_offset, end_offset);
-    while (start_offset < end_offset) {
-      start_addr = offset_to_addr(start_offset);
-      if (!cl->do_addr(start_addr)) {
+  while (offset < end_offset) {
+    HeapWord* const addr = offset_to_addr(offset);
+    if (!cl->do_addr(addr)) {
         return false;
       }
-      HeapWord* next_addr = MIN2(addr_after_obj(start_addr), end_addr);
-      BitMap::idx_t const next_offset = addr_to_offset(next_addr);
-      start_offset = _bm.get_next_one_offset(next_offset, end_offset);
-    }
+    size_t const obj_size = (size_t)((oop)addr)->size();
+    offset = _bm.get_next_one_offset(offset + (obj_size >> _shifter), end_offset);
   }
   return true;
 }
 
 inline HeapWord* G1CMBitMap::get_next_marked_addr(const HeapWord* addr,
                                                   const HeapWord* limit) const {
-  // First we must round addr *up* to a possible object boundary.
-  addr = (HeapWord*)align_up(addr, HeapWordSize << _shifter);
-  size_t addrOffset = addr_to_offset(addr);
   assert(limit != NULL, "limit must not be NULL");
-  size_t limitOffset = addr_to_offset(limit);
-  size_t nextOffset = _bm.get_next_one_offset(addrOffset, limitOffset);
-  HeapWord* nextAddr = offset_to_addr(nextOffset);
-  assert(nextAddr >= addr, "get_next_one postcondition");
-  assert(nextAddr == limit || is_marked(nextAddr),
-         "get_next_one postcondition");
-  return nextAddr;
-}
-
-inline HeapWord* G1CMBitMap::addr_after_obj(HeapWord* addr) {
-  return addr + ((oop)addr)->size();
+  // Round addr up to a possible object boundary to be safe.
+  size_t const addr_offset = addr_to_offset(align_up(addr, HeapWordSize << _shifter));
+  size_t const limit_offset = addr_to_offset(limit);
+  size_t const nextOffset = _bm.get_next_one_offset(addr_offset, limit_offset);
+  return offset_to_addr(nextOffset);
 }
 
 #ifdef ASSERT
 inline void G1CMBitMap::check_mark(HeapWord* addr) {
   assert(G1CollectedHeap::heap()->is_in_exact(addr),
< prev index next >