< prev index next >

src/hotspot/share/prims/jvmtiEnv.cpp

Print this page
rev 49643 : [mq]: heap8
rev 49644 : [mq]: event_rebased
rev 49646 : [mq]: heap11
rev 49648 : [mq]: heap13

@@ -62,10 +62,11 @@
 #include "runtime/objectMonitor.inline.hpp"
 #include "runtime/osThread.hpp"
 #include "runtime/reflectionUtils.hpp"
 #include "runtime/signature.hpp"
 #include "runtime/thread.inline.hpp"
+#include "runtime/threadHeapSampler.hpp"
 #include "runtime/threadSMR.hpp"
 #include "runtime/timerTrace.hpp"
 #include "runtime/vframe.inline.hpp"
 #include "runtime/vmThread.hpp"
 #include "services/threadService.hpp"

@@ -535,14 +536,21 @@
     }
 
     if (event_type == JVMTI_EVENT_CLASS_FILE_LOAD_HOOK && enabled) {
       record_class_file_load_hook_enabled();
     }
+
+    if (event_type == JVMTI_EVENT_SAMPLED_OBJECT_ALLOC) {
+      if (enabled) {
+        ThreadHeapSampler::enable();
+      } else {
+        ThreadHeapSampler::disable();
+      }
+    }
     JvmtiEventController::set_user_enabled(this, (JavaThread*) NULL, event_type, enabled);
   } else {
     // We have a specified event_thread.
-
     JavaThread* java_thread = NULL;
     ThreadsListHandle tlh;
     jvmtiError err = JvmtiExport::cv_external_thread_to_JavaThread(tlh.list(), event_thread, &java_thread, NULL);
     if (err != JVMTI_ERROR_NONE) {
       return err;

@@ -566,10 +574,18 @@
     }
 
     if (event_type == JVMTI_EVENT_CLASS_FILE_LOAD_HOOK && enabled) {
       record_class_file_load_hook_enabled();
     }
+
+    if (event_type == JVMTI_EVENT_SAMPLED_OBJECT_ALLOC) {
+      if (enabled) {
+        ThreadHeapSampler::enable();
+      } else {
+        ThreadHeapSampler::disable();
+      }
+    }
     JvmtiEventController::set_user_enabled(this, java_thread, event_type, enabled);
   }
 
   return JVMTI_ERROR_NONE;
 } /* end SetEventNotificationMode */

@@ -3629,10 +3645,19 @@
 JvmtiEnv::GetAvailableProcessors(jint* processor_count_ptr) {
   *processor_count_ptr = os::active_processor_count();
   return JVMTI_ERROR_NONE;
 } /* end GetAvailableProcessors */
 
+jvmtiError
+JvmtiEnv::SetHeapSamplingRate(jint sampling_rate) {
+  if (sampling_rate < 0) {
+    return JVMTI_ERROR_ILLEGAL_ARGUMENT;
+  }
+  ThreadHeapSampler::set_sampling_rate(sampling_rate);
+  return JVMTI_ERROR_NONE;
+} /* end SetHeapSamplingRate */
+
   //
   // System Properties functions
   //
 
 // count_ptr - pre-checked for NULL
< prev index next >