821 #else 822 823 if (bytes < 2 * G) { 824 return true; 825 } 826 827 char* addr = reserve_memory(bytes, NULL); 828 829 if (addr != NULL) { 830 release_memory(addr, bytes); 831 } 832 833 return addr != NULL; 834 #endif // AMD64 835 } 836 837 //////////////////////////////////////////////////////////////////////////////// 838 // thread stack 839 840 #ifdef AMD64 841 size_t os::Bsd::min_stack_allowed = 64 * K; 842 #else 843 size_t os::Bsd::min_stack_allowed = (48 DEBUG_ONLY(+4))*K; 844 845 #ifdef __GNUC__ 846 #define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;}) 847 #endif 848 849 #endif // AMD64 850 851 // return default stack size for thr_type 852 size_t os::Bsd::default_stack_size(os::ThreadType thr_type) { 853 // default stack size (compiler thread needs larger stack) 854 #ifdef AMD64 855 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); 856 #else 857 size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K); 858 #endif // AMD64 859 return s; 860 } 861 862 size_t os::Bsd::default_guard_size(os::ThreadType thr_type) { 863 // Creating guard page is very expensive. Java thread has HotSpot 864 // guard page, only enable glibc guard page for non-Java threads. 865 return (thr_type == java_thread ? 0 : page_size()); 866 } 867 868 // Java thread: 869 // 870 // Low memory addresses 871 // +------------------------+ 872 // | |\ JavaThread created by VM does not have glibc 873 // | glibc guard page | - guard, attached Java thread usually has 874 // | |/ 1 page glibc guard. 875 // P1 +------------------------+ Thread::stack_base() - Thread::stack_size() 876 // | |\ 877 // | HotSpot Guard Pages | - red and yellow pages 878 // | |/ 879 // +------------------------+ JavaThread::stack_yellow_zone_base() 880 // | |\ 881 // | Normal Stack | - 882 // | |/ 883 // P2 +------------------------+ Thread::stack_base() 884 // 885 // Non-Java thread: 886 // | 821 #else 822 823 if (bytes < 2 * G) { 824 return true; 825 } 826 827 char* addr = reserve_memory(bytes, NULL); 828 829 if (addr != NULL) { 830 release_memory(addr, bytes); 831 } 832 833 return addr != NULL; 834 #endif // AMD64 835 } 836 837 //////////////////////////////////////////////////////////////////////////////// 838 // thread stack 839 840 #ifdef AMD64 841 size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K; 842 size_t os::Posix::_java_thread_min_stack_allowed = 64 * K; 843 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K; 844 #else 845 size_t os::Posix::_compiler_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; 846 size_t os::Posix::_java_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; 847 size_t os::Posix::_vm_internal_thread_min_stack_allowed = (48 DEBUG_ONLY(+ 4)) * K; 848 849 #ifdef __GNUC__ 850 #define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;}) 851 #endif 852 853 #endif // AMD64 854 855 // return default stack size for thr_type 856 size_t os::Posix::default_stack_size(os::ThreadType thr_type) { 857 // default stack size (compiler thread needs larger stack) 858 #ifdef AMD64 859 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); 860 #else 861 size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K); 862 #endif // AMD64 863 return s; 864 } 865 866 867 // Java thread: 868 // 869 // Low memory addresses 870 // +------------------------+ 871 // | |\ JavaThread created by VM does not have glibc 872 // | glibc guard page | - guard, attached Java thread usually has 873 // | |/ 1 page glibc guard. 874 // P1 +------------------------+ Thread::stack_base() - Thread::stack_size() 875 // | |\ 876 // | HotSpot Guard Pages | - red and yellow pages 877 // | |/ 878 // +------------------------+ JavaThread::stack_yellow_zone_base() 879 // | |\ 880 // | Normal Stack | - 881 // | |/ 882 // P2 +------------------------+ Thread::stack_base() 883 // 884 // Non-Java thread: 885 // |