< prev index next >

src/hotspot/share/prims/jvmtiExport.cpp

Print this page
rev 52132 : 8201655: Add thread-enabled support for the Heap Sampling
Summary:
Reviewed-by:


2525   Handle h(thread, object);
2526   JvmtiEnvIterator it;
2527   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
2528     if (env->is_enabled(JVMTI_EVENT_VM_OBJECT_ALLOC)) {
2529       EVT_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("[%s] Evt vmobject alloc sent %s",
2530                                          JvmtiTrace::safe_get_thread_name(thread),
2531                                          object==NULL? "NULL" : object->klass()->external_name()));
2532 
2533       JvmtiObjectAllocEventMark jem(thread, h());
2534       JvmtiJavaThreadEventTransition jet(thread);
2535       jvmtiEventVMObjectAlloc callback = env->callbacks()->VMObjectAlloc;
2536       if (callback != NULL) {
2537         (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
2538                     jem.jni_jobject(), jem.jni_class(), jem.size());
2539       }
2540     }
2541   }
2542 }
2543 
2544 void JvmtiExport::post_sampled_object_alloc(JavaThread *thread, oop object) {





2545   EVT_TRIG_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC,
2546                  ("[%s] Trg sampled object alloc triggered",
2547                   JvmtiTrace::safe_get_thread_name(thread)));
2548   if (object == NULL) {
2549     return;
2550   }
2551   HandleMark hm(thread);
2552   Handle h(thread, object);
2553   JvmtiEnvIterator it;
2554   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
2555     if (env->is_enabled(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC)) {

2556       EVT_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC,
2557                 ("[%s] Evt sampled object alloc sent %s",
2558                  JvmtiTrace::safe_get_thread_name(thread),
2559                  object == NULL ? "NULL" : object->klass()->external_name()));
2560 

2561       JvmtiObjectAllocEventMark jem(thread, h());
2562       JvmtiJavaThreadEventTransition jet(thread);
2563       jvmtiEventSampledObjectAlloc callback = env->callbacks()->SampledObjectAlloc;
2564       if (callback != NULL) {
2565         (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
2566                     jem.jni_jobject(), jem.jni_class(), jem.size());
2567       }
2568     }
2569   }
2570 }
2571 
2572 ////////////////////////////////////////////////////////////////////////////////////////////////
2573 
2574 void JvmtiExport::cleanup_thread(JavaThread* thread) {
2575   assert(JavaThread::current() == thread, "thread is not current");
2576   MutexLocker mu(JvmtiThreadState_lock);
2577 
2578   if (thread->jvmti_thread_state() != NULL) {
2579     // This has to happen after the thread state is removed, which is
2580     // why it is not in post_thread_end_event like its complement




2525   Handle h(thread, object);
2526   JvmtiEnvIterator it;
2527   for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) {
2528     if (env->is_enabled(JVMTI_EVENT_VM_OBJECT_ALLOC)) {
2529       EVT_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("[%s] Evt vmobject alloc sent %s",
2530                                          JvmtiTrace::safe_get_thread_name(thread),
2531                                          object==NULL? "NULL" : object->klass()->external_name()));
2532 
2533       JvmtiObjectAllocEventMark jem(thread, h());
2534       JvmtiJavaThreadEventTransition jet(thread);
2535       jvmtiEventVMObjectAlloc callback = env->callbacks()->VMObjectAlloc;
2536       if (callback != NULL) {
2537         (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
2538                     jem.jni_jobject(), jem.jni_class(), jem.size());
2539       }
2540     }
2541   }
2542 }
2543 
2544 void JvmtiExport::post_sampled_object_alloc(JavaThread *thread, oop object) {
2545   JvmtiThreadState *state = thread->jvmti_thread_state();
2546   if (state == NULL) {
2547     return;
2548   }
2549 
2550   EVT_TRIG_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC,
2551                  ("[%s] Trg sampled object alloc triggered",
2552                   JvmtiTrace::safe_get_thread_name(thread)));
2553   if (object == NULL) {
2554     return;
2555   }
2556   HandleMark hm(thread);
2557   Handle h(thread, object);
2558 
2559   JvmtiEnvThreadStateIterator it(state);
2560   for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
2561     if (ets->is_enabled(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC)) {
2562       EVT_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC,
2563                 ("[%s] Evt sampled object alloc sent %s",
2564                  JvmtiTrace::safe_get_thread_name(thread),
2565                  object == NULL ? "NULL" : object->klass()->external_name()));
2566 
2567       JvmtiEnv *env = ets->get_env();
2568       JvmtiObjectAllocEventMark jem(thread, h());
2569       JvmtiJavaThreadEventTransition jet(thread);
2570       jvmtiEventSampledObjectAlloc callback = env->callbacks()->SampledObjectAlloc;
2571       if (callback != NULL) {
2572         (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
2573                     jem.jni_jobject(), jem.jni_class(), jem.size());
2574       }
2575     }
2576   }
2577 }
2578 
2579 ////////////////////////////////////////////////////////////////////////////////////////////////
2580 
2581 void JvmtiExport::cleanup_thread(JavaThread* thread) {
2582   assert(JavaThread::current() == thread, "thread is not current");
2583   MutexLocker mu(JvmtiThreadState_lock);
2584 
2585   if (thread->jvmti_thread_state() != NULL) {
2586     // This has to happen after the thread state is removed, which is
2587     // why it is not in post_thread_end_event like its complement


< prev index next >