Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8343132: Remove temporary transitions from Virtual thread implementation #21735

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/hotspot/share/classfile/vmIntrinsics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,6 @@ class methodHandle;
do_intrinsic(_notifyJvmtiVThreadEnd, java_lang_VirtualThread, notifyJvmtiEnd_name, void_method_signature, F_RN) \
do_intrinsic(_notifyJvmtiVThreadMount, java_lang_VirtualThread, notifyJvmtiMount_name, bool_void_signature, F_RN) \
do_intrinsic(_notifyJvmtiVThreadUnmount, java_lang_VirtualThread, notifyJvmtiUnmount_name, bool_void_signature, F_RN) \
do_intrinsic(_notifyJvmtiVThreadHideFrames, java_lang_VirtualThread, notifyJvmtiHideFrames_name, bool_void_signature, F_SN) \
do_intrinsic(_notifyJvmtiVThreadDisableSuspend, java_lang_VirtualThread, notifyJvmtiDisableSuspend_name, bool_void_signature, F_SN) \
\
/* support for UnsafeConstants */ \
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/classfile/vmSymbols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ class SerializeClosure;
template(notifyJvmtiEnd_name, "notifyJvmtiEnd") \
template(notifyJvmtiMount_name, "notifyJvmtiMount") \
template(notifyJvmtiUnmount_name, "notifyJvmtiUnmount") \
template(notifyJvmtiHideFrames_name, "notifyJvmtiHideFrames") \
template(notifyJvmtiDisableSuspend_name, "notifyJvmtiDisableSuspend") \
template(doYield_name, "doYield") \
template(enter_name, "enter") \
Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/share/include/jvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1142,9 +1142,6 @@ JVM_VirtualThreadMount(JNIEnv* env, jobject vthread, jboolean hide);
JNIEXPORT void JNICALL
JVM_VirtualThreadUnmount(JNIEnv* env, jobject vthread, jboolean hide);

JNIEXPORT void JNICALL
JVM_VirtualThreadHideFrames(JNIEnv* env, jclass clazz, jboolean hide);

