Skip to content

Commit dc8b95f

Browse files
pengxiaolongshipilev
authored andcommitted
8328075: Shenandoah: Avoid forwarding when objects don't move in full-GC
Backport-of: 80ccc989a892e4d9f4e2c9395a100cfabbdcda64
1 parent 9971c63 commit dc8b95f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,13 @@ class ShenandoahPrepareForCompactionObjectClosure : public ObjectClosure {
359359
_compact_point = _to_region->bottom();
360360
}
361361

362-
// Object fits into current region, record new location:
362+
// Object fits into current region, record new location, if object does not move:
363363
assert(_compact_point + obj_size <= _to_region->end(), "must fit");
364364
shenandoah_assert_not_forwarded(nullptr, p);
365-
_preserved_marks->push_if_necessary(p, p->mark());
366-
p->forward_to(cast_to_oop(_compact_point));
365+
if (_compact_point != cast_from_oop<HeapWord*>(p)) {
366+
_preserved_marks->push_if_necessary(p, p->mark());
367+
p->forward_to(cast_to_oop(_compact_point));
368+
}
367369
_compact_point += obj_size;
368370
}
369371
};
@@ -845,6 +847,7 @@ class ShenandoahCompactObjectsClosure : public ObjectClosure {
845847
if (p->is_forwarded()) {
846848
HeapWord* compact_from = cast_from_oop<HeapWord*>(p);
847849
HeapWord* compact_to = cast_from_oop<HeapWord*>(p->forwardee());
850+
assert(compact_from != compact_to, "Forwarded object should move");
848851
Copy::aligned_conjoint_words(compact_from, compact_to, size);
849852
oop new_obj = cast_to_oop(compact_to);
850853

0 commit comments

Comments
 (0)