8199717: Avoid calculating primordial thread stack bounds on VM startup

Reviewed-by: dholmes, rehn, stuefe
This commit is contained in:
Claes Redestad 2018-04-03 12:55:26 +02:00
parent 05dd65349b
commit 4d780ef52d

View file

@ -152,6 +152,13 @@ static jlong initial_time_count=0;
static int clock_tics_per_sec = 100; 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 // For diagnostics to print a message once. see run_periodic_checks
static sigset_t check_signal_done; static sigset_t check_signal_done;
static bool check_signals = true; static bool check_signals = true;
@ -917,6 +924,9 @@ void os::free_thread(OSThread* osthread) {
// Check if current thread is the primordial thread, similar to Solaris thr_main. // Check if current thread is the primordial thread, similar to Solaris thr_main.
bool os::is_primordial_thread(void) { bool os::is_primordial_thread(void) {
if (suppress_primordial_thread_resolution) {
return false;
}
char dummy; char dummy;
// If called before init complete, thread stack bottom will be null. // If called before init complete, thread stack bottom will be null.
// Can be called if fatal error occurs before initialization. // Can be called if fatal error occurs before initialization.
@ -4933,7 +4943,11 @@ jint os::init_2(void) {
if (Posix::set_minimum_stack_sizes() == JNI_ERR) { if (Posix::set_minimum_stack_sizes() == JNI_ERR) {
return 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) #if defined(IA32)
workaround_expand_exec_shield_cs_limit(); workaround_expand_exec_shield_cs_limit();