< prev index next >

src/hotspot/share/prims/jvmtiExport.cpp

Print this page

1348 bool JvmtiExport::hide_single_stepping(JavaThread *thread) {
1349   JvmtiThreadState *state = get_jvmti_thread_state(thread);
1350   if (state != nullptr && state->is_enabled(JVMTI_EVENT_SINGLE_STEP)) {
1351     state->set_hide_single_stepping();
1352     return true;
1353   } else {
1354     return false;
1355   }
1356 }
1357 
1358 void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) {
1359   if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1360     return;
1361   }
1362   HandleMark hm(thread);
1363 
1364   JvmtiThreadState *state = get_jvmti_thread_state(thread);
1365   if (state == nullptr) {
1366     return;
1367   }
1368   if (thread->is_in_tmp_VTMS_transition()) {
1369     return; // skip ClassLoad events in tmp VTMS transition
1370   }
1371   assert(!thread->is_in_any_VTMS_transition(), "class load events are not allowed in any VTMS transition");
1372 
1373   EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Trg Class Load triggered",
1374                       JvmtiTrace::safe_get_thread_name(thread)));
1375   JvmtiEnvThreadStateIterator it(state);
1376   for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
1377     if (ets->is_enabled(JVMTI_EVENT_CLASS_LOAD)) {
1378       JvmtiEnv *env = ets->get_env();
1379       if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
1380         continue;
1381       }
1382       EVT_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Evt Class Load sent %s",
1383                                          JvmtiTrace::safe_get_thread_name(thread),
1384                                          klass==nullptr? "null" : klass->external_name() ));
1385       JvmtiClassEventMark jem(thread, klass);
1386       JvmtiJavaThreadEventTransition jet(thread);
1387       jvmtiEventClassLoad callback = env->callbacks()->ClassLoad;
1388       if (callback != nullptr) {
1389         (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_class());
1390       }
1391     }
1392   }
1393 }
1394 
1395 
1396 void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) {
1397   if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1398     return;
1399   }
1400   HandleMark hm(thread);
1401 
1402   JvmtiThreadState *state = get_jvmti_thread_state(thread);
1403   if (state == nullptr) {
1404     return;
1405   }
1406   if (thread->is_in_tmp_VTMS_transition()) {
1407     return; // skip ClassPrepare events in tmp VTMS transition
1408   }
1409   assert(!thread->is_in_any_VTMS_transition(), "class prepare events are not allowed in any VTMS transition");
1410 
1411   EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Trg Class Prepare triggered",
1412                       JvmtiTrace::safe_get_thread_name(thread)));
1413   JvmtiEnvThreadStateIterator it(state);
1414   for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
1415     if (ets->is_enabled(JVMTI_EVENT_CLASS_PREPARE)) {
1416       JvmtiEnv *env = ets->get_env();
1417       if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
1418         continue;
1419       }
1420       EVT_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Evt Class Prepare sent %s",
1421                                             JvmtiTrace::safe_get_thread_name(thread),
1422                                             klass==nullptr? "null" : klass->external_name() ));
1423       JvmtiClassEventMark jem(thread, klass);
1424       JvmtiJavaThreadEventTransition jet(thread);
1425       jvmtiEventClassPrepare callback = env->callbacks()->ClassPrepare;
1426       if (callback != nullptr) {
1427         (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_class());
1428       }
1429     }

1660 
1661         JvmtiVirtualThreadEventMark jem(thread);
1662         JvmtiJavaThreadEventTransition jet(thread);
1663         jvmtiExtensionEvent callback = env->ext_callbacks()->VirtualThreadMount;
1664         if (callback != nullptr) {
1665           (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread());
1666         }
1667       }
1668     }
1669   }
1670 }
1671 
1672 void JvmtiExport::post_vthread_unmount(jobject vthread) {
1673   if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1674     return;
1675   }
1676   JavaThread *thread = JavaThread::current();
1677   HandleMark hm(thread);
1678   EVT_TRIG_TRACE(EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, ("[%p] Trg Virtual Thread Unmount event triggered", vthread));
1679 
1680   JvmtiThreadState *state = get_jvmti_thread_state(thread);
1681   if (state == nullptr) {

1682     return;
1683   }
1684 
1685   if (state->is_enabled((jvmtiEvent)EXT_EVENT_VIRTUAL_THREAD_UNMOUNT)) {
1686     JvmtiEnvThreadStateIterator it(state);
1687 
1688     for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
1689       JvmtiEnv *env = ets->get_env();
1690       if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
1691         continue;
1692       }
1693       if (ets->is_enabled((jvmtiEvent)EXT_EVENT_VIRTUAL_THREAD_UNMOUNT)) {
1694         EVT_TRACE(EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, ("[%p] Evt Virtual Thread Unmount event sent", vthread));
1695 
1696         JvmtiVirtualThreadEventMark jem(thread);
1697         JvmtiJavaThreadEventTransition jet(thread);
1698         jvmtiExtensionEvent callback = env->ext_callbacks()->VirtualThreadUnmount;
1699         if (callback != nullptr) {
1700           (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread());
1701         }
1702       }
1703     }
1704   }
1705 }
1706 
1707 void JvmtiExport::continuation_yield_cleanup(JavaThread* thread, jint continuation_frame_count) {
1708   if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1709     return;
1710   }
1711 
1712   assert(thread == JavaThread::current(), "must be");
1713   JvmtiThreadState *state = get_jvmti_thread_state(thread);
1714   if (state == nullptr) {
1715     return;
1716   }
1717   state->invalidate_cur_stack_depth();
1718 
1719   // Clear frame_pop requests in frames popped by yield
1720   if (can_post_frame_pop()) {

1348 bool JvmtiExport::hide_single_stepping(JavaThread *thread) {
1349   JvmtiThreadState *state = get_jvmti_thread_state(thread);
1350   if (state != nullptr && state->is_enabled(JVMTI_EVENT_SINGLE_STEP)) {
1351     state->set_hide_single_stepping();
1352     return true;
1353   } else {
1354     return false;
1355   }
1356 }
1357 
1358 void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) {
1359   if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1360     return;
1361   }
1362   HandleMark hm(thread);
1363 
1364   JvmtiThreadState *state = get_jvmti_thread_state(thread);
1365   if (state == nullptr) {
1366     return;
1367   }
1368   if (thread->is_in_any_VTMS_transition()) {
1369     return; // skip ClassLoad events in VTMS transition
1370   }

