File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed
src/hotspot/share/gc/parallel Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -232,11 +232,36 @@ void MutableSpace::oop_iterate(OopIterateClosure* cl) {
232232 }
233233}
234234
235- void MutableSpace::object_iterate (ObjectClosure* cl) {
235+ template <bool COMPACT_HEADERS>
236+ void MutableSpace::object_iterate_impl (ObjectClosure* cl) {
236237 HeapWord* p = bottom ();
237238 while (p < top ()) {
238- cl->do_object (cast_to_oop (p));
239- p += cast_to_oop (p)->size ();
239+ oop obj = cast_to_oop (p);
240+ // When promotion-failure occurs during Young GC, eden/from space is not cleared,
241+ // so we can encounter objects with "forwarded" markword.
242+ // They are essentially dead, so skipping them
243+ if (!obj->is_forwarded ()) {
244+ cl->do_object (obj);
245+ p += obj->size ();
246+ } else {
247+ assert (obj->forwardee () != obj, " must not be self-forwarded" );
248+ if (COMPACT_HEADERS) {
249+ // It is safe to use the forwardee here. Parallel GC only uses
250+ // header-based forwarding during promotion. Full GC doesn't
251+ // use the object header for forwarding at all.
252+ p += obj->forwardee ()->size ();
253+ } else {
254+ p += obj->size ();
255+ }
256+ }
257+ }
258+ }
259+
260+ void MutableSpace::object_iterate (ObjectClosure* cl) {
261+ if (UseCompactObjectHeaders) {
262+ object_iterate_impl<true >(cl);
263+ } else {
264+ object_iterate_impl<false >(cl);
240265 }
241266}
242267
Original file line number Diff line number Diff line change @@ -67,6 +67,9 @@ class MutableSpace: public CHeapObj<mtGC> {
6767 void set_last_setup_region (MemRegion mr) { _last_setup_region = mr; }
6868 MemRegion last_setup_region () const { return _last_setup_region; }
6969
70+ template <bool COMPACT_HEADERS>
71+ void object_iterate_impl (ObjectClosure* cl);
72+
7073 public:
7174 virtual ~MutableSpace ();
7275 MutableSpace (size_t page_size);
You can’t perform that action at this time.
0 commit comments