JNIEXPORT void JNICALL
JVM_VirtualThreadDisableSuspend(JNIEnv* env, jclass clazz, jboolean enter);

Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/jvmci/vmStructs_jvmci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
nonstatic_field(JavaThread, _cont_entry, ContinuationEntry*) \
nonstatic_field(JavaThread, _unlocked_inflated_monitor, ObjectMonitor*) \
JVMTI_ONLY(nonstatic_field(JavaThread, _is_in_VTMS_transition, bool)) \
JVMTI_ONLY(nonstatic_field(JavaThread, _is_in_tmp_VTMS_transition, bool)) \
JVMTI_ONLY(nonstatic_field(JavaThread, _is_disable_suspend, bool)) \
\
nonstatic_field(ContinuationEntry, _pin_count, uint32_t) \
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/opto/c2compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,6 @@ bool C2Compiler::is_intrinsic_supported(vmIntrinsics::ID id) {
case vmIntrinsics::_notifyJvmtiVThreadEnd:
case vmIntrinsics::_notifyJvmtiVThreadMount:
case vmIntrinsics::_notifyJvmtiVThreadUnmount:
case vmIntrinsics::_notifyJvmtiVThreadHideFrames:
case vmIntrinsics::_notifyJvmtiVThreadDisableSuspend:
#endif
break;
Expand Down
24 changes: 0 additions & 24 deletions src/hotspot/share/opto/library_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ bool LibraryCallKit::try_to_inline(int predicate) {
"notifyJvmtiMount", false, false);
case vmIntrinsics::_notifyJvmtiVThreadUnmount: return inline_native_notify_jvmti_funcs(CAST_FROM_FN_PTR(address, OptoRuntime::notify_jvmti_vthread_unmount()),
"notifyJvmtiUnmount", false, false);
case vmIntrinsics::_notifyJvmtiVThreadHideFrames: return inline_native_notify_jvmti_hide();
case vmIntrinsics::_notifyJvmtiVThreadDisableSuspend: return inline_native_notify_jvmti_sync();
#endif

Expand Down Expand Up @@ -2975,29 +2974,6 @@ bool LibraryCallKit::inline_native_notify_jvmti_funcs(address funcAddr, const ch
return true;
}

// Always update the temporary VTMS transition bit.
bool LibraryCallKit::inline_native_notify_jvmti_hide() {
if (!DoJVMTIVirtualThreadTransitions) {
return true;
}
IdealKit ideal(this);

{
// unconditionally update the temporary VTMS transition bit in current JavaThread
Node* thread = ideal.thread();
Node* hide = _gvn.transform(argument(0)); // hide argument for temporary VTMS transition notification
Node* addr = basic_plus_adr(thread, in_bytes(JavaThread::is_in_tmp_VTMS_transition_offset()));
const TypePtr *addr_type = _gvn.type(addr)->isa_ptr();

sync_kit(ideal);
access_store_at(nullptr, addr, addr_type, hide, _gvn.type(hide), T_BOOLEAN, IN_NATIVE | MO_UNORDERED);
ideal.sync_kit(this);
}
final_sync(ideal);

return true;
}

// Always update the is_disable_suspend bit.
bool LibraryCallKit::inline_native_notify_jvmti_sync() {
if (!DoJVMTIVirtualThreadTransitions) {
Expand Down
13 changes: 0 additions & 13 deletions src/hotspot/share/prims/jvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3941,19 +3941,6 @@ JVM_ENTRY(void, JVM_VirtualThreadUnmount(JNIEnv* env, jobject vthread, jboolean
#endif
JVM_END

// Always update the temporary VTMS transition bit.
JVM_ENTRY(void, JVM_VirtualThreadHideFrames(JNIEnv* env, jclass clazz, jboolean hide))
#if INCLUDE_JVMTI
if (!DoJVMTIVirtualThreadTransitions) {
assert(!JvmtiExport::can_support_virtual_threads(), "sanity check");
return;
}
assert(!thread->is_in_VTMS_transition(), "sanity check");
assert(thread->is_in_tmp_VTMS_transition() != (bool)hide, "sanity check");
thread->toggle_is_in_tmp_VTMS_transition();
#endif
JVM_END

// Notification from VirtualThread about disabling JVMTI Suspend in a sync critical section.
// Needed to avoid deadlocks with JVMTI suspend mechanism.
JVM_ENTRY(void, JVM_VirtualThreadDisableSuspend(JNIEnv* env, jclass clazz, jboolean enter))
Expand Down
102 changes: 51 additions & 51 deletions src/hotspot/share/prims/jvmtiExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ class JvmtiClassFileLoadHookPoster : public StackObj {
_cached_class_file_ptr = cache_ptr;
_has_been_modified = false;

assert(!_thread->is_in_any_VTMS_transition(), "CFLH events are not allowed in any VTMS transition");
assert(!_thread->is_in_VTMS_transition(), "CFLH events are not allowed in VTMS transition");

_state = JvmtiExport::get_jvmti_thread_state(_thread);
if (_state != nullptr) {
Expand Down Expand Up @@ -1091,8 +1091,8 @@ bool JvmtiExport::post_class_file_load_hook(Symbol* h_name,
return false;
}

if (JavaThread::current()->is_in_any_VTMS_transition()) {
return false; // no events should be posted if thread is in any VTMS transition
if (JavaThread::current()->is_in_VTMS_transition()) {
return false; // no events should be posted if thread is in VTMS transition
}

JvmtiClassFileLoadHookPoster poster(h_name, class_loader,
Expand Down Expand Up @@ -1228,8 +1228,8 @@ void JvmtiExport::post_raw_breakpoint(JavaThread *thread, Method* method, addres
if (state == nullptr) {
return;
}
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

EVT_TRIG_TRACE(JVMTI_EVENT_BREAKPOINT, ("[%s] Trg Breakpoint triggered",
Expand Down Expand Up @@ -1368,8 +1368,8 @@ void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) {
if (state == nullptr) {
return;
}
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Trg Class Load triggered",
Expand Down Expand Up @@ -1405,8 +1405,8 @@ void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) {
if (state == nullptr) {
return;
}
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Trg Class Prepare triggered",
Expand Down Expand Up @@ -1743,8 +1743,8 @@ void JvmtiExport::post_object_free(JvmtiEnv* env, GrowableArray<jlong>* objects)
assert(objects != nullptr, "Nothing to post");

JavaThread *javaThread = JavaThread::current();
if (javaThread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (javaThread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}
if (!env->is_enabled(JVMTI_EVENT_OBJECT_FREE)) {
return; // the event type has been already disabled
Expand All @@ -1767,8 +1767,8 @@ void JvmtiExport::post_resource_exhausted(jint resource_exhausted_flags, const c

JavaThread *thread = JavaThread::current();

if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

log_error(jvmti)("Posting Resource Exhausted event: %s",
Expand Down Expand Up @@ -1810,8 +1810,8 @@ void JvmtiExport::post_method_entry(JavaThread *thread, Method* method, frame cu
// for any thread that actually wants method entry, interp_only_mode is set
return;
}
if (mh->jvmti_mount_transition() || thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (mh->jvmti_mount_transition() || thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}
EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_ENTRY, ("[%s] Trg Method Entry triggered %s.%s",
JvmtiTrace::safe_get_thread_name(thread),
Expand Down Expand Up @@ -1902,8 +1902,8 @@ void JvmtiExport::post_method_exit_inner(JavaThread* thread,
bool exception_exit,
frame current_frame,
jvalue& value) {
if (mh->jvmti_mount_transition() || thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (mh->jvmti_mount_transition() || thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_EXIT, ("[%s] Trg Method Exit triggered %s.%s",
Expand Down Expand Up @@ -1978,8 +1978,8 @@ void JvmtiExport::post_single_step(JavaThread *thread, Method* method, address l
if (state == nullptr) {
return;
}
if (mh->jvmti_mount_transition() || thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (mh->jvmti_mount_transition() || thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

JvmtiEnvThreadStateIterator it(state);
Expand Down Expand Up @@ -2020,8 +2020,8 @@ void JvmtiExport::post_exception_throw(JavaThread *thread, Method* method, addre
if (state == nullptr) {
return;
}
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

EVT_TRIG_TRACE(JVMTI_EVENT_EXCEPTION, ("[%s] Trg Exception thrown triggered",
Expand Down Expand Up @@ -2142,8 +2142,8 @@ void JvmtiExport::notice_unwind_due_to_exception(JavaThread *thread, Method* met
assert(!state->is_exception_caught(), "exception must not be caught yet.");
state->set_exception_caught();

if (mh->jvmti_mount_transition() || thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (mh->jvmti_mount_transition() || thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}
JvmtiEnvThreadStateIterator it(state);
for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) {
Expand Down Expand Up @@ -2188,8 +2188,8 @@ void JvmtiExport::post_field_access_by_jni(JavaThread *thread, oop obj,
// function don't make the call unless there is a Java context.
assert(thread->has_last_Java_frame(), "must be called with a Java context");

if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

ResourceMark rm;
Expand Down Expand Up @@ -2224,8 +2224,8 @@ void JvmtiExport::post_field_access(JavaThread *thread, Method* method,
if (state == nullptr) {
return;
}
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

EVT_TRIG_TRACE(JVMTI_EVENT_FIELD_ACCESS, ("[%s] Trg Field Access event triggered",
Expand Down Expand Up @@ -2274,8 +2274,8 @@ void JvmtiExport::post_field_modification_by_jni(JavaThread *thread, oop obj,
// function don't make the call unless there is a Java context.
assert(thread->has_last_Java_frame(), "must be called with Java context");

if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

ResourceMark rm;
Expand Down Expand Up @@ -2305,8 +2305,8 @@ void JvmtiExport::post_raw_field_modification(JavaThread *thread, Method* method
address location, Klass* field_klass, Handle object, jfieldID field,
char sig_type, jvalue *value) {

if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

if (sig_type == JVM_SIGNATURE_INT || sig_type == JVM_SIGNATURE_BOOLEAN ||
Expand Down Expand Up @@ -2380,8 +2380,8 @@ void JvmtiExport::post_field_modification(JavaThread *thread, Method* method,
if (state == nullptr) {
return;
}
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

EVT_TRIG_TRACE(JVMTI_EVENT_FIELD_MODIFICATION,
Expand Down Expand Up @@ -2419,8 +2419,8 @@ void JvmtiExport::post_native_method_bind(Method* method, address* function_ptr)
HandleMark hm(thread);
methodHandle mh(thread, method);

if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}
EVT_TRIG_TRACE(JVMTI_EVENT_NATIVE_METHOD_BIND, ("[%s] Trg Native Method Bind event triggered",
JvmtiTrace::safe_get_thread_name(thread)));
Expand Down Expand Up @@ -2493,7 +2493,7 @@ void JvmtiExport::post_compiled_method_load(nmethod *nm) {
}
JavaThread* thread = JavaThread::current();

assert(!thread->is_in_any_VTMS_transition(), "compiled method load events are not allowed in any VTMS transition");
assert(!thread->is_in_VTMS_transition(), "compiled method load events are not allowed in VTMS transition");

EVT_TRIG_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD,
("[%s] method compile load event triggered",
Expand All @@ -2516,7 +2516,7 @@ void JvmtiExport::post_compiled_method_load(JvmtiEnv* env, nmethod *nm) {
}
JavaThread* thread = JavaThread::current();

assert(!thread->is_in_any_VTMS_transition(), "compiled method load events are not allowed in any VTMS transition");
assert(!thread->is_in_VTMS_transition(), "compiled method load events are not allowed in VTMS transition");

EVT_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD,
("[%s] method compile load event sent %s.%s ",
Expand All @@ -2541,7 +2541,7 @@ void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const v

JavaThread* thread = JavaThread::current();

assert(!thread->is_in_any_VTMS_transition(), "dynamic code generated events are not allowed in any VTMS transition");
assert(!thread->is_in_VTMS_transition(), "dynamic code generated events are not allowed in VTMS transition");

// In theory everyone coming thru here is in_vm but we need to be certain
// because a callee will do a vm->native transition
Expand Down Expand Up @@ -2589,7 +2589,7 @@ void JvmtiExport::post_dynamic_code_generated(JvmtiEnv* env, const char *name,
{
JavaThread* thread = JavaThread::current();

assert(!thread->is_in_any_VTMS_transition(), "dynamic code generated events are not allowed in any VTMS transition");
assert(!thread->is_in_VTMS_transition(), "dynamic code generated events are not allowed in VTMS transition");

EVT_TRIG_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED,
("[%s] dynamic code generated event triggered (by GenerateEvents)",
Expand Down Expand Up @@ -2744,8 +2744,8 @@ void JvmtiExport::post_monitor_contended_enter(JavaThread *thread, ObjectMonitor
if (state == nullptr) {
return;
}
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTER,
Expand Down Expand Up @@ -2777,8 +2777,8 @@ void JvmtiExport::post_monitor_contended_entered(JavaThread *thread, ObjectMonit
if (state == nullptr) {
return;
}
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTERED,
Expand Down Expand Up @@ -2811,8 +2811,8 @@ void JvmtiExport::post_monitor_wait(JavaThread *thread, oop object,
if (state == nullptr) {
return;
}
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_WAIT,
Expand Down Expand Up @@ -2845,8 +2845,8 @@ void JvmtiExport::post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mnt
if (state == nullptr) {
return;
}
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_WAITED,
Expand Down Expand Up @@ -2874,8 +2874,8 @@ void JvmtiExport::post_vm_object_alloc(JavaThread *thread, oop object) {
if (object == nullptr) {
return;
}
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}
HandleMark hm(thread);
Handle h(thread, object);
Expand Down Expand Up @@ -2911,8 +2911,8 @@ void JvmtiExport::post_sampled_object_alloc(JavaThread *thread, oop object) {
if (object == nullptr) {
return;
}
if (thread->is_in_any_VTMS_transition()) {
return; // no events should be posted if thread is in any VTMS transition
if (thread->is_in_VTMS_transition()) {
return; // no events should be posted if thread is in VTMS transition
}

EVT_TRIG_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC,
Expand Down
Loading