1371 
1372   EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Trg Class Load triggered",
1373                       JvmtiTrace::safe_get_thread_name(thread)));
1374   JvmtiEnvThreadStateIterator it(state);
1375   for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
1376     if (ets->is_enabled(JVMTI_EVENT_CLASS_LOAD)) {
1377       JvmtiEnv *env = ets->get_env();
1378       if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
1379         continue;
1380       }
1381       EVT_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Evt Class Load sent %s",
1382                                          JvmtiTrace::safe_get_thread_name(thread),
1383                                          klass==nullptr? "null" : klass->external_name() ));
1384       JvmtiClassEventMark jem(thread, klass);
1385       JvmtiJavaThreadEventTransition jet(thread);
1386       jvmtiEventClassLoad callback = env->callbacks()->ClassLoad;
1387       if (callback != nullptr) {
1388         (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_class());
1389       }
1390     }
1391   }
1392 }
1393 
1394 
1395 void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) {
1396   if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1397     return;
1398   }
1399   HandleMark hm(thread);
1400 
1401   JvmtiThreadState *state = get_jvmti_thread_state(thread);
1402   if (state == nullptr) {
1403     return;
1404   }
1405   if (thread->is_in_any_VTMS_transition()) {
1406     return; // skip ClassPrepare events in VTMS transition
1407   }

1408 
1409   EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Trg Class Prepare triggered",
1410                       JvmtiTrace::safe_get_thread_name(thread)));
1411   JvmtiEnvThreadStateIterator it(state);
1412   for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
1413     if (ets->is_enabled(JVMTI_EVENT_CLASS_PREPARE)) {
1414       JvmtiEnv *env = ets->get_env();
1415       if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
1416         continue;
1417       }
1418       EVT_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Evt Class Prepare sent %s",
1419                                             JvmtiTrace::safe_get_thread_name(thread),
1420                                             klass==nullptr? "null" : klass->external_name() ));
1421       JvmtiClassEventMark jem(thread, klass);
1422       JvmtiJavaThreadEventTransition jet(thread);
1423       jvmtiEventClassPrepare callback = env->callbacks()->ClassPrepare;
1424       if (callback != nullptr) {
1425         (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_class());
1426       }
1427     }

1658 
1659         JvmtiVirtualThreadEventMark jem(thread);
1660         JvmtiJavaThreadEventTransition jet(thread);
1661         jvmtiExtensionEvent callback = env->ext_callbacks()->VirtualThreadMount;
1662         if (callback != nullptr) {
1663           (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread());
1664         }
1665       }
1666     }
1667   }
1668 }
1669 
1670 void JvmtiExport::post_vthread_unmount(jobject vthread) {
1671   if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1672     return;
1673   }
1674   JavaThread *thread = JavaThread::current();
1675   HandleMark hm(thread);
1676   EVT_TRIG_TRACE(EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, ("[%p] Trg Virtual Thread Unmount event triggered", vthread));
1677 
1678   // On preemption JVMTI state rebinding has already happened so get it always direclty from the oop.
1679   JvmtiThreadState *state = java_lang_Thread::jvmti_thread_state(JNIHandles::resolve(vthread));
1680   if (state == NULL) {
1681     return;
1682   }
1683 
1684   if (state->is_enabled((jvmtiEvent)EXT_EVENT_VIRTUAL_THREAD_UNMOUNT)) {
1685     JvmtiEnvThreadStateIterator it(state);
1686 
1687     for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
1688       JvmtiEnv *env = ets->get_env();
1689       if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
1690         continue;
1691       }
1692       if (ets->is_enabled((jvmtiEvent)EXT_EVENT_VIRTUAL_THREAD_UNMOUNT)) {
1693         EVT_TRACE(EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, ("[%p] Evt Virtual Thread Unmount event sent", vthread));
1694 
1695         JvmtiVirtualThreadEventMark jem(thread);
1696         JvmtiJavaThreadEventTransition jet(thread);
1697         jvmtiExtensionEvent callback = env->ext_callbacks()->VirtualThreadUnmount;
1698         if (callback != nullptr) {
1699           (*callback)(env->jvmti_external(), jem.jni_env(), vthread);
1700         }
1701       }
1702     }
1703   }
1704 }
1705 
1706 void JvmtiExport::continuation_yield_cleanup(JavaThread* thread, jint continuation_frame_count) {
1707   if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1708     return;
1709   }
1710 
1711   assert(thread == JavaThread::current(), "must be");
1712   JvmtiThreadState *state = get_jvmti_thread_state(thread);
1713   if (state == nullptr) {
1714     return;
1715   }
1716   state->invalidate_cur_stack_depth();
1717 
1718   // Clear frame_pop requests in frames popped by yield
1719   if (can_post_frame_pop()) {
< prev index next >