303 return addr != NULL;
304 #endif // _LP64
305 }
306
307 ///////////////////////////////////////////////////////////////////////////////
308 // thread stack
309
310 size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K;
311 size_t os::Posix::_java_thread_min_stack_allowed = 64 * K;
312 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
313
314 size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
315 #ifdef _LP64
316 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
317 #else
318 size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K);
319 #endif // _LP64
320 return s;
321 }
322
323 size_t os::Linux::default_guard_size(os::ThreadType thr_type) {
324 // Only enable glibc guard pages for non-Java threads
325 // (Java threads have HotSpot guard pages)
326 return (thr_type == java_thread ? 0 : page_size());
327 }
328
329 static void current_stack_region(address *bottom, size_t *size) {
330 pthread_attr_t attr;
331 int res = pthread_getattr_np(pthread_self(), &attr);
332 if (res != 0) {
333 if (res == ENOMEM) {
334 vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
335 }
336 else {
337 fatal("pthread_getattr_np failed with errno = %d", res);
338 }
339 }
340
341 address stack_bottom;
342 size_t stack_bytes;
343 res = pthread_attr_getstack(&attr, (void **) &stack_bottom, &stack_bytes);
344 if (res != 0) {
345 fatal("pthread_attr_getstack failed with errno = %d", res);
346 }
347 address stack_top = stack_bottom + stack_bytes;
348
349 // The block of memory returned by pthread_attr_getstack() includes
350 // guard pages where present. We need to trim these off.
351 size_t page_bytes = os::Linux::page_size();
352 assert(((intptr_t) stack_bottom & (page_bytes - 1)) == 0, "unaligned stack");
353
354 size_t guard_bytes;
355 res = pthread_attr_getguardsize(&attr, &guard_bytes);
356 if (res != 0) {
357 fatal("pthread_attr_getguardsize failed with errno = %d", res);
358 }
359 int guard_pages = align_size_up(guard_bytes, page_bytes) / page_bytes;
360 assert(guard_bytes == guard_pages * page_bytes, "unaligned guard");
361
362 #ifdef IA64
363 // IA64 has two stacks sharing the same area of memory, a normal
364 // stack growing downwards and a register stack growing upwards.
365 // Guard pages, if present, are in the centre. This code splits
|
303 return addr != NULL;
304 #endif // _LP64
305 }
306
307 ///////////////////////////////////////////////////////////////////////////////
308 // thread stack
309
310 size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K;
311 size_t os::Posix::_java_thread_min_stack_allowed = 64 * K;
312 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
313
314 size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
315 #ifdef _LP64
316 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
317 #else
318 size_t s = (thr_type == os::compiler_thread ? 2 * M : 512 * K);
319 #endif // _LP64
320 return s;
321 }
322
323 static void current_stack_region(address *bottom, size_t *size) {
324 pthread_attr_t attr;
325 int res = pthread_getattr_np(pthread_self(), &attr);
326 if (res != 0) {
327 if (res == ENOMEM) {
328 vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
329 }
330 else {
331 fatal("pthread_getattr_np failed with error = %d", res);
332 }
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
|