8269466: Factor out the common code for initializing and starting internal VM JavaThreads

Reviewed-by: sspitsyn, pchilanomate, dcubed, coleenp, kvn
This commit is contained in:
David Holmes 2021-07-02 04:29:47 +00:00
parent 2baf498eb5
commit 4107dcf6ec
13 changed files with 152 additions and 225 deletions

View file

@ -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);
JavaThread* thread = new JavaThread(&signal_thread_entry);
JavaThread::vm_exit_on_osthread_failure(thread);
// 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::start_internal_daemon(THREAD, thread, thread_oop, NearMaxPriority);
java_lang_Thread::set_thread(thread_oop(), signal_thread);
java_lang_Thread::set_priority(thread_oop(), NearMaxPriority);
java_lang_Thread::set_daemon(thread_oop());
signal_thread->set_threadObj(thread_oop());
Threads::add(signal_thread);
Thread::start(signal_thread);
}
// Handle ^BREAK
os::signal(SIGBREAK, os::user_handler());
}