# HG changeset patch # User redestad # Date 1522158105 -7200 # Tue Mar 27 15:41:45 2018 +0200 # Node ID ff872a47461f9b6f61d471d212477923a193b9f8 # Parent b39bc2eb8325eafc55b7c0d0f4dd5076b3d44561 8199717: Avoid calculating primordial thread stack bounds on VM startup Reviewed-by: dholmes, rehn, stuefe diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -152,6 +152,13 @@ static int clock_tics_per_sec = 100; +// If the VM might have been created on the primordial thread, we need to resolve the +// primordial thread stack bounds and check if the current thread might be the +// primordial thread in places. If we know that the primordial thread is never used, +// such as when the VM was created by one of the standard java launchers, we can +// avoid this +static bool suppress_primordial_thread_resolution = false; + // For diagnostics to print a message once. see run_periodic_checks static sigset_t check_signal_done; static bool check_signals = true; @@ -917,6 +924,9 @@ // Check if current thread is the primordial thread, similar to Solaris thr_main. bool os::is_primordial_thread(void) { + if (suppress_primordial_thread_resolution) { + return false; + } char dummy; // If called before init complete, thread stack bottom will be null. // Can be called if fatal error occurs before initialization. @@ -4936,7 +4946,11 @@ if (Posix::set_minimum_stack_sizes() == JNI_ERR) { return JNI_ERR; } - Linux::capture_initial_stack(JavaThread::stack_size_at_create()); + + suppress_primordial_thread_resolution = Arguments::created_by_java_launcher(); + if (!suppress_primordial_thread_resolution) { + Linux::capture_initial_stack(JavaThread::stack_size_at_create()); + } #if defined(IA32) workaround_expand_exec_shield_cs_limit();