File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -1670,17 +1670,17 @@ void JvmtiExport::post_vthread_mount(jobject vthread) {
16701670 }
16711671}
16721672
1673- void JvmtiExport::post_vthread_unmount (jobject vthread) {
1673+ void JvmtiExport::post_vthread_unmount (jobject vthread, JvmtiThreadState* state_to_use ) {
16741674 if (JvmtiEnv::get_phase () < JVMTI_PHASE_PRIMORDIAL) {
16751675 return ;
16761676 }
16771677 JavaThread *thread = JavaThread::current ();
16781678 HandleMark hm (thread);
16791679 EVT_TRIG_TRACE (EXT_EVENT_VIRTUAL_THREAD_UNMOUNT, (" [%p] Trg Virtual Thread Unmount event triggered" , vthread));
16801680
1681- // On preemption JVMTI state rebinding has already happened so get it always directly from the oop .
1682- JvmtiThreadState *state = java_lang_Thread::jvmti_thread_state ( JNIHandles::resolve (vthread)) ;
1683- if (state == NULL ) {
1681+ // On preemption, JVMTI state rebinding has already happened so we use the passed one .
1682+ JvmtiThreadState *state = state_to_use == nullptr ? get_jvmti_thread_state (thread) : state_to_use ;
1683+ if (state == nullptr ) {
16841684 return ;
16851685 }
16861686
Original file line number Diff line number Diff line change @@ -358,7 +358,7 @@ class JvmtiExport : public AllStatic {
358358 static void post_vthread_start (jthread vthread) NOT_JVMTI_RETURN;
359359 static void post_vthread_end (jthread vthread) NOT_JVMTI_RETURN;
360360 static void post_vthread_mount (jthread vthread) NOT_JVMTI_RETURN;
361- static void post_vthread_unmount (jthread vthread) NOT_JVMTI_RETURN;
361+ static void post_vthread_unmount (jthread vthread, JvmtiThreadState* state_to_use = nullptr ) NOT_JVMTI_RETURN;
362362
363363 static void continuation_yield_cleanup (JavaThread* thread, jint continuation_frame_count) NOT_JVMTI_RETURN;
364364
Original file line number Diff line number Diff line change @@ -667,7 +667,10 @@ JvmtiVTMSTransitionDisabler::VTMS_unmount_end(jobject vthread) {
667667
668668 if (thread->pending_jvmti_unmount_event ()) {
669669 assert (java_lang_VirtualThread::is_preempted (JNIHandles::resolve (vthread)), " should be marked preempted" );
670- JvmtiExport::post_vthread_unmount (vthread);
670+ // State rebinding has already happened so use the correct state when posting the event.
671+ Handle vth = Handle (thread, JNIHandles::resolve_external_guard (vthread));
672+ JvmtiThreadState* state = JvmtiThreadState::state_for (nullptr , vth);
673+ JvmtiExport::post_vthread_unmount (vthread, state);
671674 thread->set_pending_jvmti_unmount_event (false );
672675 }
673676}
You can’t perform that action at this time.
0 commit comments