< prev index next >

src/os_cpu/linux_zero/vm/os_linux_zero.cpp

Print this page




 333   }
 334 
 335   address stack_bottom;
 336   size_t stack_bytes;
 337   res = pthread_attr_getstack(&attr, (void **) &stack_bottom, &stack_bytes);
 338   if (res != 0) {
 339     fatal("pthread_attr_getstack failed with error = %d", res);
 340   }
 341   address stack_top = stack_bottom + stack_bytes;
 342 
 343   // The block of memory returned by pthread_attr_getstack() includes
 344   // guard pages where present.  We need to trim these off.
 345   size_t page_bytes = os::Linux::page_size();
 346   assert(((intptr_t) stack_bottom & (page_bytes - 1)) == 0, "unaligned stack");
 347 
 348   size_t guard_bytes;
 349   res = pthread_attr_getguardsize(&attr, &guard_bytes);
 350   if (res != 0) {
 351     fatal("pthread_attr_getguardsize failed with errno = %d", res);
 352   }
 353   int guard_pages = align_size_up(guard_bytes, page_bytes) / page_bytes;
 354   assert(guard_bytes == guard_pages * page_bytes, "unaligned guard");
 355 
 356 #ifdef IA64
 357   // IA64 has two stacks sharing the same area of memory, a normal
 358   // stack growing downwards and a register stack growing upwards.
 359   // Guard pages, if present, are in the centre.  This code splits
 360   // the stack in two even without guard pages, though in theory
 361   // there's nothing to stop us allocating more to the normal stack
 362   // or more to the register stack if one or the other were found
 363   // to grow faster.
 364   int total_pages = align_size_down(stack_bytes, page_bytes) / page_bytes;
 365   stack_bottom += (total_pages - guard_pages) / 2 * page_bytes;
 366 #endif // IA64
 367 
 368   stack_bottom += guard_bytes;
 369 
 370   pthread_attr_destroy(&attr);
 371 
 372   // The initial thread has a growable stack, and the size reported
 373   // by pthread_attr_getstack is the maximum size it could possibly
 374   // be given what currently mapped.  This can be huge, so we cap it.
 375   if (os::Linux::is_initial_thread()) {
 376     stack_bytes = stack_top - stack_bottom;
 377 
 378     if (stack_bytes > JavaThread::stack_size_at_create())
 379       stack_bytes = JavaThread::stack_size_at_create();
 380 
 381     stack_bottom = stack_top - stack_bytes;
 382   }
 383 
 384   assert(os::current_stack_pointer() >= stack_bottom, "should do");




 333   }
 334 
 335   address stack_bottom;
 336   size_t stack_bytes;
 337   res = pthread_attr_getstack(&attr, (void **) &stack_bottom, &stack_bytes);
 338   if (res != 0) {
 339     fatal("pthread_attr_getstack failed with error = %d", res);
 340   }
 341   address stack_top = stack_bottom + stack_bytes;
 342 
 343   // The block of memory returned by pthread_attr_getstack() includes
 344   // guard pages where present.  We need to trim these off.
 345   size_t page_bytes = os::Linux::page_size();
 346   assert(((intptr_t) stack_bottom & (page_bytes - 1)) == 0, "unaligned stack");
 347 
 348   size_t guard_bytes;
 349   res = pthread_attr_getguardsize(&attr, &guard_bytes);
 350   if (res != 0) {
 351     fatal("pthread_attr_getguardsize failed with errno = %d", res);
 352   }
 353   int guard_pages = align_up(guard_bytes, page_bytes) / page_bytes;
 354   assert(guard_bytes == guard_pages * page_bytes, "unaligned guard");
 355 
 356 #ifdef IA64
 357   // IA64 has two stacks sharing the same area of memory, a normal
 358   // stack growing downwards and a register stack growing upwards.
 359   // Guard pages, if present, are in the centre.  This code splits
 360   // the stack in two even without guard pages, though in theory
 361   // there's nothing to stop us allocating more to the normal stack
 362   // or more to the register stack if one or the other were found
 363   // to grow faster.
 364   int total_pages = align_down(stack_bytes, page_bytes) / page_bytes;
 365   stack_bottom += (total_pages - guard_pages) / 2 * page_bytes;
 366 #endif // IA64
 367 
 368   stack_bottom += guard_bytes;
 369 
 370   pthread_attr_destroy(&attr);
 371 
 372   // The initial thread has a growable stack, and the size reported
 373   // by pthread_attr_getstack is the maximum size it could possibly
 374   // be given what currently mapped.  This can be huge, so we cap it.
 375   if (os::Linux::is_initial_thread()) {
 376     stack_bytes = stack_top - stack_bottom;
 377 
 378     if (stack_bytes > JavaThread::stack_size_at_create())
 379       stack_bytes = JavaThread::stack_size_at_create();
 380 
 381     stack_bottom = stack_top - stack_bytes;
 382   }
 383 
 384   assert(os::current_stack_pointer() >= stack_bottom, "should do");


< prev index next >