< prev index next >

src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp

Print this page
rev 12363 : 8169373: Work around linux NPTL stack guard error.
Summary: Also skip libc guard page for compiler thread, merge similar code on linux platforms, and streamline libc guard page handling on linuxs390, linuxppc, aixppc.
Reviewed-by: dholmes, dcubed, kvn


 293   size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K);
 294 #endif // _LP64
 295   return s;
 296 }
 297 
 298 static void current_stack_region(address *bottom, size_t *size) {
 299   address stack_bottom;
 300   address stack_top;
 301   size_t stack_bytes;
 302 
 303 #ifdef __APPLE__
 304   pthread_t self = pthread_self();
 305   stack_top = (address) pthread_get_stackaddr_np(self);
 306   stack_bytes = pthread_get_stacksize_np(self);
 307   stack_bottom = stack_top - stack_bytes;
 308 #elif defined(__OpenBSD__)
 309   stack_t ss;
 310   int rslt = pthread_stackseg_np(pthread_self(), &ss);
 311 
 312   if (rslt != 0)
 313     fatal("pthread_stackseg_np failed with err = " INT32_FORMAT, rslt);
 314 
 315   stack_top = (address) ss.ss_sp;
 316   stack_bytes  = ss.ss_size;
 317   stack_bottom = stack_top - stack_bytes;
 318 #else
 319   pthread_attr_t attr;
 320 
 321   int rslt = pthread_attr_init(&attr);
 322 
 323   // JVM needs to know exact stack location, abort if it fails
 324   if (rslt != 0)
 325     fatal("pthread_attr_init failed with err = " INT32_FORMAT, rslt);
 326 
 327   rslt = pthread_attr_get_np(pthread_self(), &attr);
 328 
 329   if (rslt != 0)
 330     fatal("pthread_attr_get_np failed with err = " INT32_FORMAT, rslt);
 331 
 332   if (pthread_attr_getstackaddr(&attr, (void **) &stack_bottom) != 0 ||
 333       pthread_attr_getstacksize(&attr, &stack_bytes) != 0) {
 334     fatal("Can not locate current stack attributes!");
 335   }
 336 
 337   pthread_attr_destroy(&attr);
 338 
 339   stack_top = stack_bottom + stack_bytes;
 340 #endif
 341 
 342   assert(os::current_stack_pointer() >= stack_bottom, "should do");
 343   assert(os::current_stack_pointer() < stack_top, "should do");
 344 
 345   *bottom = stack_bottom;
 346   *size = stack_top - stack_bottom;
 347 }
 348 
 349 address os::current_stack_base() {
 350   address bottom;




 293   size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K);
 294 #endif // _LP64
 295   return s;
 296 }
 297 
 298 static void current_stack_region(address *bottom, size_t *size) {
 299   address stack_bottom;
 300   address stack_top;
 301   size_t stack_bytes;
 302 
 303 #ifdef __APPLE__
 304   pthread_t self = pthread_self();
 305   stack_top = (address) pthread_get_stackaddr_np(self);
 306   stack_bytes = pthread_get_stacksize_np(self);
 307   stack_bottom = stack_top - stack_bytes;
 308 #elif defined(__OpenBSD__)
 309   stack_t ss;
 310   int rslt = pthread_stackseg_np(pthread_self(), &ss);
 311 
 312   if (rslt != 0)
 313     fatal("pthread_stackseg_np failed with error = " INT32_FORMAT, rslt);
 314 
 315   stack_top = (address) ss.ss_sp;
 316   stack_bytes  = ss.ss_size;
 317   stack_bottom = stack_top - stack_bytes;
 318 #else
 319   pthread_attr_t attr;
 320 
 321   int rslt = pthread_attr_init(&attr);
 322 
 323   // JVM needs to know exact stack location, abort if it fails
 324   if (rslt != 0)
 325     fatal("pthread_attr_init failed with error = " INT32_FORMAT, rslt);
 326 
 327   rslt = pthread_attr_get_np(pthread_self(), &attr);
 328 
 329   if (rslt != 0)
 330     fatal("pthread_attr_get_np failed with error = " INT32_FORMAT, rslt);
 331 
 332   if (pthread_attr_getstackaddr(&attr, (void **) &stack_bottom) != 0 ||
 333       pthread_attr_getstacksize(&attr, &stack_bytes) != 0) {
 334     fatal("Can not locate current stack attributes!");
 335   }
 336 
 337   pthread_attr_destroy(&attr);
 338 
 339   stack_top = stack_bottom + stack_bytes;
 340 #endif
 341 
 342   assert(os::current_stack_pointer() >= stack_bottom, "should do");
 343   assert(os::current_stack_pointer() < stack_top, "should do");
 344 
 345   *bottom = stack_bottom;
 346   *size = stack_top - stack_bottom;
 347 }
 348 
 349 address os::current_stack_base() {
 350   address bottom;


< prev index next >