8080298: Clean up os::...::supports_variable_stack_size()

Reviewed-by: kbarrett, simonis, stuefe, coleenp
This commit is contained in:
David Holmes 2015-08-03 16:54:08 -04:00
parent 2bf01467e3
commit 8dfd822c41
14 changed files with 77 additions and 123 deletions

View File

@ -971,34 +971,32 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) {
guarantee(pthread_attr_setsuspendstate_np(&attr, PTHREAD_CREATE_SUSPENDED_NP) == 0, "???"); guarantee(pthread_attr_setsuspendstate_np(&attr, PTHREAD_CREATE_SUSPENDED_NP) == 0, "???");
// calculate stack size if it's not specified by caller // calculate stack size if it's not specified by caller
if (os::Aix::supports_variable_stack_size()) { if (stack_size == 0) {
if (stack_size == 0) { stack_size = os::Aix::default_stack_size(thr_type);
stack_size = os::Aix::default_stack_size(thr_type);
switch (thr_type) { switch (thr_type) {
case os::java_thread: case os::java_thread:
// Java threads use ThreadStackSize whose default value can be changed with the flag -Xss. // Java threads use ThreadStackSize whose default value can be changed with the flag -Xss.
assert(JavaThread::stack_size_at_create() > 0, "this should be set"); assert(JavaThread::stack_size_at_create() > 0, "this should be set");
stack_size = JavaThread::stack_size_at_create(); stack_size = JavaThread::stack_size_at_create();
break;
case os::compiler_thread:
if (CompilerThreadStackSize > 0) {
stack_size = (size_t)(CompilerThreadStackSize * K);
break; break;
case os::compiler_thread: } // else fall through:
if (CompilerThreadStackSize > 0) { // use VMThreadStackSize if CompilerThreadStackSize is not defined
stack_size = (size_t)(CompilerThreadStackSize * K); case os::vm_thread:
break; case os::pgc_thread:
} // else fall through: case os::cgc_thread:
// use VMThreadStackSize if CompilerThreadStackSize is not defined case os::watcher_thread:
case os::vm_thread: if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
case os::pgc_thread: break;
case os::cgc_thread:
case os::watcher_thread:
if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
break;
}
} }
}
stack_size = MAX2(stack_size, os::Aix::min_stack_allowed); stack_size = MAX2(stack_size, os::Aix::min_stack_allowed);
pthread_attr_setstacksize(&attr, stack_size); pthread_attr_setstacksize(&attr, stack_size);
} //else let thread_create() pick the default value (96 K on AIX)
pthread_t tid; pthread_t tid;
int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread); int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread);

View File

