8223951: Shenandoah: Only need to update thread roots during final update refs
Reviewed-by: shade
--- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp Fri May 17 08:29:55 2019 -0700
+++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp Fri May 17 11:47:06 2019 -0400
@@ -304,6 +304,34 @@
#endif
}
+class ShenandoahUpdateThreadRootsTask : public AbstractGangTask {
+private:
+ ShenandoahThreadRoots _thread_roots;
+ ShenandoahPhaseTimings::Phase _phase;
+public:
+ ShenandoahUpdateThreadRootsTask(bool is_par, ShenandoahPhaseTimings::Phase phase) :
+ AbstractGangTask("Shenandoah Update Thread Roots"),
+ _thread_roots(is_par),
+ _phase(phase) {
+ ShenandoahHeap::heap()->phase_timings()->record_workers_start(_phase);
+ }
+
+ ~ShenandoahUpdateThreadRootsTask() {
+ ShenandoahHeap::heap()->phase_timings()->record_workers_end(_phase);
+ }
+ void work(uint worker_id) {
+ ShenandoahUpdateRefsClosure cl;
+ _thread_roots.oops_do(&cl, NULL, worker_id);
+ }
+};
+
+void ShenandoahConcurrentMark::update_thread_roots(ShenandoahPhaseTimings::Phase root_phase) {
+ WorkGang* workers = _heap->workers();
+ bool is_par = workers->active_workers() > 1;
+ ShenandoahUpdateThreadRootsTask task(is_par, root_phase);
+ workers->run_task(&task);
+}
+
void ShenandoahConcurrentMark::initialize(uint workers) {
_heap = ShenandoahHeap::heap();
--- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.hpp Fri May 17 08:29:55 2019 -0700
+++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.hpp Fri May 17 11:47:06 2019 -0400
@@ -79,6 +79,7 @@
void mark_roots(ShenandoahPhaseTimings::Phase root_phase);
void update_roots(ShenandoahPhaseTimings::Phase root_phase);
+ void update_thread_roots(ShenandoahPhaseTimings::Phase root_phase);
// ---------- Weak references
//
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Fri May 17 08:29:55 2019 -0700
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Fri May 17 11:47:06 2019 -0400
@@ -2200,9 +2200,11 @@
verifier()->verify_roots_no_forwarded_except(ShenandoahRootVerifier::ThreadRoots);
}
- concurrent_mark()->update_roots(is_degenerated_gc_in_progress() ?
- ShenandoahPhaseTimings::degen_gc_update_roots:
- ShenandoahPhaseTimings::final_update_refs_roots);
+ if (is_degenerated_gc_in_progress()) {
+ concurrent_mark()->update_roots(ShenandoahPhaseTimings::degen_gc_update_roots);
+ } else {
+ concurrent_mark()->update_thread_roots(ShenandoahPhaseTimings::final_update_refs_roots);
+ }
ShenandoahGCPhase final_update_refs(ShenandoahPhaseTimings::final_update_refs_recycle);