[jdk17u-dev] RFR: 8269466: Factor out the common code for initializing and starting internal VM JavaThreads
Martin Doerr
mdoerr at openjdk.org
Thu Jun 29 21:06:00 UTC 2023
On Mon, 26 Jun 2023 09:50:00 GMT, Martin Doerr <mdoerr at openjdk.org> wrote:
> Backport of [JDK-8269466](https://bugs.openjdk.org/browse/JDK-8269466).
>
> Integrated 2 hunks manually:
>
> --- src/hotspot/share/runtime/os.cpp
> +++ src/hotspot/share/runtime/os.cpp
> @@ -490,26 +490,11 @@ void os::initialize_jdk_signal_support(TRAPS) {
> thread_oop,
> CHECK);
>
> - { MutexLocker mu(THREAD, Threads_lock);
> - JavaThread* signal_thread = new JavaThread(&signal_thread_entry);
> -
> - // At this point it may be possible that no osthread was created for the
> - // JavaThread due to lack of memory. We would have to throw an exception
> - // in that case. However, since this must work and we do not allow
> - // exceptions anyway, check and abort if this fails.
> - if (signal_thread == NULL || signal_thread->osthread() == NULL) {
> - vm_exit_during_initialization("java.lang.OutOfMemoryError",
> - os::native_thread_creation_failed_msg());
> - }
> + JavaThread* thread = new JavaThread(&signal_thread_entry);
> + JavaThread::vm_exit_on_osthread_failure(thread);
>
> - java_lang_Thread::set_thread(thread_oop(), signal_thread);
> - java_lang_Thread::set_priority(thread_oop(), NearMaxPriority);
> - java_lang_Thread::set_daemon(thread_oop());
> + JavaThread::start_internal_daemon(THREAD, thread, thread_oop, NearMaxPriority);
>
> - signal_thread->set_threadObj(thread_oop());
> - Threads::add(signal_thread);
> - Thread::start(signal_thread);
> - }
> // Handle ^BREAK
> os::signal(SIGBREAK, os::user_handler());
> }
>
>
>
> --- src/hotspot/share/runtime/thread.hpp
> +++ src/hotspot/share/runtime/thread.hpp
> @@ -1593,6 +1592,15 @@ class JavaThread: public Thread {
> static OopStorage* thread_oop_storage();
>
> static void verify_cross_modify_fence_failure(JavaThread *thread) PRODUCT_RETURN;
> +
> + // Helper function to start a VM-internal daemon thread.
> + // E.g. ServiceThread, NotificationThread, CompilerThread etc.
> + static void start_internal_daemon(JavaThread* current, JavaThread* target,
> + Handle thread_oop, ThreadPriority prio);
> +
> + // Helper function to do vm_exit_on_initialization for osthread
> + // resource allocation failure.
> + static void vm_exit_on_osthread_failure(JavaThread* thread);
>
>
> The rest applies cleanly.
Thanks for the review!
-------------
PR Comment: https://git.openjdk.org/jdk17u-dev/pull/1498#issuecomment-1613804156
More information about the jdk-updates-dev
mailing list