diff --git a/src/hotspot/share/gc/shared/space.cpp b/src/hotspot/share/gc/shared/space.cpp index 1a9e726625a..d99784cf029 100644 --- a/src/hotspot/share/gc/shared/space.cpp +++ b/src/hotspot/share/gc/shared/space.cpp @@ -146,14 +146,11 @@ bool Space::obj_is_alive(const HeapWord* p) const { } void ContiguousSpace::object_iterate(ObjectClosure* blk) { - if (is_empty()) return; - object_iterate_from(bottom(), blk); -} - -void ContiguousSpace::object_iterate_from(HeapWord* mark, ObjectClosure* blk) { - while (mark < top()) { - blk->do_object(cast_to_oop(mark)); - mark += cast_to_oop(mark)->size(); + HeapWord* addr = bottom(); + while (addr < top()) { + oop obj = cast_to_oop(addr); + blk->do_object(obj); + addr += obj->size(); } } diff --git a/src/hotspot/share/gc/shared/space.hpp b/src/hotspot/share/gc/shared/space.hpp index 0f59fcb9f69..bea378db240 100644 --- a/src/hotspot/share/gc/shared/space.hpp +++ b/src/hotspot/share/gc/shared/space.hpp @@ -283,11 +283,6 @@ protected: template void oop_since_save_marks_iterate(OopClosureType* blk); - // Same as object_iterate, but starting from "mark", which is required - // to denote the start of an object. Objects allocated by - // applications of the closure *are* included in the iteration. - virtual void object_iterate_from(HeapWord* mark, ObjectClosure* blk); - // Very inefficient implementation. HeapWord* block_start_const(const void* p) const override; size_t block_size(const HeapWord* p) const override;