From 441bd1265650dc865897d5cb6a673edb89dd5cee Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Wed, 26 Mar 2025 19:45:50 +0000 Subject: [PATCH] 8352812: remove useless class and function parameter in SuspendThread impl Reviewed-by: lmesnik, cjplummer --- src/hotspot/share/prims/jvmtiEnv.cpp | 12 ++++----- src/hotspot/share/prims/jvmtiEnvBase.cpp | 7 +++-- src/hotspot/share/prims/jvmtiEnvBase.hpp | 3 +-- src/hotspot/share/prims/jvmtiImpl.cpp | 34 ------------------------ src/hotspot/share/prims/jvmtiImpl.hpp | 22 --------------- 5 files changed, 10 insertions(+), 68 deletions(-) diff --git a/src/hotspot/share/prims/jvmtiEnv.cpp b/src/hotspot/share/prims/jvmtiEnv.cpp index aedd56817bf..fe1578aedf2 100644 --- a/src/hotspot/share/prims/jvmtiEnv.cpp +++ b/src/hotspot/share/prims/jvmtiEnv.cpp @@ -940,14 +940,14 @@ JvmtiEnv::SuspendThread(jthread thread) { // Do not use JvmtiVTMSTransitionDisabler in context of self suspend to avoid deadlocks. if (java_thread != current) { - err = suspend_thread(thread_oop, java_thread, /* single_suspend */ true, nullptr); + err = suspend_thread(thread_oop, java_thread, /* single_suspend */ true); return err; } // protect thread_oop as a safepoint can be reached in disabler destructor self_tobj = Handle(current, thread_oop); } // Do self suspend for current JavaThread. - err = suspend_thread(self_tobj(), current, /* single_suspend */ true, nullptr); + err = suspend_thread(self_tobj(), current, /* single_suspend */ true); return err; } /* end SuspendThread */ @@ -988,14 +988,14 @@ JvmtiEnv::SuspendThreadList(jint request_count, const jthread* request_list, jvm self_tobj = Handle(current, thread_oop); continue; // self suspend after all other suspends } - results[i] = suspend_thread(thread_oop, java_thread, /* single_suspend */ true, nullptr); + results[i] = suspend_thread(thread_oop, java_thread, /* single_suspend */ true); } } // Self suspend after all other suspends if necessary. // Do not use JvmtiVTMSTransitionDisabler in context of self suspend to avoid deadlocks. if (self_tobj() != nullptr) { // there should not be any error for current java_thread - results[self_idx] = suspend_thread(self_tobj(), current, /* single_suspend */ true, nullptr); + results[self_idx] = suspend_thread(self_tobj(), current, /* single_suspend */ true); } // per-thread suspend results returned via results parameter return JVMTI_ERROR_NONE; @@ -1048,7 +1048,7 @@ JvmtiEnv::SuspendAllVirtualThreads(jint except_count, const jthread* except_list self_tobj = Handle(current, vt_oop); continue; // self suspend after all other suspends } - suspend_thread(vt_oop, java_thread, /* single_suspend */ false, nullptr); + suspend_thread(vt_oop, java_thread, /* single_suspend */ false); } } JvmtiVTSuspender::register_all_vthreads_suspend(); @@ -1065,7 +1065,7 @@ JvmtiEnv::SuspendAllVirtualThreads(jint except_count, const jthread* except_list // Self suspend after all other suspends if necessary. // Do not use JvmtiVTMSTransitionDisabler in context of self suspend to avoid deadlocks. if (self_tobj() != nullptr) { - suspend_thread(self_tobj(), current, /* single_suspend */ false, nullptr); + suspend_thread(self_tobj(), current, /* single_suspend */ false); } return JVMTI_ERROR_NONE; } /* end SuspendAllVirtualThreads */ diff --git a/src/hotspot/share/prims/jvmtiEnvBase.cpp b/src/hotspot/share/prims/jvmtiEnvBase.cpp index b35c0d5c949..71b2c9d216e 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.cpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp @@ -1750,8 +1750,7 @@ JvmtiEnvBase::disable_virtual_threads_notify_jvmti() { // java_thread - protected by ThreadsListHandle jvmtiError -JvmtiEnvBase::suspend_thread(oop thread_oop, JavaThread* java_thread, bool single_suspend, - int* need_safepoint_p) { +JvmtiEnvBase::suspend_thread(oop thread_oop, JavaThread* java_thread, bool single_suspend) { JavaThread* current = JavaThread::current(); HandleMark hm(current); Handle thread_h(current, thread_oop); @@ -1807,7 +1806,7 @@ JvmtiEnvBase::suspend_thread(oop thread_oop, JavaThread* java_thread, bool singl assert(single_suspend || thread_h()->is_a(vmClasses::BaseVirtualThread_klass()), "SuspendAllVirtualThreads should never suspend non-virtual threads"); // Case of mounted virtual or attached carrier thread. - if (!JvmtiSuspendControl::suspend(java_thread)) { + if (!java_thread->java_suspend()) { // Thread is already suspended or in process of exiting. if (java_thread->is_exiting()) { // The thread was in the process of exiting. @@ -1869,7 +1868,7 @@ JvmtiEnvBase::resume_thread(oop thread_oop, JavaThread* java_thread, bool single assert(single_resume || thread_h()->is_a(vmClasses::BaseVirtualThread_klass()), "ResumeAllVirtualThreads should never resume non-virtual threads"); if (java_thread->is_suspended()) { - if (!JvmtiSuspendControl::resume(java_thread)) { + if (!java_thread->java_resume()) { return JVMTI_ERROR_THREAD_NOT_SUSPENDED; } } diff --git a/src/hotspot/share/prims/jvmtiEnvBase.hpp b/src/hotspot/share/prims/jvmtiEnvBase.hpp index ec4423e4a1c..5d6b5a2209e 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.hpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.hpp @@ -90,8 +90,7 @@ class JvmtiEnvBase : public CHeapObj { // It is unsafe to use this function when virtual threads are executed. static bool disable_virtual_threads_notify_jvmti(); - static jvmtiError suspend_thread(oop thread_oop, JavaThread* java_thread, bool single_suspend, - int* need_safepoint_p); + static jvmtiError suspend_thread(oop thread_oop, JavaThread* java_thread, bool single_suspend); static jvmtiError resume_thread(oop thread_oop, JavaThread* java_thread, bool single_resume); static jvmtiError check_thread_list(jint count, const jthread* list); static bool is_in_thread_list(jint count, const jthread* list, oop jt_oop); diff --git a/src/hotspot/share/prims/jvmtiImpl.cpp b/src/hotspot/share/prims/jvmtiImpl.cpp index 1e8614e2122..9caea2de520 100644 --- a/src/hotspot/share/prims/jvmtiImpl.cpp +++ b/src/hotspot/share/prims/jvmtiImpl.cpp @@ -745,40 +745,6 @@ VM_VirtualThreadGetReceiver::VM_VirtualThreadGetReceiver( : VM_VirtualThreadGetOrSetLocal(env, vthread_h, caller_thread, depth, 0, self) {} -///////////////////////////////////////////////////////////////////////////////////////// -// -// class JvmtiSuspendControl - see comments in jvmtiImpl.hpp -// - -bool JvmtiSuspendControl::suspend(JavaThread *java_thread) { - return java_thread->java_suspend(); -} - -bool JvmtiSuspendControl::resume(JavaThread *java_thread) { - return java_thread->java_resume(); -} - -void JvmtiSuspendControl::print() { -#ifndef PRODUCT - ResourceMark rm; - LogStreamHandle(Trace, jvmti) log_stream; - log_stream.print("Suspended Threads: ["); - for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) { -#ifdef JVMTI_TRACE - const char *name = JvmtiTrace::safe_get_thread_name(thread); -#else - const char *name = ""; -#endif /*JVMTI_TRACE */ - log_stream.print("%s(%c ", name, thread->is_suspended() ? 'S' : '_'); - if (!thread->has_last_Java_frame()) { - log_stream.print("no stack"); - } - log_stream.print(") "); - } - log_stream.print_cr("]"); -#endif -} - JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_load_event( nmethod* nm) { JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_COMPILED_METHOD_LOAD); diff --git a/src/hotspot/share/prims/jvmtiImpl.hpp b/src/hotspot/share/prims/jvmtiImpl.hpp index 3a103cc8237..c359b2fcbc3 100644 --- a/src/hotspot/share/prims/jvmtiImpl.hpp +++ b/src/hotspot/share/prims/jvmtiImpl.hpp @@ -278,28 +278,6 @@ class VM_VirtualThreadGetReceiver : public VM_VirtualThreadGetOrSetLocal { }; -/////////////////////////////////////////////////////////////// -// -// class JvmtiSuspendControl -// -// Convenience routines for suspending and resuming threads. -// -// All attempts by JVMTI to suspend and resume threads must go through the -// JvmtiSuspendControl interface. -// -// methods return true if successful -// -class JvmtiSuspendControl : public AllStatic { -public: - // suspend the thread, taking it to a safepoint - static bool suspend(JavaThread *java_thread); - // resume the thread - static bool resume(JavaThread *java_thread); - - static void print(); -}; - - /** * When a thread (such as the compiler thread or VM thread) cannot post a * JVMTI event itself because the event needs to be posted from a Java