changeset 7466:8a704517c74e

Added flag to turn off weakref processing.
author Roman Kennke <rkennke@redhat.com>
date Thu, 12 Feb 2015 21:42:09 +0100
parents 2868d01310a4
children b581d6e6b640
files src/share/vm/gc_implementation/shenandoah/shenandoahCollectorPolicy.cpp src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentMark.cpp src/share/vm/gc_implementation/shenandoah/shenandoahHeap.cpp src/share/vm/runtime/globals.hpp
diffstat 4 files changed, 35 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahCollectorPolicy.cpp	Thu Feb 12 17:33:38 2015 +0100
+++ b/src/share/vm/gc_implementation/shenandoah/shenandoahCollectorPolicy.cpp	Thu Feb 12 21:42:09 2015 +0100
@@ -501,7 +501,9 @@
   print_summary_sd("Drain SATB", 2, &(_timing_data[drain_satb]._ms));
   print_summary_sd("Drain Overflow", 2, &(_timing_data[drain_overflow]._ms));
   print_summary_sd("Drain Queues", 2, &(_timing_data[drain_queues]._ms));
-  print_summary_sd("Weak References", 2, &(_timing_data[weakrefs]._ms));
+  if (ShenandoahProcessReferences) {
+    print_summary_sd("Weak References", 2, &(_timing_data[weakrefs]._ms));
+  }
   print_summary_sd("Prepare Evacuation", 2, &(_timing_data[prepare_evac]._ms));
   print_summary_sd("Initial Evacuation", 2, &(_timing_data[init_evac]._ms));
 
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentMark.cpp	Thu Feb 12 17:33:38 2015 +0100
+++ b/src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentMark.cpp	Thu Feb 12 21:42:09 2015 +0100
@@ -303,11 +303,11 @@
     ShenandoahMarkRootsTask mark_roots(update_refs);
     heap->workers()->run_task(&mark_roots);
     heap->set_par_threads(0); // Prepare for serial processing in future calls to process_strong_roots.
-
-    ReferenceProcessor* rp = heap->ref_processor_cm();
-    ShenandoahMarkRefsNoUpdateClosure rootsCl2(0);
-    rp->weak_oops_do(&rootsCl2);
-
+    if (ShenandoahProcessReferences) {
+      ReferenceProcessor* rp = heap->ref_processor_cm();
+      ShenandoahMarkRefsNoUpdateClosure rootsCl2(0);
+      rp->weak_oops_do(&rootsCl2);
+    }
   } else {
     ExtendedOopClosure* cl;
     ShenandoahMarkRefsClosure rootsCl1(0);
@@ -393,12 +393,12 @@
 
   uint max_workers = full_gc ? _max_worker_id : _max_conc_worker_id;
   ParallelTaskTerminator terminator(max_workers, _task_queues);
-  ReferenceProcessor* rp = sh->ref_processor_cm();
-  
-  // enable ("weak") refs discovery
-  rp->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
-  rp->setup_policy(false); // snapshot the soft ref policy to be used in this cycle
-
+  if (ShenandoahProcessReferences) {
+    ReferenceProcessor* rp = sh->ref_processor_cm();
+    // enable ("weak") refs discovery
+    rp->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
+    rp->setup_policy(false); // snapshot the soft ref policy to be used in this cycle
+  }
   
   SCMConcurrentMarkingTask markingTask = SCMConcurrentMarkingTask(this, &terminator, update_refs);
 
@@ -503,12 +503,14 @@
 #endif
 
   // When we're done marking everything, we process weak references.
-  if (! full_gc) {
-    sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::weakrefs);
-  }
-  weak_refs_work();
-  if (! full_gc) {
-    sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::weakrefs);
+  if (ShenandoahProcessReferences) {
+    if (! full_gc) {
+      sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::weakrefs);
+    }
+    weak_refs_work();
+    if (! full_gc) {
+      sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::weakrefs);
+    }
   }
 
 #ifdef ASSERT
--- a/src/share/vm/gc_implementation/shenandoah/shenandoahHeap.cpp	Thu Feb 12 17:33:38 2015 +0100
+++ b/src/share/vm/gc_implementation/shenandoah/shenandoahHeap.cpp	Thu Feb 12 21:42:09 2015 +0100
@@ -257,7 +257,10 @@
   gc_threads_do(&init_gclabs);
 
   _scm->initialize();
-  ref_processing_init();
+
+  if (ShenandoahProcessReferences) {
+    ref_processing_init();
+  }
 }
 
 class CalculateUsedRegionClosure : public ShenandoahHeapRegionClosure {
@@ -1251,7 +1254,9 @@
     ShenandoahHeap* heap = ShenandoahHeap::heap();
     ResourceMark rm;
     heap->process_all_roots(false, SharedHeap::SO_AllCodeCache, &cl, &cldCl, &blobsCl);
-    heap->ref_processor_cm()->weak_oops_do(&cl);
+    if (ShenandoahProcessReferences) {
+      heap->ref_processor_cm()->weak_oops_do(&cl);
+    }
     heap->process_weak_roots(&cl);
 
   }
@@ -1423,7 +1428,9 @@
 }
 
 void ShenandoahHeap::weak_roots_iterate(ExtendedOopClosure* cl) {
-  ref_processor_cm()->weak_oops_do(cl);
+  if (ShenandoahProcessReferences) {
+    ref_processor_cm()->weak_oops_do(cl);
+  }
   process_weak_roots(cl);
 }
 
--- a/src/share/vm/runtime/globals.hpp	Thu Feb 12 17:33:38 2015 +0100
+++ b/src/share/vm/runtime/globals.hpp	Thu Feb 12 21:42:09 2015 +0100
@@ -1443,6 +1443,9 @@
   develop(bool, ShenandoahTraceTLabs, false,                                \
           "Trace TLabs in Shenandoah Heap")                                 \
                                                                             \
+  product(bool, ShenandoahProcessReferences, true,                          \
+          "Enable processing of (soft/weak/..) references in Shenandoah")   \
+                                                                            \
   develop(bool, ShenandoahTraceWeakReferences, false,                       \
           "Trace Weak Reference Processing in Shenandoah Heap")             \
                                                                             \