diff -r b354ffb03ae4 -r 13c02cc7a6e5 src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Thu Apr 04 12:29:43 2019 -0700 +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Thu Apr 04 21:29:46 2019 +0200 @@ -1795,13 +1795,13 @@ void ShenandoahHeap::stop_concurrent_marking() { assert(is_concurrent_mark_in_progress(), "How else could we get here?"); + set_concurrent_mark_in_progress(false); if (!cancelled_gc()) { // If we needed to update refs, and concurrent marking has been cancelled, // we need to finish updating references. set_has_forwarded_objects(false); mark_complete_marking_context(); } - set_concurrent_mark_in_progress(false); } void ShenandoahHeap::force_satb_flush_all_threads() { @@ -1831,12 +1831,16 @@ } void ShenandoahHeap::set_concurrent_mark_in_progress(bool in_progress) { - set_gc_state_mask(MARKING, in_progress); + if (has_forwarded_objects()) { + set_gc_state_mask(MARKING | UPDATEREFS, in_progress); + } else { + set_gc_state_mask(MARKING, in_progress); + } ShenandoahBarrierSet::satb_mark_queue_set().set_active_all_threads(in_progress, !in_progress); } void ShenandoahHeap::set_concurrent_traversal_in_progress(bool in_progress) { - set_gc_state_mask(TRAVERSAL | HAS_FORWARDED, in_progress); + set_gc_state_mask(TRAVERSAL | HAS_FORWARDED | UPDATEREFS, in_progress); ShenandoahBarrierSet::satb_mark_queue_set().set_active_all_threads(in_progress, !in_progress); }