1349 bool JvmtiExport::hide_single_stepping(JavaThread *thread) {
1350 JvmtiThreadState *state = get_jvmti_thread_state(thread);
1351 if (state != nullptr && state->is_enabled(JVMTI_EVENT_SINGLE_STEP)) {
1352 state->set_hide_single_stepping();
1353 return true;
1354 } else {
1355 return false;
1356 }
1357 }
1358
1359 void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) {
1360 if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1361 return;
1362 }
1363 HandleMark hm(thread);
1364
1365 JvmtiThreadState *state = get_jvmti_thread_state(thread);
1366 if (state == nullptr) {
1367 return;
1368 }
1369 if (thread->is_in_tmp_VTMS_transition()) {
1370 return; // skip ClassLoad events in tmp VTMS transition
1371 }
1372 assert(!thread->is_in_any_VTMS_transition(), "class load events are not allowed in any VTMS transition");
1373
1374 EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Trg Class Load triggered",
1375 JvmtiTrace::safe_get_thread_name(thread)));
1376 JvmtiEnvThreadStateIterator it(state);
1377 for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
1378 if (ets->is_enabled(JVMTI_EVENT_CLASS_LOAD)) {
1379 JvmtiEnv *env = ets->get_env();
1380 if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
1381 continue;
1382 }
1383 EVT_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Evt Class Load sent %s",
1384 JvmtiTrace::safe_get_thread_name(thread),
1385 klass==nullptr? "null" : klass->external_name() ));
1386 JvmtiClassEventMark jem(thread, klass);
1387 JvmtiJavaThreadEventTransition jet(thread);
1388 jvmtiEventClassLoad callback = env->callbacks()->ClassLoad;
1389 if (callback != nullptr) {
1390 (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_class());
1391 }
1392 }
1393 }
1394 }
1395
1396
1397 void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) {
1398 if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1399 return;
1400 }
1401 HandleMark hm(thread);
1402
1403 JvmtiThreadState *state = get_jvmti_thread_state(thread);
1404 if (state == nullptr) {
1405 return;
1406 }
1407 if (thread->is_in_tmp_VTMS_transition()) {
1408 return; // skip ClassPrepare events in tmp VTMS transition
1409 }
1410 assert(!thread->is_in_any_VTMS_transition(), "class prepare events are not allowed in any VTMS transition");
1411
1412 EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Trg Class Prepare triggered",
1413 JvmtiTrace::safe_get_thread_name(thread)));
1414 JvmtiEnvThreadStateIterator it(state);
1415 for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
1416 if (ets->is_enabled(JVMTI_EVENT_CLASS_PREPARE)) {
1417 JvmtiEnv *env = ets->get_env();
1418 if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
1419 continue;
1420 }
1421 EVT_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Evt Class Prepare sent %s",
1422 JvmtiTrace::safe_get_thread_name(thread),
1423 klass==nullptr? "null" : klass->external_name() ));
1424 JvmtiClassEventMark jem(thread, klass);
1425 JvmtiJavaThreadEventTransition jet(thread);
1426 jvmtiEventClassPrepare callback = env->callbacks()->ClassPrepare;
1427 if (callback != nullptr) {
1428 (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_class());
1429 }
1430 }
1661
1662 JvmtiVirtualThreadEventMark jem(thread);
1663 JvmtiJavaThreadEventTransition jet(thread);
1664 jvmtiExtensionEvent callback = env->ext_callbacks()->VirtualThreadMount;
1665 if (callback != nullptr) {
1666 (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread());
1667 }
1668 }
1669 }
1670 }
1671 }
1672
1673 void JvmtiExport::post_vthread_unmount(jobject vthread) {
1674 if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1675 return;
1676 }
1677 JavaThread *thread = JavaThread::current();
1678 HandleMark hm(thread);
1679 EVT_TRIG_TRACE(EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, ("[%p] Trg Virtual Thread Unmount event triggered", vthread));
1680
1681 JvmtiThreadState *state = get_jvmti_thread_state(thread);
1682 if (state == nullptr) {
1683 return;
1684 }
1685
1686 if (state->is_enabled((jvmtiEvent)EXT_EVENT_VIRTUAL_THREAD_UNMOUNT)) {
1687 JvmtiEnvThreadStateIterator it(state);
1688
1689 for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
1690 JvmtiEnv *env = ets->get_env();
1691 if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
1692 continue;
1693 }
1694 if (ets->is_enabled((jvmtiEvent)EXT_EVENT_VIRTUAL_THREAD_UNMOUNT)) {
1695 EVT_TRACE(EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, ("[%p] Evt Virtual Thread Unmount event sent", vthread));
1696
1697 JvmtiVirtualThreadEventMark jem(thread);
1698 JvmtiJavaThreadEventTransition jet(thread);
1699 jvmtiExtensionEvent callback = env->ext_callbacks()->VirtualThreadUnmount;
1700 if (callback != nullptr) {
1701 (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread());
1702 }
1703 }
1704 }
1705 }
1706 }
1707
1708 void JvmtiExport::continuation_yield_cleanup(JavaThread* thread, jint continuation_frame_count) {
1709 if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1710 return;
1711 }
1712
1713 assert(thread == JavaThread::current(), "must be");
1714 JvmtiThreadState *state = get_jvmti_thread_state(thread);
1715 if (state == nullptr) {
1716 return;
1717 }
1718 state->invalidate_cur_stack_depth();
1719
1720 // Clear frame_pop requests in frames popped by yield
1721 if (can_post_frame_pop()) {
|
1349 bool JvmtiExport::hide_single_stepping(JavaThread *thread) {
1350 JvmtiThreadState *state = get_jvmti_thread_state(thread);
1351 if (state != nullptr && state->is_enabled(JVMTI_EVENT_SINGLE_STEP)) {
1352 state->set_hide_single_stepping();
1353 return true;
1354 } else {
1355 return false;
1356 }
1357 }
1358
1359 void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) {
1360 if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1361 return;
1362 }
1363 HandleMark hm(thread);
1364
1365 JvmtiThreadState *state = get_jvmti_thread_state(thread);
1366 if (state == nullptr) {
1367 return;
1368 }
1369 if (thread->is_in_any_VTMS_transition()) {
1370 return; // skip ClassLoad events in VTMS transition
1371 }
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_any_VTMS_transition()) {
1407 return; // skip ClassPrepare events in VTMS transition
1408 }
1409
1410 EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Trg Class Prepare triggered",
1411 JvmtiTrace::safe_get_thread_name(thread)));
1412 JvmtiEnvThreadStateIterator it(state);
1413 for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
1414 if (ets->is_enabled(JVMTI_EVENT_CLASS_PREPARE)) {
1415 JvmtiEnv *env = ets->get_env();
1416 if (env->phase() == JVMTI_PHASE_PRIMORDIAL) {
1417 continue;
1418 }
1419 EVT_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Evt Class Prepare sent %s",
1420 JvmtiTrace::safe_get_thread_name(thread),
1421 klass==nullptr? "null" : klass->external_name() ));
1422 JvmtiClassEventMark jem(thread, klass);
1423 JvmtiJavaThreadEventTransition jet(thread);
1424 jvmtiEventClassPrepare callback = env->callbacks()->ClassPrepare;
1425 if (callback != nullptr) {
1426 (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_class());
1427 }
1428 }
1659
1660 JvmtiVirtualThreadEventMark jem(thread);
1661 JvmtiJavaThreadEventTransition jet(thread);
1662 jvmtiExtensionEvent callback = env->ext_callbacks()->VirtualThreadMount;
1663 if (callback != nullptr) {
1664 (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread());
1665 }
1666 }
1667 }
1668 }
1669 }
1670
1671 void JvmtiExport::post_vthread_unmount(jobject vthread) {
1672 if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) {
1673 return;
1674 }
1675 JavaThread *thread = JavaThread::current();
1676 HandleMark hm(thread);
1677 EVT_TRIG_TRACE(EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, ("[%p] Trg Virtual Thread Unmount event triggered", vthread));
1678
1679 // On preemption JVMTI state rebinding has already happened so get it always direclty from the oop.
1680 JvmtiThreadState *state = java_lang_Thread::jvmti_thread_state(JNIHandles::resolve(vthread));
1681 if (state == NULL) {
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(), vthread);
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()) {
|