456 ShouldNotReachHere();
457 return false;
458 }
459
460 void os::Linux::init_thread_fpu_state(void) {
461 // Nothing to do on z/Architecture.
462 }
463
464 int os::Linux::get_fpu_control_word(void) {
465 // Nothing to do on z/Architecture.
466 return 0;
467 }
468
469 void os::Linux::set_fpu_control_word(int fpu_control) {
470 // Nothing to do on z/Architecture.
471 }
472
473 ////////////////////////////////////////////////////////////////////////////////
474 // thread stack
475
476 size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K;
477 size_t os::Posix::_java_thread_min_stack_allowed = 128 * K;
478 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * 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 : 1024 * K);
484 return s;
485 }
486
487 size_t os::Linux::default_guard_size(os::ThreadType thr_type) {
488 // z/Architecture: put 2 guard pages right in the middle of thread stack. This value
489 // should be consistent with the value used by register stack handling code.
490 return 2 * page_size();
491 }
492
493 // Java thread:
494 //
495 // Low memory addresses
496 // +------------------------+
497 // | |\
498 // | glibc guard page | - Right in the middle of stack, 2 pages
499 // | |/
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 | - Right in the middle of stack, 2 pages
516 // | |/
517 // P1 +------------------------+ Thread::stack_base() - Thread::stack_size()
518 // | |\
519 // | Normal Stack | -
520 // | |/
521 // P2 +------------------------+ Thread::stack_base()
522 //
523 // ** P2 is the address returned from pthread_attr_getstackaddr(), P2 - P1
524 // is the stack size returned by pthread_attr_getstacksize().
525
526
527 static void current_stack_region(address * bottom, size_t * size) {
528 if (os::Linux::is_initial_thread()) {
529 // Initial thread needs special handling because pthread_getattr_np()
530 // may return bogus value.
531 *bottom = os::Linux::initial_thread_stack_bottom();
532 *size = os::Linux::initial_thread_stack_size();
533 } else {
534 pthread_attr_t attr;
535
536 int rslt = pthread_getattr_np(pthread_self(), &attr);
537
538 // JVM needs to know exact stack location, abort if it fails
539 if (rslt != 0) {
540 if (rslt == ENOMEM) {
541 vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
542 } else {
543 fatal("pthread_getattr_np failed with errno = %d", rslt);
544 }
545 }
546
547 if (pthread_attr_getstack(&attr, (void **)bottom, size) != 0) {
548 fatal("Can not locate current stack attributes!");
549 }
550
551 pthread_attr_destroy(&attr);
552
553 }
554 assert(os::current_stack_pointer() >= *bottom &&
555 os::current_stack_pointer() < *bottom + *size, "just checking");
556 }
557
558 address os::current_stack_base() {
559 address bottom;
560 size_t size;
561 current_stack_region(&bottom, &size);
562 return (bottom + size);
563 }
564
565 size_t os::current_stack_size() {
566 // stack size includes normal stack and HotSpot guard pages
567 address bottom;
568 size_t size;
569 current_stack_region(&bottom, &size);
570 return size;
571 }
572
573 /////////////////////////////////////////////////////////////////////////////
574 // helper functions for fatal error handler
575
576 void os::print_context(outputStream *st, const void *context) {
577 if (context == NULL) return;
578
579 const ucontext_t* uc = (const ucontext_t*)context;
580
581 st->print_cr("Processor state:");
582 st->print_cr("----------------");
583 st->print_cr(" ip = " INTPTR_FORMAT " ", uc->uc_mcontext.psw.addr);
584 st->print_cr(" proc mask = " INTPTR_FORMAT " ", uc->uc_mcontext.psw.mask);
585 st->print_cr(" fpc reg = 0x%8.8x " , uc->uc_mcontext.fpregs.fpc);
586 st->cr();
587
588 st->print_cr("General Purpose Registers:");
589 st->print_cr("--------------------------");
590 for( int i = 0; i < 16; i+=2 ) {
|
456 ShouldNotReachHere();
457 return false;
458 }
459
460 void os::Linux::init_thread_fpu_state(void) {
461 // Nothing to do on z/Architecture.
462 }
463
464 int os::Linux::get_fpu_control_word(void) {
465 // Nothing to do on z/Architecture.
466 return 0;
467 }
468
469 void os::Linux::set_fpu_control_word(int fpu_control) {
470 // Nothing to do on z/Architecture.
471 }
472
473 ////////////////////////////////////////////////////////////////////////////////
474 // thread stack
475
476 // These sizes exclude libc stack guard pages, but include
477 // the HotSpot guard pages.
478 size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K;
479 size_t os::Posix::_java_thread_min_stack_allowed = 236 * K;
480 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K;
481
482 // Return default stack size for thr_type.
483 size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
484 // Default stack size (compiler thread needs larger stack).
485 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K);
486 return s;
487 }
488
489 /////////////////////////////////////////////////////////////////////////////
490 // helper functions for fatal error handler
491
492 void os::print_context(outputStream *st, const void *context) {
493 if (context == NULL) return;
494
495 const ucontext_t* uc = (const ucontext_t*)context;
496
497 st->print_cr("Processor state:");
498 st->print_cr("----------------");
499 st->print_cr(" ip = " INTPTR_FORMAT " ", uc->uc_mcontext.psw.addr);
500 st->print_cr(" proc mask = " INTPTR_FORMAT " ", uc->uc_mcontext.psw.mask);
501 st->print_cr(" fpc reg = 0x%8.8x " , uc->uc_mcontext.fpregs.fpc);
502 st->cr();
503
504 st->print_cr("General Purpose Registers:");
505 st->print_cr("--------------------------");
506 for( int i = 0; i < 16; i+=2 ) {
|