@@ -947,11 +947,25 @@ class ShenandoahConcurrentWeakRootsEvacUpdateTask : public WorkerTask {
947947void ShenandoahConcurrentGC::op_weak_roots () {
948948 ShenandoahHeap* const heap = ShenandoahHeap::heap ();
949949 assert (heap->is_concurrent_weak_root_in_progress (), " Only during this phase" );
950- // Concurrent weak root processing
951- ShenandoahTimingsTracker t (ShenandoahPhaseTimings::conc_weak_roots_work);
952- ShenandoahGCWorkerPhase worker_phase (ShenandoahPhaseTimings::conc_weak_roots_work);
953- ShenandoahConcurrentWeakRootsEvacUpdateTask task (ShenandoahPhaseTimings::conc_weak_roots_work);
954- heap->workers ()->run_task (&task);
950+ {
951+ // Concurrent weak root processing
952+ ShenandoahTimingsTracker t (ShenandoahPhaseTimings::conc_weak_roots_work);
953+ ShenandoahGCWorkerPhase worker_phase (ShenandoahPhaseTimings::conc_weak_roots_work);
954+ ShenandoahConcurrentWeakRootsEvacUpdateTask task (ShenandoahPhaseTimings::conc_weak_roots_work);
955+ heap->workers ()->run_task (&task);
956+ }
957+
958+ {
959+ // It is possible for mutators executing the load reference barrier to have
960+ // loaded an oop through a weak handle that has since been nulled out by
961+ // weak root processing. Handshaking here forces them to complete the
962+ // barrier before the GC cycle continues and does something that would
963+ // change the evaluation of the barrier (for example, resetting the TAMS
964+ // on trashed regions could make an oop appear to be marked _after_ the
965+ // region has been recycled).
966+ ShenandoahTimingsTracker t (ShenandoahPhaseTimings::conc_weak_roots_rendezvous);
967+ heap->rendezvous_threads (" Shenandoah Concurrent Weak Roots" );
968+ }
955969}
956970
957971void ShenandoahConcurrentGC::op_class_unloading () {
0 commit comments