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:
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);
|
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 OS stack guard pages, but include
477 // the VM guard pages.
478 size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K;
479 size_t os::Posix::_java_thread_min_stack_allowed = 128 * 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 size_t os::Linux::default_guard_size(os::ThreadType thr_type) {
490 // Creating guard page is very expensive. Java thread has HotSpot
491 // guard page, only enable glibc guard page for non-Java threads.
492 return (thr_type == java_thread ? 0 : page_size());
493 }
494
495 // Java thread:
496 //
497 // Low memory addresses
498 // +------------------------+
499 // | |\
500 // | glibc guard page | - Right in the middle of stack, 2 pages
501 // | |/
502 // P1 +------------------------+ Thread::stack_base() - Thread::stack_size()
503 // | |\
504 // | HotSpot Guard Pages | - red and yellow pages
505 // | |/
506 // +------------------------+ JavaThread::stack_yellow_zone_base()
507 // | |\
508 // | Normal Stack | -
509 // | |/
510 // P2 +------------------------+ Thread::stack_base()
511 //
512 // Non-Java thread:
532 // may return bogus value.
533 *bottom = os::Linux::initial_thread_stack_bottom();
534 *size = os::Linux::initial_thread_stack_size();
535 } else {
536 pthread_attr_t attr;
537
538 int rslt = pthread_getattr_np(pthread_self(), &attr);
539
540 // JVM needs to know exact stack location, abort if it fails
541 if (rslt != 0) {
542 if (rslt == ENOMEM) {
543 vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
544 } else {
545 fatal("pthread_getattr_np failed with errno = %d", rslt);
546 }
547 }
548
549 if (pthread_attr_getstack(&attr, (void **)bottom, size) != 0) {
550 fatal("Can not locate current stack attributes!");
551 }
552
553 // Work around NPTL stack guard error.
554 size_t guard_size = 0;
555 pthread_attr_getguardsize(&attr, &guard_size);
556 *bottom += guard_size;
557 *size -= guard_size;
558
559 pthread_attr_destroy(&attr);
560
561 }
562 assert(os::current_stack_pointer() >= *bottom &&
563 os::current_stack_pointer() < *bottom + *size, "just checking");
564 }
565
566 address os::current_stack_base() {
567 address bottom;
568 size_t size;
569 current_stack_region(&bottom, &size);
570 return (bottom + size);
571 }
572
573 size_t os::current_stack_size() {
574 // stack size includes normal stack and HotSpot guard pages
575 address bottom;
576 size_t size;
577 current_stack_region(&bottom, &size);
|