--- old/src/cpu/ppc/vm/globals_ppc.hpp 2016-12-02 11:44:48.568049000 +0100 +++ new/src/cpu/ppc/vm/globals_ppc.hpp 2016-12-02 11:44:48.406035000 +0100 @@ -42,6 +42,9 @@ #define DEFAULT_STACK_YELLOW_PAGES (2) #define DEFAULT_STACK_RED_PAGES (1) +// Java_java_net_SocketOutputStream_socketWrite0() uses a 64k buffer on the +// stack if compiled for unix and LP64. To pass stack overflow tests we need +// 20 shadow pages. #define DEFAULT_STACK_SHADOW_PAGES (20 DEBUG_ONLY(+2)) #define DEFAULT_STACK_RESERVED_PAGES (1) --- old/src/cpu/x86/vm/globals_x86.hpp 2016-12-02 11:44:49.782106000 +0100 +++ new/src/cpu/x86/vm/globals_x86.hpp 2016-12-02 11:44:49.621098000 +0100 @@ -63,9 +63,10 @@ #define MIN_STACK_RED_PAGES DEFAULT_STACK_RED_PAGES #define MIN_STACK_RESERVED_PAGES (0) -#ifdef AMD64 -// Very large C++ stack frames using solaris-amd64 optimized builds -// due to lack of optimization caused by C++ compiler bugs +#ifdef _LP64 +// Java_java_net_SocketOutputStream_socketWrite0() uses a 64k buffer on the +// stack if compiled for unix and LP64. To pass stack overflow tests we need +// 20 shadow pages. #define DEFAULT_STACK_SHADOW_PAGES (NOT_WIN64(20) WIN64_ONLY(7) DEBUG_ONLY(+2)) // For those clients that do not use write socket, we allow // the min range value to be below that of the default @@ -73,7 +74,7 @@ #else #define DEFAULT_STACK_SHADOW_PAGES (4 DEBUG_ONLY(+5)) #define MIN_STACK_SHADOW_PAGES DEFAULT_STACK_SHADOW_PAGES -#endif // AMD64 +#endif // _LP64 define_pd_global(intx, StackYellowPages, DEFAULT_STACK_YELLOW_PAGES); define_pd_global(intx, StackRedPages, DEFAULT_STACK_RED_PAGES); --- old/src/os/posix/vm/os_posix.cpp 2016-12-02 11:44:50.969175000 +0100 +++ new/src/os/posix/vm/os_posix.cpp 2016-12-02 11:44:50.801183000 +0100 @@ -1111,10 +1111,9 @@ // Add in 4*BytesPerWord 4K pages to account for VM stack during // class initialization depending on 32 or 64 bit VM. jint os::Posix::set_minimum_stack_sizes() { - _java_thread_min_stack_allowed = MAX2(_java_thread_min_stack_allowed, - JavaThread::stack_guard_zone_size() + - JavaThread::stack_shadow_zone_size() + - (4 * BytesPerWord COMPILER2_PRESENT(+ 2)) * 4 * K); + _java_thread_min_stack_allowed = _java_thread_min_stack_allowed + + JavaThread::stack_guard_zone_size() + + JavaThread::stack_shadow_zone_size(); _java_thread_min_stack_allowed = align_size_up(_java_thread_min_stack_allowed, vm_page_size()); @@ -1150,8 +1149,11 @@ // Make the stack size a multiple of the page size so that // the yellow/red zones can be guarded. - JavaThread::set_stack_size_at_create(round_to(stack_size_in_bytes, - vm_page_size())); + JavaThread::set_stack_size_at_create(round_to(stack_size_in_bytes, vm_page_size())); + + _compiler_thread_min_stack_allowed = _compiler_thread_min_stack_allowed + + JavaThread::stack_guard_zone_size() + + JavaThread::stack_shadow_zone_size(); _compiler_thread_min_stack_allowed = align_size_up(_compiler_thread_min_stack_allowed, vm_page_size()); --- old/src/os/posix/vm/os_posix.hpp 2016-12-02 11:44:52.090226000 +0100 +++ new/src/os/posix/vm/os_posix.hpp 2016-12-02 11:44:51.930217000 +0100 @@ -43,7 +43,11 @@ static void print_load_average(outputStream* st); // Minimum stack size a thread can be created with (allowing - // the VM to completely create the thread and enter user code) + // the VM to completely create the thread and enter user code). + // The initial values exclude any guard pages (by HotSpot or libc). + // Set_minimum_stack_sizes() will add the size required for + // HotSpot guard pages depending on page size and flag settings. + // Libc guard pages are never considered by these values. static size_t _compiler_thread_min_stack_allowed; static size_t _java_thread_min_stack_allowed; static size_t _vm_internal_thread_min_stack_allowed; --- old/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp 2016-12-02 11:44:53.221292000 +0100 +++ new/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp 2016-12-02 11:44:53.070283000 +0100 @@ -535,11 +535,11 @@ //////////////////////////////////////////////////////////////////////////////// // thread stack -// These sizes exclude libc stack guard pages, but include -// the HotSpot guard pages. -size_t os::Posix::_compiler_thread_min_stack_allowed = 512 * K; -size_t os::Posix::_java_thread_min_stack_allowed = 512 * K; -size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; +// Minimum usable stack sizes required to get to user code. Space for +// HotSpotguard pages is added later. +size_t os::Posix::_compiler_thread_min_stack_allowed = 192 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; // Return default stack size for thr_type. size_t os::Posix::default_stack_size(os::ThreadType thr_type) { --- old/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp 2016-12-02 11:44:54.356348000 +0100 +++ new/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp 2016-12-02 11:44:54.205335000 +0100 @@ -839,19 +839,20 @@ //////////////////////////////////////////////////////////////////////////////// // thread stack -#ifdef AMD64 -size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; -size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +// Minimum usable stack sizes required to get to user code. Space for +// HotSpot guard pages is added later. +size_t os::Posix::_compiler_thread_min_stack_allowed = 48 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 48 * K; +#ifdef _LP64 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; #else -size_t os::Posix::_compiler_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; -size_t os::Posix::_java_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; size_t os::Posix::_vm_internal_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; +#endif // _LP64 +#ifndef AMD64 #ifdef __GNUC__ #define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;}) #endif - #endif // AMD64 // return default stack size for thr_type --- old/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp 2016-12-02 11:44:55.469403000 +0100 +++ new/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp 2016-12-02 11:44:55.309401000 +0100 @@ -473,8 +473,10 @@ //////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; -size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +// Minimum usable stack sizes required to get to user code. Space for +// HotSpot guard pages is added later. +size_t os::Posix::_compiler_thread_min_stack_allowed = 32 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 32 * K; size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; // return default stack size for thr_type --- old/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp 2016-12-02 11:44:56.644462000 +0100 +++ new/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp 2016-12-02 11:44:56.486458000 +0100 @@ -535,15 +535,15 @@ //////////////////////////////////////////////////////////////////////////////// // thread stack -// These sizes exclude libc stack guard pages, but include -// the HotSpot guard pages. -size_t os::Posix::_compiler_thread_min_stack_allowed = 384 * K; -size_t os::Posix::_java_thread_min_stack_allowed = 384 * K; -size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; +// Minimum usable stack sizes required to get to user code. Space for +// HotSpot guard pages is added later. +size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; -// return default stack size for thr_type +// Return default stack size for thr_type. size_t os::Posix::default_stack_size(os::ThreadType thr_type) { - // default stack size (compiler thread needs larger stack) + // Default stack size (compiler thread needs larger stack). size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K); return s; } --- old/src/os_cpu/linux_s390/vm/os_linux_s390.cpp 2016-12-02 11:44:57.793524000 +0100 +++ new/src/os_cpu/linux_s390/vm/os_linux_s390.cpp 2016-12-02 11:44:57.634513000 +0100 @@ -473,11 +473,11 @@ //////////////////////////////////////////////////////////////////////////////// // thread stack -// These sizes exclude libc stack guard pages, but include -// the HotSpot guard pages. -size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K; -size_t os::Posix::_java_thread_min_stack_allowed = 236 * K; -size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; +// Minimum usable stack sizes required to get to user code. Space for +// HotSpot guard pages is added later. +size_t os::Posix::_compiler_thread_min_stack_allowed = (52 DEBUG_ONLY(+32)) * K; +size_t os::Posix::_java_thread_min_stack_allowed = (32 DEBUG_ONLY(+8)) * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 32 * K; // Return default stack size for thr_type. size_t os::Posix::default_stack_size(os::ThreadType thr_type) { --- old/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp 2016-12-02 11:44:58.944579000 +0100 +++ new/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp 2016-12-02 11:44:58.781578000 +0100 @@ -681,8 +681,10 @@ /////////////////////////////////////////////////////////////////////////////// // thread stack -size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K; -size_t os::Posix::_java_thread_min_stack_allowed = 128 * K; +// Minimum usable stack sizes required to get to user code. Space for +// HotSpot guard pages is added later. +size_t os::Posix::_compiler_thread_min_stack_allowed = 32 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 32 * K; size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; // return default stack size for thr_type --- old/src/os_cpu/linux_x86/vm/os_linux_x86.cpp 2016-12-02 11:45:00.079641000 +0100 +++ new/src/os_cpu/linux_x86/vm/os_linux_x86.cpp 2016-12-02 11:44:59.921630000 +0100 @@ -677,15 +677,15 @@ //////////////////////////////////////////////////////////////////////////////// // thread stack -#ifdef AMD64 -size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; -size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; +// Minimum usable stack sizes required to get to user code. Space for +// HotSpot guard pages is added later. +size_t os::Posix::_compiler_thread_min_stack_allowed = 48 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 40 * K; +#ifdef _LP64 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; #else -size_t os::Posix::_compiler_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; -size_t os::Posix::_java_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; size_t os::Posix::_vm_internal_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; -#endif // AMD64 +#endif // _LP64 // return default stack size for thr_type size_t os::Posix::default_stack_size(os::ThreadType thr_type) { --- old/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp 2016-12-02 11:45:01.243699000 +0100 +++ new/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp 2016-12-02 11:45:01.087690000 +0100 @@ -81,15 +81,13 @@ #define MAX_PATH (2 * K) -// Minimum stack size for the VM. It's easier to document a constant -// but it's different for x86 and sparc because the page sizes are different. +// Minimum usable stack sizes required to get to user code. Space for +// HotSpot guard pages is added later. +size_t os::Posix::_compiler_thread_min_stack_allowed = 104 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 86 * K; #ifdef _LP64 -size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K; -size_t os::Posix::_java_thread_min_stack_allowed = 128 * K; size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K; #else -size_t os::Posix::_compiler_thread_min_stack_allowed = 96 * K; -size_t os::Posix::_java_thread_min_stack_allowed = 96 * K; size_t os::Posix::_vm_internal_thread_min_stack_allowed = 96 * K; #endif --- old/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp 2016-12-02 11:45:02.518768000 +0100 +++ new/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp 2016-12-02 11:45:02.360759000 +0100 @@ -86,19 +86,23 @@ #define MAX_PATH (2 * K) -// Minimum stack sizes for the VM. It's easier to document a constant value -// but it's different for x86 and sparc because the page sizes are different. -#ifdef AMD64 -size_t os::Posix::_compiler_thread_min_stack_allowed = 394 * K; -size_t os::Posix::_java_thread_min_stack_allowed = 224 * K; +// Minimum usable stack sizes required to get to user code. Space for +// HotSpot guard pages is added later. +#ifdef _LP64 +size_t os::Posix::_compiler_thread_min_stack_allowed = 202 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 48 * K; size_t os::Posix::_vm_internal_thread_min_stack_allowed = 224 * K; +#else +size_t os::Posix::_compiler_thread_min_stack_allowed = 32 * K; +size_t os::Posix::_java_thread_min_stack_allowed = 32 * K; +size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; +#endif // _LP64 + +#ifdef AMD64 #define REG_SP REG_RSP #define REG_PC REG_RIP #define REG_FP REG_RBP #else -size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; -size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; -size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; #define REG_SP UESP #define REG_PC EIP #define REG_FP EBP --- old/src/share/vm/runtime/os.hpp 2016-12-02 11:45:04.298864000 +0100 +++ new/src/share/vm/runtime/os.hpp 2016-12-02 11:45:04.131856000 +0100 @@ -436,7 +436,7 @@ vm_thread, cgc_thread, // Concurrent GC thread pgc_thread, // Parallel GC thread - java_thread, + java_thread, // Java, CocdeCacheSweeper, JVMTIAgent and Service threads. compiler_thread, watcher_thread, os_thread