提交 881bfaf1 编写于 作者: T tschatzl

8069760: When iterating over a card, G1 often iterates over much more...

8069760: When iterating over a card, G1 often iterates over much more references than are contained in the card
Summary: Properly bound the iteration work for objArray-oops.
Reviewed-by: mgerdin, kbarrett
上级 e44f2e1d
/* /*
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -468,7 +468,7 @@ oops_on_card_seq_iterate_careful(MemRegion mr, ...@@ -468,7 +468,7 @@ oops_on_card_seq_iterate_careful(MemRegion mr,
oop obj; oop obj;
HeapWord* next = cur; HeapWord* next = cur;
while (next <= start) { do {
cur = next; cur = next;
obj = oop(cur); obj = oop(cur);
if (obj->klass_or_null() == NULL) { if (obj->klass_or_null() == NULL) {
...@@ -477,45 +477,38 @@ oops_on_card_seq_iterate_careful(MemRegion mr, ...@@ -477,45 +477,38 @@ oops_on_card_seq_iterate_careful(MemRegion mr,
} }
// Otherwise... // Otherwise...
next = cur + block_size(cur); next = cur + block_size(cur);
} } while (next <= start);
// If we finish the above loop...We have a parseable object that // If we finish the above loop...We have a parseable object that
// begins on or before the start of the memory region, and ends // begins on or before the start of the memory region, and ends
// inside or spans the entire region. // inside or spans the entire region.
assert(obj == oop(cur), "sanity");
assert(cur <= start, "Loop postcondition"); assert(cur <= start, "Loop postcondition");
assert(obj->klass_or_null() != NULL, "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) { do {
obj = oop(cur); obj = oop(cur);
assert((cur + block_size(cur)) > (HeapWord*)obj, "Loop invariant");
if (obj->klass_or_null() == NULL) { if (obj->klass_or_null() == NULL) {
// Ran into an unparseable point. // Ran into an unparseable point.
return cur; return cur;
}; }
// Otherwise: // Advance the current pointer. "obj" still points to the object to iterate.
next = cur + block_size(cur); cur = cur + block_size(cur);
if (!g1h->is_obj_dead(obj)) { if (!g1h->is_obj_dead(obj)) {
if (next < end || !obj->is_objArray()) { // Non-objArrays are sometimes marked imprecise at the object start. We
// This object either does not span the MemRegion // always need to iterate over them in full.
// boundary, or if it does it's not an array. // We only iterate over object arrays in full if they are completely contained
// Apply closure to whole object. // in the memory region.
if (!obj->is_objArray() || (((HeapWord*)obj) >= start && cur <= end)) {
obj->oop_iterate(cl); obj->oop_iterate(cl);
} else { } else {
// This obj is an array that spans the boundary.
// Stop at the boundary.
obj->oop_iterate(cl, mr); obj->oop_iterate(cl, mr);
} }
} }
cur = next; } while (cur < end);
}
return NULL; return NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册