811 // 812 // Low memory addresses 813 // +------------------------+ 814 // | |\ 815 // | glibc guard page | - usually 1 page 816 // | |/ 817 // P1 +------------------------+ Thread::stack_base() - Thread::stack_size() 818 // | |\ 819 // | Normal Stack | - 820 // | |/ 821 // P2 +------------------------+ Thread::stack_base() 822 // 823 // ** P1 (aka bottom) and size ( P2 = P1 - size) are the address and stack size returned from 824 // pthread_attr_getstack() 825 826 static void current_stack_region(address * bottom, size_t * size) { 827 #ifdef __APPLE__ 828 pthread_t self = pthread_self(); 829 void *stacktop = pthread_get_stackaddr_np(self); 830 *size = pthread_get_stacksize_np(self); 831 *bottom = (address) stacktop - *size; 832 #elif defined(__OpenBSD__) 833 stack_t ss; 834 int rslt = pthread_stackseg_np(pthread_self(), &ss); 835 836 if (rslt != 0) 837 fatal(err_msg("pthread_stackseg_np failed with err = %d", rslt)); 838 839 *bottom = (address)((char *)ss.ss_sp - ss.ss_size); 840 *size = ss.ss_size; 841 #else 842 pthread_attr_t attr; 843 844 int rslt = pthread_attr_init(&attr); 845 846 // JVM needs to know exact stack location, abort if it fails 847 if (rslt != 0) 848 fatal(err_msg("pthread_attr_init failed with err = %d", rslt)); 849 850 rslt = pthread_attr_get_np(pthread_self(), &attr); | 811 // 812 // Low memory addresses 813 // +------------------------+ 814 // | |\ 815 // | glibc guard page | - usually 1 page 816 // | |/ 817 // P1 +------------------------+ Thread::stack_base() - Thread::stack_size() 818 // | |\ 819 // | Normal Stack | - 820 // | |/ 821 // P2 +------------------------+ Thread::stack_base() 822 // 823 // ** P1 (aka bottom) and size ( P2 = P1 - size) are the address and stack size returned from 824 // pthread_attr_getstack() 825 826 static void current_stack_region(address * bottom, size_t * size) { 827 #ifdef __APPLE__ 828 pthread_t self = pthread_self(); 829 void *stacktop = pthread_get_stackaddr_np(self); 830 *size = pthread_get_stacksize_np(self); 831 // workaround for 10.9 (Mavericks) 832 // pthread_get_stacksize_np returns 128 pages even though the actual size is 2048 pages 833 if (pthread_main_np() == 1) { 834 #define DEFAULT_MAIN_THREAD_STACK_PAGES 2048 835 if (*size < (DEFAULT_MAIN_THREAD_STACK_PAGES*(size_t)getpagesize())) { 836 *size = (DEFAULT_MAIN_THREAD_STACK_PAGES*getpagesize()); 837 } 838 } 839 *bottom = (address) stacktop - *size; 840 #elif defined(__OpenBSD__) 841 stack_t ss; 842 int rslt = pthread_stackseg_np(pthread_self(), &ss); 843 844 if (rslt != 0) 845 fatal(err_msg("pthread_stackseg_np failed with err = %d", rslt)); 846 847 *bottom = (address)((char *)ss.ss_sp - ss.ss_size); 848 *size = ss.ss_size; 849 #else 850 pthread_attr_t attr; 851 852 int rslt = pthread_attr_init(&attr); 853 854 // JVM needs to know exact stack location, abort if it fails 855 if (rslt != 0) 856 fatal(err_msg("pthread_attr_init failed with err = %d", rslt)); 857 858 rslt = pthread_attr_get_np(pthread_self(), &attr); |