diff --git a/src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp b/src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp index 51903a60fb4..2291015edc6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp @@ -77,18 +77,6 @@ public: inline void do_nmethod(nmethod* nm); }; -class ShenandoahUpdateRefsClosure: public ShenandoahOopClosureBase { -private: - ShenandoahHeap* _heap; -public: - inline ShenandoahUpdateRefsClosure(); - inline void do_oop(oop* p); - inline void do_oop(narrowOop* p); -private: - template - inline void do_oop_work(T* p); -}; - template class ShenandoahEvacuateUpdateRootClosureBase : public ShenandoahOopClosureBase { protected: diff --git a/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp index befc0d7c1f1..53921be8d20 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp @@ -97,18 +97,6 @@ void ShenandoahKeepAliveClosure::do_oop_work(T* p) { } } -ShenandoahUpdateRefsClosure::ShenandoahUpdateRefsClosure() : - _heap(ShenandoahHeap::heap()) { -} - -template -void ShenandoahUpdateRefsClosure::do_oop_work(T* p) { - _heap->update_with_forwarded(p); -} - -void ShenandoahUpdateRefsClosure::do_oop(oop* p) { do_oop_work(p); } -void ShenandoahUpdateRefsClosure::do_oop(narrowOop* p) { do_oop_work(p); } - template ShenandoahEvacuateUpdateRootClosureBase::ShenandoahEvacuateUpdateRootClosureBase() : _heap(ShenandoahHeap::heap()), _thread(stable_thread ? Thread::current() : nullptr) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp index ed40fecfc1d..6da2d2e83f7 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp @@ -931,7 +931,10 @@ void ShenandoahConcurrentGC::op_updaterefs() { class ShenandoahUpdateThreadClosure : public HandshakeClosure { private: - ShenandoahUpdateRefsClosure _cl; + // This closure runs when thread is stopped for handshake, which means + // we can use non-concurrent closure here, as long as it only updates + // locations modified by the thread itself, i.e. stack locations. + ShenandoahNonConcUpdateRefsClosure _cl; public: ShenandoahUpdateThreadClosure(); void do_thread(Thread* thread); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp index 922f54edf3c..6195f445f7b 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp @@ -29,6 +29,7 @@ #include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahGC.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" +#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" @@ -66,13 +67,13 @@ public: assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint"); ShenandoahParallelWorkerSession worker_session(worker_id); - ShenandoahUpdateRefsClosure cl; + ShenandoahNonConcUpdateRefsClosure cl; if (_check_alive) { ShenandoahForwardedIsAliveClosure is_alive; - _root_updater->roots_do(worker_id, &is_alive, &cl); + _root_updater->roots_do(worker_id, &is_alive, &cl); } else { - AlwaysTrueClosure always_true;; - _root_updater->roots_do(worker_id, &always_true, &cl); + AlwaysTrueClosure always_true; + _root_updater->roots_do(worker_id, &always_true, &cl); } } }; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index 7ae4a1cf8b3..e94f43b8886 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -2012,8 +2012,8 @@ void ShenandoahHeap::stw_process_weak_roots(bool full_gc) { // Cleanup weak roots if (has_forwarded_objects()) { ShenandoahForwardedIsAliveClosure is_alive; - ShenandoahUpdateRefsClosure keep_alive; - ShenandoahParallelWeakRootsCleaningTask + ShenandoahNonConcUpdateRefsClosure keep_alive; + ShenandoahParallelWeakRootsCleaningTask cleaning_task(timing_phase, &is_alive, &keep_alive, num_workers); _workers->run_task(&cleaning_task); } else { @@ -2197,7 +2197,7 @@ public: do_work(worker_id); } else { ShenandoahParallelWorkerSession worker_session(worker_id); - do_work(worker_id); + do_work(worker_id); } } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp index 1ee1f9dfc88..a3e0b9397da 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp @@ -660,7 +660,7 @@ public: inline void conc_update_with_forwarded(T* p); template - inline void update_with_forwarded(T* p); + inline void non_conc_update_with_forwarded(T* p); static inline void atomic_update_oop(oop update, oop* addr, oop compare); static inline void atomic_update_oop(oop update, narrowOop* addr, oop compare); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp index f2cc602d8cb..cd2cc2eb209 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp @@ -108,7 +108,7 @@ inline void ShenandoahHeap::leave_evacuation(Thread* t) { } template -inline void ShenandoahHeap::update_with_forwarded(T* p) { +inline void ShenandoahHeap::non_conc_update_with_forwarded(T* p) { T o = RawAccess<>::oop_load(p); if (!CompressedOops::is_null(o)) { oop obj = CompressedOops::decode_not_null(o); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp index e6baa4096f0..a2869b6ead6 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp @@ -94,7 +94,6 @@ public: virtual void do_oop(oop* p) { do_oop_work(p); } }; - class ShenandoahUpdateRefsSuperClosure : public ShenandoahOopClosureBase { protected: ShenandoahHeap* _heap; @@ -103,15 +102,13 @@ public: ShenandoahUpdateRefsSuperClosure() : _heap(ShenandoahHeap::heap()) {} }; -class ShenandoahSTWUpdateRefsClosure : public ShenandoahUpdateRefsSuperClosure { +class ShenandoahNonConcUpdateRefsClosure : public ShenandoahUpdateRefsSuperClosure { private: template inline void work(T* p); public: - ShenandoahSTWUpdateRefsClosure() : ShenandoahUpdateRefsSuperClosure() { - assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must only be used at safepoints"); - } + ShenandoahNonConcUpdateRefsClosure() : ShenandoahUpdateRefsSuperClosure() {} virtual void do_oop(narrowOop* p) { work(p); } virtual void do_oop(oop* p) { work(p); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp index e0662c24462..e614893aab9 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp @@ -39,15 +39,15 @@ template template inline void ShenandoahMarkUpdateRefsClosure::work(T* p) { // Update the location - _heap->update_with_forwarded(p); + _heap->non_conc_update_with_forwarded(p); // ...then do the usual thing ShenandoahMarkRefsSuperClosure::work(p); } template -inline void ShenandoahSTWUpdateRefsClosure::work(T* p) { - _heap->update_with_forwarded(p); +inline void ShenandoahNonConcUpdateRefsClosure::work(T* p) { + _heap->non_conc_update_with_forwarded(p); } template