提交 98ec1205 编写于 作者: D dholmes

6978641: Fix for 6929067 introduces additional overhead in thread creation/termination paths

Summary: Disable stack bounds checks in product mode other than for the initial thread
Reviewed-by: coleenp, jcoomes, aph
上级 50215306
...@@ -2597,10 +2597,14 @@ get_stack_bounds(uintptr_t *bottom, uintptr_t *top) ...@@ -2597,10 +2597,14 @@ get_stack_bounds(uintptr_t *bottom, uintptr_t *top)
// where we're going to put our guard pages, truncate the mapping at // where we're going to put our guard pages, truncate the mapping at
// that point by munmap()ping it. This ensures that when we later // that point by munmap()ping it. This ensures that when we later
// munmap() the guard pages we don't leave a hole in the stack // munmap() the guard pages we don't leave a hole in the stack
// mapping. // mapping. This only affects the main/initial thread, but guard
// against future OS changes
bool os::create_stack_guard_pages(char* addr, size_t size) { bool os::create_stack_guard_pages(char* addr, size_t size) {
uintptr_t stack_extent, stack_base; uintptr_t stack_extent, stack_base;
if (get_stack_bounds(&stack_extent, &stack_base)) { bool chk_bounds = NOT_DEBUG(os::Linux::is_initial_thread()) DEBUG_ONLY(true);
if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) {
assert(os::Linux::is_initial_thread(),
"growable stack in non-initial thread");
if (stack_extent < (uintptr_t)addr) if (stack_extent < (uintptr_t)addr)
::munmap((void*)stack_extent, (uintptr_t)addr - stack_extent); ::munmap((void*)stack_extent, (uintptr_t)addr - stack_extent);
} }
...@@ -2609,10 +2613,15 @@ bool os::create_stack_guard_pages(char* addr, size_t size) { ...@@ -2609,10 +2613,15 @@ bool os::create_stack_guard_pages(char* addr, size_t size) {
} }
// If this is a growable mapping, remove the guard pages entirely by // If this is a growable mapping, remove the guard pages entirely by
// munmap()ping them. If not, just call uncommit_memory(). // munmap()ping them. If not, just call uncommit_memory(). This only
// affects the main/initial thread, but guard against future OS changes
bool os::remove_stack_guard_pages(char* addr, size_t size) { bool os::remove_stack_guard_pages(char* addr, size_t size) {
uintptr_t stack_extent, stack_base; uintptr_t stack_extent, stack_base;
if (get_stack_bounds(&stack_extent, &stack_base)) { bool chk_bounds = NOT_DEBUG(os::Linux::is_initial_thread()) DEBUG_ONLY(true);
if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) {
assert(os::Linux::is_initial_thread(),
"growable stack in non-initial thread");
return ::munmap(addr, size) == 0; return ::munmap(addr, size) == 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册