@ -131,8 +131,6 @@ class Aix {
static void initialize_libo4(); static void initialize_libo4();
static void initialize_libperfstat(); static void initialize_libperfstat();
static bool supports_variable_stack_size();
public: public:
static void init_thread_fpu_state(); static void init_thread_fpu_state();
static pthread_t main_thread(void) { return _main_thread; } static pthread_t main_thread(void) { return _main_thread; }

View File

@ -739,40 +739,35 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) {
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
// stack size // calculate stack size if it's not specified by caller
if (os::Bsd::supports_variable_stack_size()) { if (stack_size == 0) {
// calculate stack size if it's not specified by caller stack_size = os::Bsd::default_stack_size(thr_type);
if (stack_size == 0) {
stack_size = os::Bsd::default_stack_size(thr_type);
switch (thr_type) { switch (thr_type) {
case os::java_thread: case os::java_thread:
// Java threads use ThreadStackSize which default value can be // Java threads use ThreadStackSize which default value can be
// changed with the flag -Xss // changed with the flag -Xss
assert(JavaThread::stack_size_at_create() > 0, "this should be set"); assert(JavaThread::stack_size_at_create() > 0, "this should be set");
stack_size = JavaThread::stack_size_at_create(); stack_size = JavaThread::stack_size_at_create();
break;
case os::compiler_thread:
if (CompilerThreadStackSize > 0) {
stack_size = (size_t)(CompilerThreadStackSize * K);
break; break;
case os::compiler_thread: } // else fall through:
if (CompilerThreadStackSize > 0) { // use VMThreadStackSize if CompilerThreadStackSize is not defined
stack_size = (size_t)(CompilerThreadStackSize * K); case os::vm_thread:
break; case os::pgc_thread:
} // else fall through: case os::cgc_thread:
// use VMThreadStackSize if CompilerThreadStackSize is not defined case os::watcher_thread:
case os::vm_thread: if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
case os::pgc_thread: break;
case os::cgc_thread:
case os::watcher_thread:
if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
break;
}
} }
stack_size = MAX2(stack_size, os::Bsd::min_stack_allowed);
pthread_attr_setstacksize(&attr, stack_size);
} else {
// let pthread_create() pick the default value.
} }
stack_size = MAX2(stack_size, os::Bsd::min_stack_allowed);
pthread_attr_setstacksize(&attr, stack_size);
ThreadState state; ThreadState state;
{ {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -75,8 +75,6 @@ class Bsd {
static julong physical_memory() { return _physical_memory; } static julong physical_memory() { return _physical_memory; }
static void initialize_system_info(); static void initialize_system_info();
static bool supports_variable_stack_size();
static void rebuild_cpu_to_node_map(); static void rebuild_cpu_to_node_map();
static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; } static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }

View File

@ -711,39 +711,35 @@ bool os::create_thread(Thread* thread, ThreadType thr_type,
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
// stack size // stack size
if (os::Linux::supports_variable_stack_size()) { // calculate stack size if it's not specified by caller
// calculate stack size if it's not specified by caller if (stack_size == 0) {
if (stack_size == 0) { stack_size = os::Linux::default_stack_size(thr_type);
stack_size = os::Linux::default_stack_size(thr_type);
switch (thr_type) { switch (thr_type) {
case os::java_thread: case os::java_thread:
// Java threads use ThreadStackSize which default value can be // Java threads use ThreadStackSize which default value can be
// changed with the flag -Xss // changed with the flag -Xss
assert(JavaThread::stack_size_at_create() > 0, "this should be set"); assert(JavaThread::stack_size_at_create() > 0, "this should be set");
stack_size = JavaThread::stack_size_at_create(); stack_size = JavaThread::stack_size_at_create();
break;
case os::compiler_thread:
if (CompilerThreadStackSize > 0) {
stack_size = (size_t)(CompilerThreadStackSize * K);
break; break;
case os::compiler_thread: } // else fall through:
if (CompilerThreadStackSize > 0) { // use VMThreadStackSize if CompilerThreadStackSize is not defined
stack_size = (size_t)(CompilerThreadStackSize * K); case os::vm_thread:
break; case os::pgc_thread:
} // else fall through: case os::cgc_thread:
// use VMThreadStackSize if CompilerThreadStackSize is not defined case os::watcher_thread:
case os::vm_thread: if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
case os::pgc_thread: break;
case os::cgc_thread:
case os::watcher_thread:
if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
break;
}
} }
stack_size = MAX2(stack_size, os::Linux::min_stack_allowed);
pthread_attr_setstacksize(&attr, stack_size);
} else {
// let pthread_create() pick the default value.
} }
stack_size = MAX2(stack_size, os::Linux::min_stack_allowed);
pthread_attr_setstacksize(&attr, stack_size);
// glibc guard page // glibc guard page
pthread_attr_setguardsize(&attr, os::Linux::default_guard_size(thr_type)); pthread_attr_setguardsize(&attr, os::Linux::default_guard_size(thr_type));

View File

@ -83,8 +83,6 @@ class Linux {
static void set_glibc_version(const char *s) { _glibc_version = s; } static void set_glibc_version(const char *s) { _glibc_version = s; }
static void set_libpthread_version(const char *s) { _libpthread_version = s; } static void set_libpthread_version(const char *s) { _libpthread_version = s; }
static bool supports_variable_stack_size();
static void rebuild_cpu_to_node_map(); static void rebuild_cpu_to_node_map();
static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; } static GrowableArray<int>* cpu_to_node() { return _cpu_to_node; }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012, 2014 SAP AG. All rights reserved. * Copyright 2012, 2014 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -489,10 +489,6 @@ void os::Aix::init_thread_fpu_state(void) {
size_t os::Aix::min_stack_allowed = 128*K; size_t os::Aix::min_stack_allowed = 128*K;
// Aix is always in floating stack mode. The stack size for a new
// thread can be set via pthread_attr_setstacksize().
bool os::Aix::supports_variable_stack_size() { return true; }
// return default stack size for thr_type // return default stack size for thr_type
size_t os::Aix::default_stack_size(os::ThreadType thr_type) { size_t os::Aix::default_stack_size(os::ThreadType thr_type) {
// default stack size (compiler thread needs larger stack) // default stack size (compiler thread needs larger stack)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -780,9 +780,6 @@ bool os::is_allocatable(size_t bytes) {
#ifdef AMD64 #ifdef AMD64
size_t os::Bsd::min_stack_allowed = 64 * K; size_t os::Bsd::min_stack_allowed = 64 * K;
// amd64: pthread on amd64 is always in floating stack mode
bool os::Bsd::supports_variable_stack_size() { return true; }
#else #else
size_t os::Bsd::min_stack_allowed = (48 DEBUG_ONLY(+4))*K; size_t os::Bsd::min_stack_allowed = (48 DEBUG_ONLY(+4))*K;
@ -790,7 +787,6 @@ size_t os::Bsd::min_stack_allowed = (48 DEBUG_ONLY(+4))*K;
#define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;}) #define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;})
#endif #endif
bool os::Bsd::supports_variable_stack_size() { return true; }
#endif // AMD64 #endif // AMD64
// return default stack size for thr_type // return default stack size for thr_type

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -290,10 +290,6 @@ bool os::is_allocatable(size_t bytes) {
size_t os::Bsd::min_stack_allowed = 64 * K; size_t os::Bsd::min_stack_allowed = 64 * K;
bool os::Bsd::supports_variable_stack_size() {
return true;
}
size_t os::Bsd::default_stack_size(os::ThreadType thr_type) { size_t os::Bsd::default_stack_size(os::ThreadType thr_type) {
#ifdef _LP64 #ifdef _LP64
size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Red Hat Inc. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -496,9 +496,6 @@ bool os::is_allocatable(size_t bytes) {
size_t os::Linux::min_stack_allowed = 64 * K; size_t os::Linux::min_stack_allowed = 64 * K;
// aarch64: pthread on aarch64 is always in floating stack mode
bool os::Linux::supports_variable_stack_size() { return true; }
// return default stack size for thr_type // return default stack size for thr_type
size_t os::Linux::default_stack_size(os::ThreadType thr_type) { size_t os::Linux::default_stack_size(os::ThreadType thr_type) {
// default stack size (compiler thread needs larger stack) // default stack size (compiler thread needs larger stack)

View File

@ -467,8 +467,6 @@ void os::Linux::set_fpu_control_word(int fpu_control) {
size_t os::Linux::min_stack_allowed = 128*K; size_t os::Linux::min_stack_allowed = 128*K;
bool os::Linux::supports_variable_stack_size() { return true; }
// return default stack size for thr_type // return default stack size for thr_type
size_t os::Linux::default_stack_size(os::ThreadType thr_type) { size_t os::Linux::default_stack_size(os::ThreadType thr_type) {
// default stack size (compiler thread needs larger stack) // default stack size (compiler thread needs larger stack)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -733,9 +733,6 @@ bool os::is_allocatable(size_t bytes) {
size_t os::Linux::min_stack_allowed = 128 * K; size_t os::Linux::min_stack_allowed = 128 * K;
// pthread on Ubuntu is always in floating stack mode
bool os::Linux::supports_variable_stack_size() { return true; }
// return default stack size for thr_type // return default stack size for thr_type
size_t os::Linux::default_stack_size(os::ThreadType thr_type) { size_t os::Linux::default_stack_size(os::ThreadType thr_type) {
// default stack size (compiler thread needs larger stack) // default stack size (compiler thread needs larger stack)

View File

@ -623,11 +623,6 @@ size_t os::Linux::min_stack_allowed = 64 * K;
size_t os::Linux::min_stack_allowed = (48 DEBUG_ONLY(+4))*K; size_t os::Linux::min_stack_allowed = (48 DEBUG_ONLY(+4))*K;
#endif // AMD64 #endif // AMD64
// Test if pthread library can support variable thread stack size.
bool os::Linux::supports_variable_stack_size() {
return true;
}
// return default stack size for thr_type // return default stack size for thr_type
size_t os::Linux::default_stack_size(os::ThreadType thr_type) { size_t os::Linux::default_stack_size(os::ThreadType thr_type) {
// default stack size (compiler thread needs larger stack) // default stack size (compiler thread needs larger stack)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
@ -305,10 +305,6 @@ bool os::is_allocatable(size_t bytes) {
size_t os::Linux::min_stack_allowed = 64 * K; size_t os::Linux::min_stack_allowed = 64 * K;
bool os::Linux::supports_variable_stack_size() {
return true;
}
size_t os::Linux::default_stack_size(os::ThreadType thr_type) { size_t os::Linux::default_stack_size(os::ThreadType thr_type) {
#ifdef _LP64 #ifdef _LP64
size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);