< prev index next >

src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp

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


 518 
 519 void os::Linux::init_thread_fpu_state(void) {
 520   // Disable FP exceptions.
 521   __asm__ __volatile__ ("mtfsfi 6,0");
 522 }
 523 
 524 int os::Linux::get_fpu_control_word(void) {
 525   // x86 has problems with FPU precision after pthread_cond_timedwait().
 526   // nothing to do on ppc64.
 527   return 0;
 528 }
 529 
 530 void os::Linux::set_fpu_control_word(int fpu_control) {
 531   // x86 has problems with FPU precision after pthread_cond_timedwait().
 532   // nothing to do on ppc64.
 533 }
 534 
 535 ////////////////////////////////////////////////////////////////////////////////
 536 // thread stack
 537 
 538 size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K;
 539 size_t os::Posix::_java_thread_min_stack_allowed = 128 * K;
 540 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K;
 541 
 542 // return default stack size for thr_type
 543 size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
 544   // default stack size (compiler thread needs larger stack)
 545   size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K);
 546   return s;
 547 }
 548 
 549 size_t os::Linux::default_guard_size(os::ThreadType thr_type) {
 550   return 2 * page_size();
 551 }
 552 
 553 // Java thread:
 554 //
 555 //   Low memory addresses
 556 //    +------------------------+
 557 //    |                        |\  JavaThread created by VM does not have glibc
 558 //    |    glibc guard page    | - guard, attached Java thread usually has
 559 //    |                        |/  1 page glibc guard.
 560 // P1 +------------------------+ Thread::stack_base() - Thread::stack_size()
 561 //    |                        |\
 562 //    |  HotSpot Guard Pages   | - red and yellow pages
 563 //    |                        |/
 564 //    +------------------------+ JavaThread::stack_yellow_zone_base()
 565 //    |                        |\
 566 //    |      Normal Stack      | -
 567 //    |                        |/
 568 // P2 +------------------------+ Thread::stack_base()
 569 //
 570 // Non-Java thread:
 571 //
 572 //   Low memory addresses
 573 //    +------------------------+
 574 //    |                        |\
 575 //    |  glibc guard page      | - usually 1 page
 576 //    |                        |/
 577 // P1 +------------------------+ Thread::stack_base() - Thread::stack_size()
 578 //    |                        |\
 579 //    |      Normal Stack      | -
 580 //    |                        |/
 581 // P2 +------------------------+ Thread::stack_base()
 582 //
 583 // ** P1 (aka bottom) and size ( P2 = P1 - size) are the address and stack size returned from
 584 //    pthread_attr_getstack()
 585 
 586 static void current_stack_region(address * bottom, size_t * size) {
 587   if (os::Linux::is_initial_thread()) {
 588      // initial thread needs special handling because pthread_getattr_np()
 589      // may return bogus value.
 590     *bottom = os::Linux::initial_thread_stack_bottom();
 591     *size   = os::Linux::initial_thread_stack_size();
 592   } else {
 593     pthread_attr_t attr;
 594 
 595     int rslt = pthread_getattr_np(pthread_self(), &attr);
 596 
 597     // JVM needs to know exact stack location, abort if it fails
 598     if (rslt != 0) {
 599       if (rslt == ENOMEM) {
 600         vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
 601       } else {
 602         fatal("pthread_getattr_np failed with errno = %d", rslt);
 603       }
 604     }
 605 
 606     if (pthread_attr_getstack(&attr, (void **)bottom, size) != 0) {
 607       fatal("Can not locate current stack attributes!");
 608     }
 609 
 610     pthread_attr_destroy(&attr);
 611 
 612   }
 613   assert(os::current_stack_pointer() >= *bottom &&
 614          os::current_stack_pointer() < *bottom + *size, "just checking");
 615 }
 616 
 617 address os::current_stack_base() {
 618   address bottom;
 619   size_t size;
 620   current_stack_region(&bottom, &size);
 621   return (bottom + size);
 622 }
 623 
 624 size_t os::current_stack_size() {
 625   // stack size includes normal stack and HotSpot guard pages
 626   address bottom;
 627   size_t size;
 628   current_stack_region(&bottom, &size);
 629   return size;
 630 }
 631 
 632 /////////////////////////////////////////////////////////////////////////////
 633 // helper functions for fatal error handler
 634 
 635 void os::print_context(outputStream *st, const void *context) {
 636   if (context == NULL) return;
 637 
 638   const ucontext_t* uc = (const ucontext_t*)context;
 639 
 640   st->print_cr("Registers:");
 641   st->print("pc =" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->nip);
 642   st->print("lr =" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->link);
 643   st->print("ctr=" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->ctr);
 644   st->cr();
 645   for (int i = 0; i < 32; i++) {
 646     st->print("r%-2d=" INTPTR_FORMAT "  ", i, uc->uc_mcontext.regs->gpr[i]);
 647     if (i % 3 == 2) st->cr();
 648   }
 649   st->cr();




 518 
 519 void os::Linux::init_thread_fpu_state(void) {
 520   // Disable FP exceptions.
 521   __asm__ __volatile__ ("mtfsfi 6,0");
 522 }
 523 
 524 int os::Linux::get_fpu_control_word(void) {
 525   // x86 has problems with FPU precision after pthread_cond_timedwait().
 526   // nothing to do on ppc64.
 527   return 0;
 528 }
 529 
 530 void os::Linux::set_fpu_control_word(int fpu_control) {
 531   // x86 has problems with FPU precision after pthread_cond_timedwait().
 532   // nothing to do on ppc64.
 533 }
 534 
 535 ////////////////////////////////////////////////////////////////////////////////
 536 // thread stack
 537 
 538 size_t os::Posix::_compiler_thread_min_stack_allowed = 384 * K;
 539 size_t os::Posix::_java_thread_min_stack_allowed = 384 * K;
 540 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K;
 541 
 542 // return default stack size for thr_type
 543 size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
 544   // default stack size (compiler thread needs larger stack)
 545   size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K);
 546   return s;



















































































 547 }
 548 
 549 /////////////////////////////////////////////////////////////////////////////
 550 // helper functions for fatal error handler
 551 
 552 void os::print_context(outputStream *st, const void *context) {
 553   if (context == NULL) return;
 554 
 555   const ucontext_t* uc = (const ucontext_t*)context;
 556 
 557   st->print_cr("Registers:");
 558   st->print("pc =" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->nip);
 559   st->print("lr =" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->link);
 560   st->print("ctr=" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->ctr);
 561   st->cr();
 562   for (int i = 0; i < 32; i++) {
 563     st->print("r%-2d=" INTPTR_FORMAT "  ", i, uc->uc_mcontext.regs->gpr[i]);
 564     if (i % 3 == 2) st->cr();
 565   }
 566   st->cr();


< prev index next >