Mercurial > hg > graal-jvmci-8
comparison src/os/linux/vm/os_linux.cpp @ 1750:c7004d700b49
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
author | dholmes |
---|---|
date | Wed, 25 Aug 2010 21:29:05 -0400 |
parents | 126ea7725993 |
children | 1c352af0135d |
comparison
equal
deleted
inserted
replaced
1745:ebfb7c68865e | 1750:c7004d700b49 |
---|---|
2595 | 2595 |
2596 // If the (growable) stack mapping already extends beyond the point | 2596 // If the (growable) stack mapping already extends beyond the point |
2597 // where we're going to put our guard pages, truncate the mapping at | 2597 // where we're going to put our guard pages, truncate the mapping at |
2598 // that point by munmap()ping it. This ensures that when we later | 2598 // that point by munmap()ping it. This ensures that when we later |
2599 // munmap() the guard pages we don't leave a hole in the stack | 2599 // munmap() the guard pages we don't leave a hole in the stack |
2600 // mapping. | 2600 // mapping. This only affects the main/initial thread, but guard |
2601 // against future OS changes | |
2601 bool os::create_stack_guard_pages(char* addr, size_t size) { | 2602 bool os::create_stack_guard_pages(char* addr, size_t size) { |
2602 uintptr_t stack_extent, stack_base; | 2603 uintptr_t stack_extent, stack_base; |
2603 if (get_stack_bounds(&stack_extent, &stack_base)) { | 2604 bool chk_bounds = NOT_DEBUG(os::Linux::is_initial_thread()) DEBUG_ONLY(true); |
2605 if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) { | |
2606 assert(os::Linux::is_initial_thread(), | |
2607 "growable stack in non-initial thread"); | |
2604 if (stack_extent < (uintptr_t)addr) | 2608 if (stack_extent < (uintptr_t)addr) |
2605 ::munmap((void*)stack_extent, (uintptr_t)addr - stack_extent); | 2609 ::munmap((void*)stack_extent, (uintptr_t)addr - stack_extent); |
2606 } | 2610 } |
2607 | 2611 |
2608 return os::commit_memory(addr, size); | 2612 return os::commit_memory(addr, size); |
2609 } | 2613 } |
2610 | 2614 |
2611 // If this is a growable mapping, remove the guard pages entirely by | 2615 // If this is a growable mapping, remove the guard pages entirely by |
2612 // munmap()ping them. If not, just call uncommit_memory(). | 2616 // munmap()ping them. If not, just call uncommit_memory(). This only |
2617 // affects the main/initial thread, but guard against future OS changes | |
2613 bool os::remove_stack_guard_pages(char* addr, size_t size) { | 2618 bool os::remove_stack_guard_pages(char* addr, size_t size) { |
2614 uintptr_t stack_extent, stack_base; | 2619 uintptr_t stack_extent, stack_base; |
2615 if (get_stack_bounds(&stack_extent, &stack_base)) { | 2620 bool chk_bounds = NOT_DEBUG(os::Linux::is_initial_thread()) DEBUG_ONLY(true); |
2621 if (chk_bounds && get_stack_bounds(&stack_extent, &stack_base)) { | |
2622 assert(os::Linux::is_initial_thread(), | |
2623 "growable stack in non-initial thread"); | |
2624 | |
2616 return ::munmap(addr, size) == 0; | 2625 return ::munmap(addr, size) == 0; |
2617 } | 2626 } |
2618 | 2627 |
2619 return os::uncommit_memory(addr, size); | 2628 return os::uncommit_memory(addr, size); |
2620 } | 2629 } |