< prev index next >

src/share/vm/gc/shared/referenceProcessor.cpp

Print this page
rev 13139 : [mq]: heap7

@@ -33,10 +33,11 @@
 #include "gc/shared/referenceProcessor.inline.hpp"
 #include "logging/log.hpp"
 #include "memory/allocation.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/oop.inline.hpp"
+#include "runtime/heapMonitoring.hpp"
 #include "runtime/java.hpp"
 #include "runtime/jniHandles.hpp"
 
 ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL;
 ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy      = NULL;

@@ -255,13 +256,20 @@
       task_executor->set_single_threaded_mode();
     }
     process_phaseJNI(is_alive, keep_alive, complete_gc);
   }
 
+  size_t handled;
+  {
+    GCTraceTime(Debug, gc, ref) tt("Heap Monitoring Weak Reference", gc_timer);
+    handled = process_phaseHeapSampling(is_alive, keep_alive, complete_gc, task_executor);
+  }
+
   log_debug(gc, ref)("Ref Counts: Soft: " SIZE_FORMAT " Weak: " SIZE_FORMAT " Final: " SIZE_FORMAT " Phantom: " SIZE_FORMAT,
                      stats.soft_count(), stats.weak_count(), stats.final_count(), stats.phantom_count());
   log_develop_trace(gc, ref)("JNI Weak Reference count: " SIZE_FORMAT, count_jni_refs());
+  log_develop_trace(gc, ref)("Heap Sampler Weak Reference handled: " SIZE_FORMAT, handled);
 
   return stats;
 }
 
 #ifndef PRODUCT

@@ -287,10 +295,26 @@
                                           VoidClosure*       complete_gc) {
   JNIHandles::weak_oops_do(is_alive, keep_alive);
   complete_gc->do_void();
 }
 
+size_t ReferenceProcessor::process_phaseHeapSampling(
+    BoolObjectClosure*           is_alive,
+    OopClosure*                  keep_alive,
+    VoidClosure*                 complete_gc,
+    AbstractRefProcTaskExecutor* task_executor) {
+  size_t count = 0;
+  if (HeapMonitoring::enabled()) {
+    if (task_executor != NULL) {
+      task_executor->set_single_threaded_mode();
+    }
+    count = HeapMonitoring::weak_oops_do(is_alive, keep_alive);
+    complete_gc->do_void();
+  }
+  return count;
+}
+
 void ReferenceProcessor::enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor) {
   // Enqueue references that are not made active again, and
   // clear the decks for the next collection (cycle).
   enqueue_discovered_reflists(task_executor);
 
< prev index next >