review: some tweaks for carrier thread JvmtiThreadState initialization

This commit is contained in:
Serguei Spitsyn 2026-01-29 01:16:21 -08:00
parent 4e3ff29a54
commit 23d6f88ecc

View File

@ -56,8 +56,17 @@ bool JvmtiThreadState::_seen_interp_only_mode = false;
JvmtiThreadState::JvmtiThreadState(JavaThread* thread, oop thread_oop)
: _thread_event_enable() {
assert(JvmtiThreadState_lock->is_locked(), "sanity check");
_thread = thread;
_thread_saved = nullptr;
if (JvmtiEnvBase::is_thread_carrying_vthread(thread, thread_oop)) {
// Carrier and virtual threads can temporary share the same JavaThread.
// Only virtual thread should have a link from JvmtiThreadState to JavaThread.
// It is needed for interp-only mechanism.
_thread = nullptr;
_thread_saved = thread;
} else { // virtual or non-carrying platform thread
_thread = thread;
_thread_saved = nullptr;
}
_exception_state = ES_CLEARED;
_hide_single_stepping = false;
_pending_interp_only_mode = false;
@ -124,10 +133,6 @@ JvmtiThreadState::JvmtiThreadState(JavaThread* thread, oop thread_oop)
}
thread->set_interp_only_mode(false);
}
if (JvmtiEnvBase::is_thread_carrying_vthread(thread, thread_oop)) {
_thread_saved = thread;
_thread = nullptr;
}
}