8355631: The events might be generated after VM_DEATH event

Reviewed-by: sspitsyn, dholmes
This commit is contained in:
Leonid Mesnik 2025-10-28 23:50:04 +00:00
parent 73f93920b9
commit 723d6f83a2
4 changed files with 121 additions and 42 deletions

View File

@ -495,6 +495,10 @@ JvmtiEventControllerPrivate::recompute_env_enabled(JvmtiEnvBase* env) {
break;
}
if (JvmtiEventController::is_execution_finished()) {
now_enabled &= VM_DEATH_BIT;
}
// Set/reset the event enabled under the tagmap lock.
set_enabled_events_with_lock(env, now_enabled);
@ -537,6 +541,10 @@ JvmtiEventControllerPrivate::recompute_env_thread_enabled(JvmtiEnvThreadState* e
break;
}
if (JvmtiEventController::is_execution_finished()) {
now_enabled &= VM_DEATH_BIT;
}
// if anything changed do update
if (now_enabled != was_enabled) {
@ -1047,7 +1055,7 @@ JvmtiEventControllerPrivate::vm_init() {
void
JvmtiEventControllerPrivate::vm_death() {
// events are disabled (phase has changed)
// events are disabled, see JvmtiEventController::_execution_finished
JvmtiEventControllerPrivate::recompute_enabled();
}
@ -1059,6 +1067,9 @@ JvmtiEventControllerPrivate::vm_death() {
JvmtiEventEnabled JvmtiEventController::_universal_global_event_enabled;
volatile bool JvmtiEventController::_execution_finished = false;
volatile int JvmtiEventController::_in_callback_count = 0;
bool
JvmtiEventController::is_global_event(jvmtiEvent event_type) {
assert(is_valid_event_type(event_type), "invalid event type");
@ -1207,8 +1218,23 @@ JvmtiEventController::vm_init() {
void
JvmtiEventController::vm_death() {
// No new event callbacks except vm_death can be called after this point.
AtomicAccess::store(&_execution_finished, true);
if (JvmtiEnvBase::environments_might_exist()) {
MutexLocker mu(JvmtiThreadState_lock);
JvmtiEventControllerPrivate::vm_death();
}
}
// Some events might be still in callback for daemons and VM internal threads.
const double start = os::elapsedTime();
const double max_wait_time = 60;
// The first time we see the callback count reach zero we know all actual
// callbacks are complete. The count could rise again, but those "callbacks"
// will immediately see `execution_finished()` and return (dropping the count).
while (in_callback_count() > 0) {
os::naked_short_sleep(100);
if (os::elapsedTime() - start > max_wait_time) {
break;
}
}
}

View File

@ -197,6 +197,11 @@ private:
// for all environments, global array indexed by jvmtiEvent
static JvmtiEventEnabled _universal_global_event_enabled;
// These fields are used to synchronize stop posting events and
// wait until already executing callbacks are finished.
volatile static bool _execution_finished;
volatile static int _in_callback_count;
public:
static bool is_enabled(jvmtiEvent event_type);
@ -245,6 +250,10 @@ public:
static void vm_start();
static void vm_init();
static void vm_death();
static bool is_execution_finished();
static void inc_in_callback_count();
static void dec_in_callback_count();
static int in_callback_count();
};
#endif // SHARE_PRIMS_JVMTIEVENTCONTROLLER_HPP

View File

@ -108,4 +108,22 @@ inline bool JvmtiEventController::is_enabled(jvmtiEvent event_type) {
return _universal_global_event_enabled.is_enabled(event_type);
}
inline bool JvmtiEventController::is_execution_finished() {
return AtomicAccess::load(&_execution_finished);
}
inline void JvmtiEventController::inc_in_callback_count() {
AtomicAccess::inc(&_in_callback_count);
}
inline void JvmtiEventController::dec_in_callback_count() {
AtomicAccess::dec(&_in_callback_count);
}
inline int JvmtiEventController::in_callback_count() {
int result = AtomicAccess::load(&_in_callback_count);
assert(result >= 0, "Should be positive");
return result;
}
#endif // SHARE_PRIMS_JVMTIEVENTCONTROLLER_INLINE_HPP

View File

@ -97,7 +97,12 @@ public:
JvmtiJavaThreadEventTransition(JavaThread *thread) :
_rm(),
_transition(thread),
_hm(thread) {};
_hm(thread) {
JvmtiEventController::inc_in_callback_count();
};
~JvmtiJavaThreadEventTransition() {
JvmtiEventController::dec_in_callback_count();
}
};
// For JavaThreads which are not in _thread_in_vm state
@ -111,6 +116,7 @@ private:
public:
JvmtiThreadEventTransition(Thread *thread) : _rm(), _hm(thread) {
JvmtiEventController::inc_in_callback_count();
if (thread->is_Java_thread()) {
_jthread = JavaThread::cast(thread);
_saved_state = _jthread->thread_state();
@ -125,11 +131,26 @@ public:
}
~JvmtiThreadEventTransition() {
if (_jthread != nullptr)
if (_jthread != nullptr) {
ThreadStateTransition::transition_from_native(_jthread, _saved_state);
}
JvmtiEventController::dec_in_callback_count();
}
};
// The JVMTI_...__BLOCK are used to ensure that vm_death is the last posted event.
// The callbacks are not executed after _execution_finished is set to true
// and the _in_callback_count contains the number of callbacks still in progress.
#define JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread) \
JvmtiJavaThreadEventTransition jet(thread); \
if (JvmtiEventController::is_execution_finished()) {\
return; \
}
#define JVMTI_THREAD_EVENT_CALLBACK_BLOCK(thread) \
JvmtiThreadEventTransition jet(thread); \
if (JvmtiEventController::is_execution_finished()) { \
return; \
}
///////////////////////////////////////////////////////////////
//
@ -662,7 +683,7 @@ void JvmtiExport::post_early_vm_start() {
EVT_TRACE(JVMTI_EVENT_VM_START, ("Evt Early VM start event sent" ));
JavaThread *thread = JavaThread::current();
JvmtiThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventVMStart callback = env->callbacks()->VMStart;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env());
@ -691,7 +712,7 @@ void JvmtiExport::post_vm_start() {
EVT_TRACE(JVMTI_EVENT_VM_START, ("Evt VM start event sent" ));
JvmtiThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventVMStart callback = env->callbacks()->VMStart;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env());
@ -741,7 +762,7 @@ void JvmtiExport::post_vm_initialized() {
JavaThread *thread = JavaThread::current();
JvmtiThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventVMInit callback = env->callbacks()->VMInit;
if (callback != nullptr) {
// We map the JvmtiEnv to its Agent to measure when and for how long
@ -769,6 +790,11 @@ void JvmtiExport::post_vm_death() {
JvmtiTagMap::flush_all_object_free_events();
// It is needed to disable event generation before setting DEAD phase and wait
// until already executing events are finished.
// The VM_DEATH should be the last posted event.
JvmtiEventController::vm_death();
JvmtiEnvIterator it;
for (JvmtiEnv* env = it.first(); env != nullptr; env = it.next(env)) {
if (env->is_enabled(JVMTI_EVENT_VM_DEATH)) {
@ -776,6 +802,7 @@ void JvmtiExport::post_vm_death() {
JavaThread *thread = JavaThread::current();
JvmtiEventMark jem(thread);
// JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK must not be used here
JvmtiJavaThreadEventTransition jet(thread);
jvmtiEventVMDeath callback = env->callbacks()->VMDeath;
if (callback != nullptr) {
@ -785,7 +812,6 @@ void JvmtiExport::post_vm_death() {
}
JvmtiEnvBase::set_phase(JVMTI_PHASE_DEAD);
JvmtiEventController::vm_death();
}
char**
@ -967,7 +993,7 @@ class JvmtiClassFileLoadHookPoster : public StackObj {
JvmtiClassFileLoadEventMark jem(_thread, _h_name, _class_loader,
_h_protection_domain,
_class_being_redefined);
JvmtiJavaThreadEventTransition jet(_thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(_thread)
jvmtiEventClassFileLoadHook callback = env->callbacks()->ClassFileLoadHook;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(),
@ -1177,7 +1203,7 @@ void JvmtiExport::post_compiled_method_unload(
ResourceMark rm(thread);
JvmtiEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventCompiledMethodUnload callback = env->callbacks()->CompiledMethodUnload;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), method, code_begin);
@ -1219,7 +1245,7 @@ void JvmtiExport::post_raw_breakpoint(JavaThread *thread, Method* method, addres
JvmtiEnv *env = ets->get_env();
JvmtiLocationEventMark jem(thread, mh, location);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventBreakpoint callback = env->callbacks()->Breakpoint;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
@ -1360,7 +1386,7 @@ void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) {
JvmtiTrace::safe_get_thread_name(thread),
klass==nullptr? "null" : klass->external_name() ));
JvmtiClassEventMark jem(thread, klass);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventClassLoad callback = env->callbacks()->ClassLoad;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_class());
@ -1401,7 +1427,7 @@ void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) {
JvmtiTrace::safe_get_thread_name(thread),
klass==nullptr? "null" : klass->external_name() ));
JvmtiClassEventMark jem(thread, klass);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventClassPrepare callback = env->callbacks()->ClassPrepare;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_class());
@ -1444,7 +1470,7 @@ void JvmtiExport::post_class_unload_internal(const char* name) {
EVT_TRACE(EXT_EVENT_CLASS_UNLOAD, ("[?] Evt Class Unload sent %s", name));
JvmtiEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiExtensionEvent callback = env->ext_callbacks()->ClassUnload;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), name);
@ -1490,7 +1516,7 @@ void JvmtiExport::post_thread_start(JavaThread *thread) {
JvmtiTrace::safe_get_thread_name(thread) ));
JvmtiVirtualThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventThreadStart callback = env->callbacks()->ThreadStart;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread());
@ -1538,7 +1564,7 @@ void JvmtiExport::post_thread_end(JavaThread *thread) {
JvmtiTrace::safe_get_thread_name(thread) ));
JvmtiVirtualThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventThreadEnd callback = env->callbacks()->ThreadEnd;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread());
@ -1568,7 +1594,7 @@ void JvmtiExport::post_vthread_start(jobject vthread) {
EVT_TRACE(JVMTI_EVENT_VIRTUAL_THREAD_START, ("[%p] Evt Virtual Thread Start event sent", vthread));
JvmtiVirtualThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventVirtualThreadStart callback = env->callbacks()->VirtualThreadStart;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread());
@ -1604,7 +1630,7 @@ void JvmtiExport::post_vthread_end(jobject vthread) {
EVT_TRACE(JVMTI_EVENT_VIRTUAL_THREAD_END, ("[%p] Evt Virtual Thread End event sent", vthread));
JvmtiVirtualThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventVirtualThreadEnd callback = env->callbacks()->VirtualThreadEnd;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), vthread);
@ -1639,7 +1665,7 @@ void JvmtiExport::post_vthread_mount(jobject vthread) {
EVT_TRACE(EXT_EVENT_VIRTUAL_THREAD_MOUNT, ("[%p] Evt Virtual Thread Mount event sent", vthread));
JvmtiVirtualThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiExtensionEvent callback = env->ext_callbacks()->VirtualThreadMount;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread());
@ -1674,7 +1700,7 @@ void JvmtiExport::post_vthread_unmount(jobject vthread) {
EVT_TRACE(EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, ("[%p] Evt Virtual Thread Unmount event sent", vthread));
JvmtiVirtualThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiExtensionEvent callback = env->ext_callbacks()->VirtualThreadUnmount;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread());
@ -1787,7 +1813,7 @@ void JvmtiExport::post_resource_exhausted(jint resource_exhausted_flags, const c
EVT_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("Evt resource exhausted event sent" ));
JvmtiThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventResourceExhausted callback = env->callbacks()->ResourceExhausted;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(),
@ -1827,7 +1853,7 @@ void JvmtiExport::post_method_entry(JavaThread *thread, Method* method, frame cu
JvmtiEnv *env = ets->get_env();
JvmtiMethodEventMark jem(thread, mh);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventMethodEntry callback = env->callbacks()->MethodEntry;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_methodID());
@ -1914,7 +1940,7 @@ void JvmtiExport::post_method_exit_inner(JavaThread* thread,
JvmtiEnv *env = ets->get_env();
JvmtiMethodEventMark jem(thread, mh);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventMethodExit callback = env->callbacks()->MethodExit;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
@ -1941,7 +1967,7 @@ void JvmtiExport::post_method_exit_inner(JavaThread* thread,
// we also need to issue a frame pop event for this frame
JvmtiEnv *env = ets->get_env();
JvmtiMethodEventMark jem(thread, mh);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventFramePop callback = env->callbacks()->FramePop;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
@ -1989,7 +2015,7 @@ void JvmtiExport::post_single_step(JavaThread *thread, Method* method, address l
JvmtiEnv *env = ets->get_env();
JvmtiLocationEventMark jem(thread, mh, location);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventSingleStep callback = env->callbacks()->SingleStep;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
@ -2077,7 +2103,7 @@ void JvmtiExport::post_exception_throw(JavaThread *thread, Method* method, addre
catch_jmethodID = jem.to_jmethodID(current_mh);
}
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventException callback = env->callbacks()->Exception;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
@ -2152,7 +2178,7 @@ void JvmtiExport::notice_unwind_due_to_exception(JavaThread *thread, Method* met
JvmtiEnv *env = ets->get_env();
JvmtiExceptionEventMark jem(thread, mh, location, exception_handle);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventExceptionCatch callback = env->callbacks()->ExceptionCatch;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
@ -2238,7 +2264,7 @@ void JvmtiExport::post_field_access(JavaThread *thread, Method* method,
JvmtiLocationEventMark jem(thread, mh, location);
jclass field_jclass = jem.to_jclass(field_klass);
jobject field_jobject = jem.to_jobject(object());
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventFieldAccess callback = env->callbacks()->FieldAccess;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
@ -2396,7 +2422,7 @@ void JvmtiExport::post_field_modification(JavaThread *thread, Method* method,
JvmtiLocationEventMark jem(thread, mh, location);
jclass field_jclass = jem.to_jclass(field_klass);
jobject field_jobject = jem.to_jobject(object());
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventFieldModification callback = env->callbacks()->FieldModification;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
@ -2428,7 +2454,7 @@ void JvmtiExport::post_native_method_bind(Method* method, address* function_ptr)
JvmtiTrace::safe_get_thread_name(thread) ));
JvmtiMethodEventMark jem(thread, mh);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
JNIEnv* jni_env = (env->phase() == JVMTI_PHASE_PRIMORDIAL) ? nullptr : jem.jni_env();
jvmtiEventNativeMethodBind callback = env->callbacks()->NativeMethodBind;
if (callback != nullptr) {
@ -2525,7 +2551,7 @@ void JvmtiExport::post_compiled_method_load(JvmtiEnv* env, nmethod *nm) {
jvmtiCompiledMethodLoadInlineRecord* inlinerecord = create_inline_record(nm);
// Pass inlining information through the void pointer
JvmtiCompiledMethodLoadEventMark jem(thread, nm, inlinerecord);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
(*callback)(env->jvmti_external(), jem.jni_methodID(),
jem.code_size(), jem.code_data(), jem.map_length(),
jem.map(), jem.compile_info());
@ -2552,7 +2578,7 @@ void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const v
("[%s] dynamic code generated event sent for %s",
JvmtiTrace::safe_get_thread_name(thread), name));
JvmtiEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jint length = (jint)pointer_delta(code_end, code_begin, sizeof(char));
jvmtiEventDynamicCodeGenerated callback = env->callbacks()->DynamicCodeGenerated;
if (callback != nullptr) {
@ -2594,7 +2620,7 @@ void JvmtiExport::post_dynamic_code_generated(JvmtiEnv* env, const char *name,
("[%s] dynamic code generated event sent for %s",
JvmtiTrace::safe_get_thread_name(thread), name));
JvmtiEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jint length = (jint)pointer_delta(code_end, code_begin, sizeof(char));
jvmtiEventDynamicCodeGenerated callback = env->callbacks()->DynamicCodeGenerated;
if (callback != nullptr) {
@ -2678,7 +2704,7 @@ void JvmtiExport::post_garbage_collection_finish() {
EVT_TRACE(JVMTI_EVENT_GARBAGE_COLLECTION_FINISH,
("[%s] garbage collection finish event sent",
JvmtiTrace::safe_get_thread_name(thread)));
JvmtiThreadEventTransition jet(thread);
JVMTI_THREAD_EVENT_CALLBACK_BLOCK(thread)
// JNIEnv is null here because this event is posted from VM Thread
jvmtiEventGarbageCollectionFinish callback = env->callbacks()->GarbageCollectionFinish;
if (callback != nullptr) {
@ -2699,7 +2725,7 @@ void JvmtiExport::post_garbage_collection_start() {
EVT_TRACE(JVMTI_EVENT_GARBAGE_COLLECTION_START,
("[%s] garbage collection start event sent",
JvmtiTrace::safe_get_thread_name(thread)));
JvmtiThreadEventTransition jet(thread);
JVMTI_THREAD_EVENT_CALLBACK_BLOCK(thread)
// JNIEnv is null here because this event is posted from VM Thread
jvmtiEventGarbageCollectionStart callback = env->callbacks()->GarbageCollectionStart;
if (callback != nullptr) {
@ -2720,7 +2746,7 @@ void JvmtiExport::post_data_dump() {
EVT_TRACE(JVMTI_EVENT_DATA_DUMP_REQUEST,
("[%s] data dump request event sent",
JvmtiTrace::safe_get_thread_name(thread)));
JvmtiThreadEventTransition jet(thread);
JVMTI_THREAD_EVENT_CALLBACK_BLOCK(thread)
// JNIEnv is null here because this event is posted from VM Thread
jvmtiEventDataDumpRequest callback = env->callbacks()->DataDumpRequest;
if (callback != nullptr) {
@ -2754,7 +2780,7 @@ void JvmtiExport::post_monitor_contended_enter(JavaThread *thread, ObjectMonitor
JvmtiTrace::safe_get_thread_name(thread)));
JvmtiMonitorEventMark jem(thread, h());
JvmtiEnv *env = ets->get_env();
JvmtiThreadEventTransition jet(thread);
JVMTI_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventMonitorContendedEnter callback = env->callbacks()->MonitorContendedEnter;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_object());
@ -2788,7 +2814,7 @@ void JvmtiExport::post_monitor_contended_entered(JavaThread *thread, ObjectMonit
JvmtiTrace::safe_get_thread_name(thread)));
JvmtiMonitorEventMark jem(thread, h());
JvmtiEnv *env = ets->get_env();
JvmtiThreadEventTransition jet(thread);
JVMTI_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventMonitorContendedEntered callback = env->callbacks()->MonitorContendedEntered;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(), jem.jni_object());
@ -2821,7 +2847,7 @@ void JvmtiExport::post_monitor_wait(JavaThread *thread, oop object,
JvmtiTrace::safe_get_thread_name(thread)));
JvmtiMonitorEventMark jem(thread, h());
JvmtiEnv *env = ets->get_env();
JvmtiThreadEventTransition jet(thread);
JVMTI_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventMonitorWait callback = env->callbacks()->MonitorWait;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
@ -2855,7 +2881,7 @@ void JvmtiExport::post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mnt
JvmtiTrace::safe_get_thread_name(thread)));
JvmtiMonitorEventMark jem(thread, h());
JvmtiEnv *env = ets->get_env();
JvmtiThreadEventTransition jet(thread);
JVMTI_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventMonitorWaited callback = env->callbacks()->MonitorWaited;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
@ -2898,7 +2924,7 @@ void JvmtiExport::post_vm_object_alloc(JavaThread *thread, oop object) {
object==nullptr? "null" : object->klass()->external_name()));
JvmtiObjectAllocEventMark jem(thread, h());
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventVMObjectAlloc callback = env->callbacks()->VMObjectAlloc;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
@ -2936,7 +2962,7 @@ void JvmtiExport::post_sampled_object_alloc(JavaThread *thread, oop object) {
JvmtiEnv *env = ets->get_env();
JvmtiObjectAllocEventMark jem(thread, h());
JvmtiJavaThreadEventTransition jet(thread);
JVMTI_JAVA_THREAD_EVENT_CALLBACK_BLOCK(thread)
jvmtiEventSampledObjectAlloc callback = env->callbacks()->SampledObjectAlloc;
if (callback != nullptr) {
(*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),