Skip to content

Commit 1729b98

Browse files
committed
Use JvmtiVTMSTransitionDisabler::VTMS_vthread_mount/unmount
1 parent 124efa0 commit 1729b98

File tree

5 files changed

+3
-33
lines changed

5 files changed

+3
-33
lines changed

src/hotspot/share/prims/jvmtiThreadState.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -667,12 +667,6 @@ JvmtiVTMSTransitionDisabler::VTMS_unmount_end(jobject vthread) {
667667
JavaThread* thread = JavaThread::current();
668668
assert(thread->is_in_VTMS_transition(), "sanity check");
669669
finish_VTMS_transition(vthread, /* is_mount */ false);
670-
671-
if (thread->pending_jvmti_unmount_event()) {
672-
assert(java_lang_VirtualThread::is_preempted(JNIHandles::resolve(vthread)), "should be marked preempted");
673-
JvmtiExport::post_vthread_unmount(vthread);
674-
thread->set_pending_jvmti_unmount_event(false);
675-
}
676670
}
677671

678672

src/hotspot/share/runtime/continuation.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class JvmtiUnmountBeginMark : public StackObj {
7070
assert(!_target->is_in_VTMS_transition(), "must be");
7171

7272
if (JvmtiVTMSTransitionDisabler::VTMS_notify_jvmti_events()) {
73-
JvmtiVTMSTransitionDisabler::start_VTMS_transition((jthread)_vthread.raw_value(), /* is_mount */ false);
73+
JvmtiVTMSTransitionDisabler::VTMS_vthread_unmount((jthread)_vthread.raw_value(), true);
7474

7575
// Don't preempt if there is a pending popframe or earlyret operation. This can
7676
// be installed in start_VTMS_transition() so we need to check it here.
@@ -104,20 +104,11 @@ class JvmtiUnmountBeginMark : public StackObj {
104104
if (_result != freeze_ok) {
105105
// Undo transition
106106
if (jvmti_present) {
107-
JvmtiVTMSTransitionDisabler::finish_VTMS_transition((jthread)_vthread.raw_value(), false);
107+
JvmtiVTMSTransitionDisabler::VTMS_vthread_mount((jthread)_vthread.raw_value(), false);
108108
} else {
109109
_target->set_is_in_VTMS_transition(false);
110110
java_lang_Thread::set_is_in_VTMS_transition(_vthread(), false);
111111
}
112-
} else {
113-
if (jvmti_present) {
114-
_target->rebind_to_jvmti_thread_state_of(_target->threadObj());
115-
if (JvmtiExport::should_post_vthread_unmount()) {
116-
// We are inside the VTMS transition already so we will post the event
117-
// once we finish it in JvmtiVTMSTransitionDisabler::VTMS_unmount_end().
118-
_target->set_pending_jvmti_unmount_event(true);
119-
}
120-
}
121112
}
122113
}
123114
void set_result(freeze_result res) { _result = res; }

src/hotspot/share/runtime/continuationFreezeThaw.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,17 +1608,7 @@ static void jvmti_mount_end(JavaThread* current, ContinuationWrapper& cont, fram
16081608
set_anchor(current, top.sp());
16091609

16101610
JRT_BLOCK
1611-
current->rebind_to_jvmti_thread_state_of(vth());
1612-
JvmtiVTMSTransitionDisabler::finish_VTMS_transition((jthread)vth.raw_value(), /* is_mount */ true);
1613-
1614-
// If pending_jvmti_unmount_event() is true here we are in the preemption
1615-
// cancelled case. Since we never unmounted we don't post the mount event
1616-
// and just clear the pending unmount flag.
1617-
if (current->pending_jvmti_unmount_event()) {
1618-
current->set_pending_jvmti_unmount_event(false);
1619-
} else if (JvmtiExport::should_post_vthread_mount()) {
1620-
JvmtiExport::post_vthread_mount((jthread)vth.raw_value());
1621-
}
1611+
JvmtiVTMSTransitionDisabler::VTMS_vthread_mount((jthread)vth.raw_value(), false);
16221612

16231613
if (current->pending_contended_entered_event()) {
16241614
JvmtiExport::post_monitor_contended_entered(current, current->contended_entered_monitor());

src/hotspot/share/runtime/javaThread.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ JavaThread::JavaThread(MemTag mem_tag) :
455455
_is_in_VTMS_transition(false),
456456
_is_disable_suspend(false),
457457
_VTMS_transition_mark(false),
458-
_pending_jvmti_unmount_event(false),
459458
_on_monitor_waited_event(false),
460459
_contended_entered_monitor(nullptr),
461460
#ifdef ASSERT

src/hotspot/share/runtime/javaThread.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ class JavaThread: public Thread {
328328
bool _is_in_VTMS_transition; // thread is in virtual thread mount state transition
329329
bool _is_disable_suspend; // JVMTI suspend is temporarily disabled; used on current thread only
330330
bool _VTMS_transition_mark; // used for sync between VTMS transitions and disablers
331-
bool _pending_jvmti_unmount_event; // When preempting we post unmount event at unmount end rather than start
332331
bool _on_monitor_waited_event; // Avoid callee arg processing for enterSpecial when posting waited event
333332
ObjectMonitor* _contended_entered_monitor; // Monitor for pending monitor_contended_entered callback
334333
#ifdef ASSERT
@@ -722,9 +721,6 @@ class JavaThread: public Thread {
722721
bool VTMS_transition_mark() const { return Atomic::load(&_VTMS_transition_mark); }
723722
void set_VTMS_transition_mark(bool val) { Atomic::store(&_VTMS_transition_mark, val); }
724723

725-
bool pending_jvmti_unmount_event() { return _pending_jvmti_unmount_event; }
726-
void set_pending_jvmti_unmount_event(bool val) { _pending_jvmti_unmount_event = val; }
727-
728724
bool on_monitor_waited_event() { return _on_monitor_waited_event; }
729725
void set_on_monitor_waited_event(bool val) { _on_monitor_waited_event = val; }
730726

0 commit comments

Comments
 (0)