void AbstractAssembler::generate_stack_overflow_check( int frame_size_in_bytes) { if (UseStackBanging) { // Each code entry causes one stack bang n pages down the stack where n // is configurable by StackBangPages. The setting depends on the maximum // depth of VM call stack or native before going back into java code, // since only java code can raise a stack overflow exception using the // stack banging mechanism. The VM and native code does not detect stack // overflow. // The code in JavaCalls::call() checks that there is at least n pages // available, so all entry code needs to do is bang once for the end of // this shadow zone. // The entry code may need to bang additional pages if the framesize // is greater than a page. const int page_size = os::vm_page_size(); int bang_end = StackShadowPages*page_size; // This is how far the previous frame's stack banging extended. const int bang_end_safe = bang_end; if (frame_size_in_bytes > page_size) { bang_end += frame_size_in_bytes; } int bang_offset = bang_end_safe; while (bang_offset <= bang_end) { // Need at least one stack bang at end of shadow zone. bang_stack_with_offset(bang_offset); bang_offset += page_size; } } // end (UseStackBanging) }
void AbstractInterpreterGenerator::bang_stack_shadow_pages(bool native_call) { // Quick & dirty stack overflow checking: bang the stack & handle trap. // Note that we do the banging after the frame is setup, since the exception // handling code expects to find a valid interpreter frame on the stack. // Doing the banging earlier fails if the caller frame is not an interpreter // frame. // (Also, the exception throwing code expects to unlock any synchronized // method receiever, so do the banging after locking the receiver.) // Bang each page in the shadow zone. We can't assume it's been done for // an interpreter frame with greater than a page of locals, so each page // needs to be checked. Only true for non-native. if (UseStackBanging) { const int start_page = native_call ? StackShadowPages : 1; const int page_size = os::vm_page_size(); for (int pages = start_page; pages <= StackShadowPages ; pages++) { __ bang_stack_with_offset(pages*page_size); } } }