314 void os::init_before_ergo() { |
314 void os::init_before_ergo() { |
315 // We need to initialize large page support here because ergonomics takes some |
315 // We need to initialize large page support here because ergonomics takes some |
316 // decisions depending on large page support and the calculated large page size. |
316 // decisions depending on large page support and the calculated large page size. |
317 large_page_init(); |
317 large_page_init(); |
318 |
318 |
|
319 // We need to adapt the configured number of stack protection pages given |
|
320 // in 4K pages to the actual os page size. We must do this before setting |
|
321 // up minimal stack sizes etc. in os::init_2(). |
|
322 JavaThread::set_stack_red_zone_size (align_size_up(StackRedPages * 4 * K, vm_page_size())); |
|
323 JavaThread::set_stack_yellow_zone_size (align_size_up(StackYellowPages * 4 * K, vm_page_size())); |
|
324 JavaThread::set_stack_reserved_zone_size(align_size_up(StackReservedPages * 4 * K, vm_page_size())); |
|
325 JavaThread::set_stack_shadow_zone_size (align_size_up(StackShadowPages * 4 * K, vm_page_size())); |
|
326 |
319 // VM version initialization identifies some characteristics of the |
327 // VM version initialization identifies some characteristics of the |
320 // the platform that are used during ergonomic decisions. |
328 // platform that are used during ergonomic decisions. |
321 VM_Version::init_before_ergo(); |
329 VM_Version::init_before_ergo(); |
322 } |
330 } |
323 |
331 |
324 void os::signal_init() { |
332 void os::signal_init() { |
325 if (!ReduceSignalUsage) { |
333 if (!ReduceSignalUsage) { |
1013 } |
1021 } |
1014 return; |
1022 return; |
1015 } |
1023 } |
1016 // If the addr is in the stack region for this thread then report that |
1024 // If the addr is in the stack region for this thread then report that |
1017 // and print thread info |
1025 // and print thread info |
1018 if (thread->stack_base() >= addr && |
1026 if (thread->on_local_stack(addr)) { |
1019 addr > (thread->stack_base() - thread->stack_size())) { |
|
1020 st->print_cr(INTPTR_FORMAT " is pointing into the stack for thread: " |
1027 st->print_cr(INTPTR_FORMAT " is pointing into the stack for thread: " |
1021 INTPTR_FORMAT, p2i(addr), p2i(thread)); |
1028 INTPTR_FORMAT, p2i(addr), p2i(thread)); |
1022 if (verbose) thread->print_on(st); |
1029 if (verbose) thread->print_on(st); |
1023 return; |
1030 return; |
1024 } |
1031 } |
1373 Thread::muxRelease(&SerializePageLock); |
1380 Thread::muxRelease(&SerializePageLock); |
1374 } |
1381 } |
1375 |
1382 |
1376 // Returns true if the current stack pointer is above the stack shadow |
1383 // Returns true if the current stack pointer is above the stack shadow |
1377 // pages, false otherwise. |
1384 // pages, false otherwise. |
1378 |
|
1379 bool os::stack_shadow_pages_available(Thread *thread, const methodHandle& method) { |
1385 bool os::stack_shadow_pages_available(Thread *thread, const methodHandle& method) { |
1380 assert(StackRedPages > 0 && StackYellowPages > 0,"Sanity check"); |
1386 if (!thread->is_Java_thread()) return false; |
1381 address sp = current_stack_pointer(); |
1387 address sp = current_stack_pointer(); |
1382 // Check if we have StackShadowPages above the yellow zone. This parameter |
1388 // Check if we have StackShadowPages above the yellow zone. This parameter |
1383 // is dependent on the depth of the maximum VM call stack possible from |
1389 // is dependent on the depth of the maximum VM call stack possible from |
1384 // the handler for stack overflow. 'instanceof' in the stack overflow |
1390 // the handler for stack overflow. 'instanceof' in the stack overflow |
1385 // handler or a println uses at least 8k stack of VM and native code |
1391 // handler or a println uses at least 8k stack of VM and native code |
1386 // respectively. |
1392 // respectively. |
1387 const int framesize_in_bytes = |
1393 const int framesize_in_bytes = |
1388 Interpreter::size_top_interpreter_activation(method()) * wordSize; |
1394 Interpreter::size_top_interpreter_activation(method()) * wordSize; |
1389 int reserved_area = ((StackShadowPages + StackRedPages + StackYellowPages |
1395 |
1390 + StackReservedPages) * vm_page_size()) |
1396 assert((thread->stack_base() - thread->stack_size()) + |
1391 + framesize_in_bytes; |
1397 (JavaThread::stack_guard_zone_size() + |
1392 // The very lower end of the stack |
1398 JavaThread::stack_shadow_zone_size() + framesize_in_bytes) == |
1393 address stack_limit = thread->stack_base() - thread->stack_size(); |
1399 ((JavaThread*)thread)->stack_overflow_limit() + framesize_in_bytes, "sanity"); |
1394 return (sp > (stack_limit + reserved_area)); |
1400 |
|
1401 return (sp > ((JavaThread*)thread)->stack_overflow_limit() + framesize_in_bytes); |
1395 } |
1402 } |
1396 |
1403 |
1397 size_t os::page_size_for_region(size_t region_size, size_t min_pages, bool must_be_aligned) { |
1404 size_t os::page_size_for_region(size_t region_size, size_t min_pages, bool must_be_aligned) { |
1398 assert(min_pages > 0, "sanity"); |
1405 assert(min_pages > 0, "sanity"); |
1399 if (UseLargePages) { |
1406 if (UseLargePages) { |