--- old/src/share/vm/gc_implementation/g1/heapRegion.cpp 2015-01-27 12:53:36.890390490 +0100 +++ new/src/share/vm/gc_implementation/g1/heapRegion.cpp 2015-01-27 12:53:36.761386754 +0100 @@ -435,39 +435,34 @@ // 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; } @@ -680,6 +675,7 @@ template 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");