< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp

Print this page
rev 59533 : 8246097: Shenandoah: limit parallelism in CLDG root handling
Reviewed-by: XXX


 105 template <typename Closure>
 106 void ShenandoahWeakRoots<false /* concurrent */>::oops_do(Closure* cl, uint worker_id) {
 107   AlwaysTrueClosure always_true;
 108   weak_oops_do<AlwaysTrueClosure, Closure>(&always_true, cl, worker_id);
 109 }
 110 
 111 template <bool CONCURRENT>
 112 ShenandoahVMRoots<CONCURRENT>::ShenandoahVMRoots(ShenandoahPhaseTimings::Phase phase) :
 113   _jni_handle_roots(OopStorageSet::jni_global(), phase, ShenandoahPhaseTimings::JNIRoots),
 114   _vm_global_roots(OopStorageSet::vm_global(), phase, ShenandoahPhaseTimings::VMGlobalRoots) {
 115 }
 116 
 117 template <bool CONCURRENT>
 118 template <typename T>
 119 void ShenandoahVMRoots<CONCURRENT>::oops_do(T* cl, uint worker_id) {
 120   _jni_handle_roots.oops_do(cl, worker_id);
 121   _vm_global_roots.oops_do(cl, worker_id);
 122 }
 123 
 124 template <bool CONCURRENT, bool SINGLE_THREADED>
 125 ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::ShenandoahClassLoaderDataRoots(ShenandoahPhaseTimings::Phase phase) :

 126   _phase(phase) {
 127   if (!SINGLE_THREADED) {
 128     ClassLoaderDataGraph::clear_claimed_marks();
 129   }
 130   if (CONCURRENT) {
 131     ClassLoaderDataGraph_lock->lock();
 132   }
 133 }
 134 
 135 template <bool CONCURRENT, bool SINGLE_THREADED>
 136 ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::~ShenandoahClassLoaderDataRoots() {
 137   if (CONCURRENT) {
 138     ClassLoaderDataGraph_lock->unlock();
 139   }
 140 }
 141 
 142 
 143 template <bool CONCURRENT, bool SINGLE_THREADED>
 144 void ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::always_strong_cld_do(CLDClosure* clds, uint worker_id) {
 145   if (SINGLE_THREADED) {
 146     assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
 147     assert(Thread::current()->is_VM_thread(), "Single threaded CLDG iteration can only be done by VM thread");
 148     ClassLoaderDataGraph::always_strong_cld_do(clds);
 149   } else {
 150     ShenandoahWorkerTimingsTracker timer(_phase, ShenandoahPhaseTimings::CLDGRoots, worker_id);
 151     ClassLoaderDataGraph::always_strong_cld_do(clds);

 152   }
 153 }
 154 
 155 template <bool CONCURRENT, bool SINGLE_THREADED>
 156 void ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::cld_do(CLDClosure* clds, uint worker_id) {
 157   if (SINGLE_THREADED) {
 158     assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
 159     assert(Thread::current()->is_VM_thread(), "Single threaded CLDG iteration can only be done by VM thread");
 160     ClassLoaderDataGraph::cld_do(clds);
 161   } else {
 162     ShenandoahWorkerTimingsTracker timer(_phase, ShenandoahPhaseTimings::CLDGRoots, worker_id);
 163     ClassLoaderDataGraph::cld_do(clds);

 164   }
 165 }
 166 
 167 class ShenandoahParallelOopsDoThreadClosure : public ThreadClosure {
 168 private:
 169   OopClosure* _f;
 170   CodeBlobClosure* _cf;
 171   ThreadClosure* _thread_cl;
 172 public:
 173   ShenandoahParallelOopsDoThreadClosure(OopClosure* f, CodeBlobClosure* cf, ThreadClosure* thread_cl) :
 174     _f(f), _cf(cf), _thread_cl(thread_cl) {}
 175 
 176   void do_thread(Thread* t) {
 177     if (_thread_cl != NULL) {
 178       _thread_cl->do_thread(t);
 179     }
 180     t->oops_do(_f, _cf);
 181   }
 182 };
 183 




 105 template <typename Closure>
 106 void ShenandoahWeakRoots<false /* concurrent */>::oops_do(Closure* cl, uint worker_id) {
 107   AlwaysTrueClosure always_true;
 108   weak_oops_do<AlwaysTrueClosure, Closure>(&always_true, cl, worker_id);
 109 }
 110 
 111 template <bool CONCURRENT>
 112 ShenandoahVMRoots<CONCURRENT>::ShenandoahVMRoots(ShenandoahPhaseTimings::Phase phase) :
 113   _jni_handle_roots(OopStorageSet::jni_global(), phase, ShenandoahPhaseTimings::JNIRoots),
 114   _vm_global_roots(OopStorageSet::vm_global(), phase, ShenandoahPhaseTimings::VMGlobalRoots) {
 115 }
 116 
 117 template <bool CONCURRENT>
 118 template <typename T>
 119 void ShenandoahVMRoots<CONCURRENT>::oops_do(T* cl, uint worker_id) {
 120   _jni_handle_roots.oops_do(cl, worker_id);
 121   _vm_global_roots.oops_do(cl, worker_id);
 122 }
 123 
 124 template <bool CONCURRENT, bool SINGLE_THREADED>
 125 ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::ShenandoahClassLoaderDataRoots(ShenandoahPhaseTimings::Phase phase, uint n_workers) :
 126   _semaphore(worker_count(n_workers)),
 127   _phase(phase) {
 128   if (!SINGLE_THREADED) {
 129     ClassLoaderDataGraph::clear_claimed_marks();
 130   }
 131   if (CONCURRENT) {
 132     ClassLoaderDataGraph_lock->lock();
 133   }
 134 }
 135 
 136 template <bool CONCURRENT, bool SINGLE_THREADED>
 137 ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::~ShenandoahClassLoaderDataRoots() {
 138   if (CONCURRENT) {
 139     ClassLoaderDataGraph_lock->unlock();
 140   }
 141 }
 142 
 143 
 144 template <bool CONCURRENT, bool SINGLE_THREADED>
 145 void ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::always_strong_cld_do(CLDClosure* clds, uint worker_id) {
 146   if (SINGLE_THREADED) {
 147     assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
 148     assert(Thread::current()->is_VM_thread(), "Single threaded CLDG iteration can only be done by VM thread");
 149     ClassLoaderDataGraph::always_strong_cld_do(clds);
 150   } else if (_semaphore.try_acquire()) {
 151     ShenandoahWorkerTimingsTracker timer(_phase, ShenandoahPhaseTimings::CLDGRoots, worker_id);
 152     ClassLoaderDataGraph::always_strong_cld_do(clds);
 153     _semaphore.claim_all();
 154   }
 155 }
 156 
 157 template <bool CONCURRENT, bool SINGLE_THREADED>
 158 void ShenandoahClassLoaderDataRoots<CONCURRENT, SINGLE_THREADED>::cld_do(CLDClosure* clds, uint worker_id) {
 159   if (SINGLE_THREADED) {
 160     assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
 161     assert(Thread::current()->is_VM_thread(), "Single threaded CLDG iteration can only be done by VM thread");
 162     ClassLoaderDataGraph::cld_do(clds);
 163   } else if (_semaphore.try_acquire()) {
 164     ShenandoahWorkerTimingsTracker timer(_phase, ShenandoahPhaseTimings::CLDGRoots, worker_id);
 165     ClassLoaderDataGraph::cld_do(clds);
 166     _semaphore.claim_all();
 167   }
 168 }
 169 
 170 class ShenandoahParallelOopsDoThreadClosure : public ThreadClosure {
 171 private:
 172   OopClosure* _f;
 173   CodeBlobClosure* _cf;
 174   ThreadClosure* _thread_cl;
 175 public:
 176   ShenandoahParallelOopsDoThreadClosure(OopClosure* f, CodeBlobClosure* cf, ThreadClosure* thread_cl) :
 177     _f(f), _cf(cf), _thread_cl(thread_cl) {}
 178 
 179   void do_thread(Thread* t) {
 180     if (_thread_cl != NULL) {
 181       _thread_cl->do_thread(t);
 182     }
 183     t->oops_do(_f, _cf);
 184   }
 185 };
 186 


< prev index next >