< prev index next >

src/share/vm/gc/shenandoah/shenandoahRootProcessor.cpp

Print this page
rev 13387 : [mq]: parallel_sp_cleaning.patch

@@ -29,38 +29,47 @@
 #include "gc/shenandoah/shenandoahRootProcessor.hpp"
 #include "gc/shenandoah/shenandoahHeap.hpp"
 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
 #include "gc/shenandoah/shenandoahPhaseTimes.hpp"
+#include "gc/shenandoah/vm_operations_shenandoah.hpp"
 #include "memory/allocation.inline.hpp"
 #include "runtime/fprofiler.hpp"
 #include "runtime/mutex.hpp"
+#include "runtime/sweeper.hpp"
 #include "services/management.hpp"
 
 ShenandoahRootProcessor::ShenandoahRootProcessor(ShenandoahHeap* heap, uint n_workers,
                                                  ShenandoahCollectorPolicy::TimingPhase phase) :
   _process_strong_tasks(new SubTasksDone(SHENANDOAH_RP_PS_NumElements)),
   _srs(n_workers),
   _phase(phase),
   _codecache_iterator(CodeCache::parallel_iterator()),
-  _om_iterator(ObjectSynchronizer::parallel_iterator())
+  _om_iterator(ObjectSynchronizer::parallel_iterator()),
+  _threads_nmethods_cl(NULL)
 {
   heap->shenandoahPolicy()->record_workers_start(_phase);
+  VM_ShenandoahOperation* op = (VM_ShenandoahOperation*) VMThread::vm_operation();
+  if (! op->_safepoint_cleanup_done) {
+    _threads_nmethods_cl = NMethodSweeper::prepare_mark_active_nmethods();
+  }
 }
 
 ShenandoahRootProcessor::~ShenandoahRootProcessor() {
   delete _process_strong_tasks;
   ShenandoahHeap::heap()->shenandoahPolicy()->record_workers_end(_phase);
+  VM_ShenandoahOperation* op = (VM_ShenandoahOperation*) VMThread::vm_operation();
+  op->_safepoint_cleanup_done = true;
 }
 
 void ShenandoahRootProcessor::process_strong_roots(OopClosure* oops,
                                                    OopClosure* weak_oops,
                                                    CLDClosure* clds,
                                                    CodeBlobClosure* blobs,
                                                    uint worker_id) {
 
-  process_java_roots(oops, clds, NULL, blobs, worker_id);
+  process_java_roots(oops, clds, NULL, NULL, _threads_nmethods_cl, worker_id);
   process_vm_roots(oops, NULL, weak_oops, worker_id);
 
   _process_strong_tasks->all_tasks_completed(n_workers());
 }
 

@@ -69,11 +78,11 @@
                                                 CLDClosure* clds,
                                                 CodeBlobClosure* blobs,
                                                 uint worker_id) {
 
   ShenandoahPhaseTimes* phase_times = ShenandoahHeap::heap()->shenandoahPolicy()->phase_times();
-  process_java_roots(oops, clds, clds, NULL, worker_id);
+  process_java_roots(oops, clds, clds, blobs, _threads_nmethods_cl, worker_id);
   process_vm_roots(oops, oops, weak_oops, worker_id);
 
   if (blobs != NULL) {
     ShenandoahParPhaseTimesTracker timer(phase_times, ShenandoahPhaseTimes::CodeCacheRoots, worker_id);
     _codecache_iterator.parallel_blobs_do(blobs);

@@ -84,10 +93,11 @@
 
 void ShenandoahRootProcessor::process_java_roots(OopClosure* strong_roots,
                                                  CLDClosure* strong_clds,
                                                  CLDClosure* weak_clds,
                                                  CodeBlobClosure* strong_code,
+                                                 CodeBlobClosure* nmethods_cl,
                                                  uint worker_id)
 {
   ShenandoahPhaseTimes* phase_times = ShenandoahHeap::heap()->shenandoahPolicy()->phase_times();
   // Iterating over the CLDG and the Threads are done early to allow us to
   // first process the strong CLDs and nmethods and then, after a barrier,

@@ -99,11 +109,11 @@
 
   {
     ShenandoahParPhaseTimesTracker timer(phase_times, ShenandoahPhaseTimes::ThreadRoots, worker_id);
     bool is_par = n_workers() > 1;
     ResourceMark rm;
-    Threads::possibly_parallel_oops_do(is_par, strong_roots, strong_code);
+    Threads::possibly_parallel_oops_do(is_par, strong_roots, strong_code, nmethods_cl);
   }
 }
 
 void ShenandoahRootProcessor::process_vm_roots(OopClosure* strong_roots,
                                                OopClosure* weak_roots,

@@ -168,18 +178,25 @@
 
 ShenandoahRootEvacuator::ShenandoahRootEvacuator(ShenandoahHeap* heap, uint n_workers, ShenandoahCollectorPolicy::TimingPhase phase) :
   _process_strong_tasks(new SubTasksDone(SHENANDOAH_RP_PS_NumElements)),
   _srs(n_workers),
   _phase(phase),
-  _codecache_iterator(CodeCache::parallel_iterator())
+  _codecache_iterator(CodeCache::parallel_iterator()),
+  _threads_nmethods_cl(NULL)
 {
   heap->shenandoahPolicy()->record_workers_start(_phase);
+  VM_ShenandoahOperation* op = (VM_ShenandoahOperation*) VMThread::vm_operation();
+  if (! op->_safepoint_cleanup_done) {
+    _threads_nmethods_cl = NMethodSweeper::prepare_mark_active_nmethods();
+  }
 }
 
 ShenandoahRootEvacuator::~ShenandoahRootEvacuator() {
   delete _process_strong_tasks;
   ShenandoahHeap::heap()->shenandoahPolicy()->record_workers_end(_phase);
+  VM_ShenandoahOperation* op = (VM_ShenandoahOperation*) VMThread::vm_operation();
+  op->_safepoint_cleanup_done = true;
 }
 
 void ShenandoahRootEvacuator::process_evacuate_roots(OopClosure* oops,
                                                      CodeBlobClosure* blobs,
                                                      uint worker_id) {

@@ -187,11 +204,12 @@
   ShenandoahPhaseTimes* phase_times = ShenandoahHeap::heap()->shenandoahPolicy()->phase_times();
   {
     bool is_par = n_workers() > 1;
     ResourceMark rm;
     ShenandoahParPhaseTimesTracker timer(phase_times, ShenandoahPhaseTimes::ThreadRoots, worker_id);
-    Threads::possibly_parallel_oops_do(is_par, oops, NULL);
+
+    Threads::possibly_parallel_oops_do(is_par, oops, NULL, _threads_nmethods_cl);
   }
 
   {
     ShenandoahParPhaseTimesTracker timer(phase_times, ShenandoahPhaseTimes::CodeCacheRoots, worker_id);
     _codecache_iterator.parallel_blobs_do(blobs);
< prev index next >