< prev index next >

src/os_cpu/linux_aarch64/vm/os_linux_aarch64.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


 467 }
 468 
 469 bool os::is_allocatable(size_t bytes) {
 470   return true;
 471 }
 472 
 473 ////////////////////////////////////////////////////////////////////////////////
 474 // thread stack
 475 
 476 size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K;
 477 size_t os::Posix::_java_thread_min_stack_allowed = 64 * K;
 478 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
 479 
 480 // return default stack size for thr_type
 481 size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
 482   // default stack size (compiler thread needs larger stack)
 483   size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
 484   return s;
 485 }
 486 
 487 size_t os::Linux::default_guard_size(os::ThreadType thr_type) {
 488   // Creating guard page is very expensive. Java thread has HotSpot
 489   // guard page, only enable glibc guard page for non-Java threads.
 490   return (thr_type == java_thread ? 0 : page_size());
 491 }
 492 
 493 // Java thread:
 494 //
 495 //   Low memory addresses
 496 //    +------------------------+
 497 //    |                        |\  JavaThread created by VM does not have glibc
 498 //    |    glibc guard page    | - guard, attached Java thread usually has
 499 //    |                        |/  1 page glibc guard.
 500 // P1 +------------------------+ Thread::stack_base() - Thread::stack_size()
 501 //    |                        |\
 502 //    |  HotSpot Guard Pages   | - red and yellow pages
 503 //    |                        |/
 504 //    +------------------------+ JavaThread::stack_yellow_zone_base()
 505 //    |                        |\
 506 //    |      Normal Stack      | -
 507 //    |                        |/
 508 // P2 +------------------------+ Thread::stack_base()
 509 //
 510 // Non-Java thread:
 511 //
 512 //   Low memory addresses
 513 //    +------------------------+
 514 //    |                        |\
 515 //    |  glibc guard page      | - usually 1 page
 516 //    |                        |/
 517 // P1 +------------------------+ Thread::stack_base() - Thread::stack_size()
 518 //    |                        |\
 519 //    |      Normal Stack      | -
 520 //    |                        |/
 521 // P2 +------------------------+ Thread::stack_base()
 522 //
 523 // ** P1 (aka bottom) and size ( P2 = P1 - size) are the address and stack size returned from
 524 //    pthread_attr_getstack()
 525 
 526 static void current_stack_region(address * bottom, size_t * size) {
 527   if (os::Linux::is_initial_thread()) {
 528      // initial thread needs special handling because pthread_getattr_np()
 529      // may return bogus value.
 530      *bottom = os::Linux::initial_thread_stack_bottom();
 531      *size   = os::Linux::initial_thread_stack_size();
 532   } else {
 533      pthread_attr_t attr;
 534 
 535      int rslt = pthread_getattr_np(pthread_self(), &attr);
 536 
 537      // JVM needs to know exact stack location, abort if it fails
 538      if (rslt != 0) {
 539        if (rslt == ENOMEM) {
 540          vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
 541        } else {
 542          fatal("pthread_getattr_np failed with errno = %d", rslt);
 543        }
 544      }
 545 
 546      if (pthread_attr_getstack(&attr, (void **)bottom, size) != 0) {
 547          fatal("Can not locate current stack attributes!");
 548      }
 549 
 550      pthread_attr_destroy(&attr);
 551 
 552   }
 553   assert(os::current_stack_pointer() >= *bottom &&
 554          os::current_stack_pointer() < *bottom + *size, "just checking");
 555 }
 556 
 557 address os::current_stack_base() {
 558   address bottom;
 559   size_t size;
 560   current_stack_region(&bottom, &size);
 561   return (bottom + size);
 562 }
 563 
 564 size_t os::current_stack_size() {
 565   // stack size includes normal stack and HotSpot guard pages
 566   address bottom;
 567   size_t size;
 568   current_stack_region(&bottom, &size);
 569   return size;
 570 }
 571 
 572 /////////////////////////////////////////////////////////////////////////////
 573 // helper functions for fatal error handler
 574 
 575 void os::print_context(outputStream *st, const void *context) {
 576   if (context == NULL) return;
 577 
 578   const ucontext_t *uc = (const ucontext_t*)context;
 579   st->print_cr("Registers:");
 580 #ifdef BUILTIN_SIM
 581   st->print(  "RAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RAX]);
 582   st->print(", RBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBX]);
 583   st->print(", RCX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RCX]);
 584   st->print(", RDX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDX]);
 585   st->cr();
 586   st->print(  "RSP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSP]);
 587   st->print(", RBP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBP]);
 588   st->print(", RSI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSI]);
 589   st->print(", RDI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDI]);
 590   st->cr();
 591   st->print(  "R8 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R8]);




 467 }
 468 
 469 bool os::is_allocatable(size_t bytes) {
 470   return true;
 471 }
 472 
 473 ////////////////////////////////////////////////////////////////////////////////
 474 // thread stack
 475 
 476 size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K;
 477 size_t os::Posix::_java_thread_min_stack_allowed = 64 * K;
 478 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
 479 
 480 // return default stack size for thr_type
 481 size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
 482   // default stack size (compiler thread needs larger stack)
 483   size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
 484   return s;
 485 }
 486 





















































































 487 /////////////////////////////////////////////////////////////////////////////
 488 // helper functions for fatal error handler
 489 
 490 void os::print_context(outputStream *st, const void *context) {
 491   if (context == NULL) return;
 492 
 493   const ucontext_t *uc = (const ucontext_t*)context;
 494   st->print_cr("Registers:");
 495 #ifdef BUILTIN_SIM
 496   st->print(  "RAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RAX]);
 497   st->print(", RBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBX]);
 498   st->print(", RCX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RCX]);
 499   st->print(", RDX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDX]);
 500   st->cr();
 501   st->print(  "RSP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSP]);
 502   st->print(", RBP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBP]);
 503   st->print(", RSI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSI]);
 504   st->print(", RDI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDI]);
 505   st->cr();
 506   st->print(  "R8 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R8]);


< prev index next >