< prev index next >

src/share/vm/gc_implementation/g1/heapRegion.cpp

Print this page
rev 7697 : imported patch 8069760-remove-duplicate-oop_iterate

@@ -433,43 +433,38 @@
 
   // If we finish the above loop...We have a parseable object that
   // begins on or before the start of the memory region, and ends
   // inside or spans the entire region.
 
-  assert(obj == oop(cur), "sanity");
   assert(cur <= start, "Loop postcondition");
-  assert(obj->klass_or_null() != NULL, "Loop postcondition");
-  assert((cur + block_size(cur)) > start, "Loop postcondition");
 
-  if (!g1h->is_obj_dead(obj)) {
-    obj->oop_iterate(cl, mr);
-  }
-
-  while (cur < end) {
-    obj = oop(cur);
+  do {
+    assert(obj->klass_or_null() != NULL, "Loop invariant");
+    assert((cur + block_size(cur)) > (HeapWord*)obj, "Loop invariant");
+    assert(obj == oop(cur), "Loop invariant");
     if (obj->klass_or_null() == NULL) {
       // Ran into an unparseable point.
       return cur;
-    };
+    }
 
-    // Otherwise:
-    next = cur + block_size(cur);
+    // Advance the current pointer. "obj" still points to the object to iterate.
+    cur = cur + block_size(cur);
 
     if (!g1h->is_obj_dead(obj)) {
-      if (next < end || !obj->is_objArray()) {
-        // This object either does not span the MemRegion
-        // boundary, or if it does it's not an array.
-        // Apply closure to whole object.
+      // Non-object arrays are sometimes marked imprecise at the object start. We
+      // always need to iterate over them in full.
+      // We only iterate over object arrays in full if they are completely contained
+      // in the memory region.
+      if (!obj->is_objArray() || (((HeapWord*)obj) >= start && cur < end)) {
         obj->oop_iterate(cl);
       } else {
-        // This obj is an array that spans the boundary.
-        // Stop at the boundary.
         obj->oop_iterate(cl, mr);
       }
     }
-    cur = next;
-  }
+    obj = oop(cur);
+  } while (cur < end);
+
   return NULL;
 }
 
 // Code roots support
 

@@ -678,10 +673,11 @@
 #endif // PRODUCT
   }
 
   template <class T>
   void do_oop_work(T* p) {
+//      gclog_or_tty->print_cr("Verifying address " PTR_FORMAT, p2i(p));
     assert(_containing_obj != NULL, "Precondition");
     assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),
            "Precondition");
     T heap_oop = oopDesc::load_heap_oop(p);
     if (!oopDesc::is_null(heap_oop)) {
< prev index next >