--- old/src/cpu/ppc/vm/globals_ppc.hpp 2016-11-16 16:45:28.890383000 +0100 +++ new/src/cpu/ppc/vm/globals_ppc.hpp 2016-11-16 16:45:28.724373000 +0100 @@ -42,6 +42,8 @@ #define DEFAULT_STACK_YELLOW_PAGES (2) #define DEFAULT_STACK_RED_PAGES (1) +// Java_java_net_SocketOutputStream_socketWrite0() uses a 64k buffer on the +// stack. 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-11-16 16:45:29.908436000 +0100 +++ new/src/cpu/x86/vm/globals_x86.hpp 2016-11-16 16:45:29.753425000 +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-11-16 16:45:30.997490000 +0100 +++ new/src/os/posix/vm/os_posix.cpp 2016-11-16 16:45:30.842489000 +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-11-16 16:45:31.947542000 +0100 +++ new/src/os/posix/vm/os_posix.hpp 2016-11-16 16:45:31.802532000 +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 VM or OS). + // set_minimum_stack_sizes() will add the size required for + // VM guard pages depending on page size. + // OS 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-11-16 16:45:32.894590000 +0100 +++ new/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp 2016-11-16 16:45:32.760587000 +0100 @@ -535,11 +535,11 @@ //////////////////////////////////////////////////////////////////////////////// // thread stack -// These sizes exclude OS stack guard pages, but include -// the VM guard pages. -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; +// Minimum usable stack sizes required to get to user code. Space for VM +// guard 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) { @@ -557,7 +557,7 @@ // the same page size as the heap. Returning page_size() here can // cause 16 guard pages which we want to avoid. Thus we return 4K // which will be rounded to the real page size by the OS. - return (thr_type == java_thread ? 0 : 4*K); + return ((thr_type == java_thread || thr_type == os::compiler_thread) ? 0 : 4*K); } ///////////////////////////////////////////////////////////////////////////// --- old/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp 2016-11-16 16:45:33.887639000 +0100 +++ new/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp 2016-11-16 16:45:33.729632000 +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 VM +// 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-11-16 16:45:35.307714000 +0100 +++ new/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp 2016-11-16 16:45:35.161707000 +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 VM +// 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 @@ -487,7 +489,7 @@ size_t os::Linux::default_guard_size(os::ThreadType thr_type) { // Creating guard page is very expensive. Java thread has HotSpot // guard page, only enable glibc guard page for non-Java threads. - return (thr_type == java_thread ? 0 : page_size()); + return ((thr_type == java_thread || thr_type == os::compiler_thread) ? 0 : page_size()); } // Java thread: --- old/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp 2016-11-16 16:45:37.152812000 +0100 +++ new/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp 2016-11-16 16:45:36.879795000 +0100 @@ -535,13 +535,15 @@ //////////////////////////////////////////////////////////////////////////////// // thread stack -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; +// Minimum usable stack sizes required to get to user code. Space for VM +// 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; } @@ -549,7 +551,7 @@ size_t os::Linux::default_guard_size(os::ThreadType thr_type) { // Creating guard page is very expensive. Java thread has HotSpot // guard page, only enable glibc guard page for non-Java threads. - return (thr_type == java_thread ? 0 : page_size()); + return ((thr_type == java_thread || thr_type == os::compiler_thread) ? 0 : page_size()); } // Java thread: --- old/src/os_cpu/linux_s390/vm/os_linux_s390.cpp 2016-11-16 16:45:38.534880000 +0100 +++ new/src/os_cpu/linux_s390/vm/os_linux_s390.cpp 2016-11-16 16:45:38.302869000 +0100 @@ -473,11 +473,11 @@ //////////////////////////////////////////////////////////////////////////////// // thread stack -// These sizes exclude OS stack guard pages, but include -// the VM guard pages. -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; +// Minimum usable stack sizes required to get to user code. Space for VM +// 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) { @@ -489,7 +489,7 @@ size_t os::Linux::default_guard_size(os::ThreadType thr_type) { // Creating guard page is very expensive. Java thread has HotSpot // guard page, only enable glibc guard page for non-Java threads. - return (thr_type == java_thread ? 0 : page_size()); + return ((thr_type == java_thread || thr_type == os::compiler_thread) ? 0 : page_size()); } // Java thread: --- old/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp 2016-11-16 16:45:39.490931000 +0100 +++ new/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp 2016-11-16 16:45:39.323920000 +0100 @@ -732,8 +732,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; +// These sizes exclude OS stack guard pages, but include +// the VM guard pages. +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 @@ -746,7 +748,7 @@ size_t os::Linux::default_guard_size(os::ThreadType thr_type) { // Creating guard page is very expensive. Java thread has HotSpot // guard page, only enable glibc guard page for non-Java threads. - return (thr_type == java_thread ? 0 : page_size()); + return ((thr_type == java_thread || thr_type == os::compiler_thread) ? 0 : page_size()); } #ifndef PRODUCT --- old/src/os_cpu/linux_x86/vm/os_linux_x86.cpp 2016-11-16 16:45:40.633991000 +0100 +++ new/src/os_cpu/linux_x86/vm/os_linux_x86.cpp 2016-11-16 16:45:40.491984000 +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 VM +// 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) { @@ -701,7 +701,7 @@ size_t os::Linux::default_guard_size(os::ThreadType thr_type) { // Creating guard page is very expensive. Java thread has HotSpot // guard page, only enable glibc guard page for non-Java threads. - return (thr_type == java_thread ? 0 : page_size()); + return ((thr_type == java_thread || thr_type == os::compiler_thread) ? 0 : page_size()); } // Java thread: --- old/src/os_cpu/linux_zero/vm/os_linux_zero.cpp 2016-11-16 16:45:41.647041000 +0100 +++ new/src/os_cpu/linux_zero/vm/os_linux_zero.cpp 2016-11-16 16:45:41.507034000 +0100 @@ -323,7 +323,7 @@ size_t os::Linux::default_guard_size(os::ThreadType thr_type) { // Only enable glibc guard pages for non-Java threads // (Java threads have HotSpot guard pages) - return (thr_type == java_thread ? 0 : page_size()); + return ((thr_type == java_thread || thr_type == os::compiler_thread) ? 0 : page_size()); } static void current_stack_region(address *bottom, size_t *size) { --- old/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp 2016-11-16 16:45:42.634092000 +0100 +++ new/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp 2016-11-16 16:45:42.487084000 +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 VM +// 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-11-16 16:45:43.589141000 +0100 +++ new/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp 2016-11-16 16:45:43.440135000 +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 VM +// 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-11-16 16:45:44.540191000 +0100 +++ new/src/share/vm/runtime/os.hpp 2016-11-16 16:45:44.387182000 +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