< prev index next > src/hotspot/share/gc/parallel/mutableSpace.cpp
Print this page
while (obj_addr < t) {
obj_addr += cast_to_oop(obj_addr)->oop_iterate_size(cl);
}
}
- void MutableSpace::object_iterate(ObjectClosure* cl) {
+ template<bool COMPACT_HEADERS>
+ void MutableSpace::object_iterate_impl(ObjectClosure* cl) {
HeapWord* p = bottom();
while (p < top()) {
oop obj = cast_to_oop(p);
// When promotion-failure occurs during Young GC, eden/from space is not cleared,
// so we can encounter objects with "forwarded" markword.
// They are essentially dead, so skipping them
if (!obj->is_forwarded()) {
cl->do_object(obj);
- }
- #ifdef ASSERT
- else {
+ p += obj->size();
+ } else {
assert(obj->forwardee() != obj, "must not be self-forwarded");
+ if (COMPACT_HEADERS) {
+ // It is safe to use the forwardee here. Parallel GC only uses
+ // header-based forwarding during promotion. Full GC doesn't
+ // use the object header for forwarding at all.
+ p += obj->forwardee()->size();
+ } else {
+ p += obj->size();
+ }
}
- #endif
- p += obj->size();
+ }
+ }
+
+ void MutableSpace::object_iterate(ObjectClosure* cl) {
+ if (UseCompactObjectHeaders) {
+ object_iterate_impl<true>(cl);
+ } else {
+ object_iterate_impl<false>(cl);
}
}
void MutableSpace::print_short() const { print_short_on(tty); }
void MutableSpace::print_short_on( outputStream* st) const {
< prev index next >