src/cpu/x86/vm/sharedRuntime_x86_64.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/cpu/x86/vm

src/cpu/x86/vm/sharedRuntime_x86_64.cpp

Print this page
rev 6132 : 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
Summary: make compiled code bang the stack by the worst case size of the interpreter frame at deoptimization points.
Reviewed-by:
rev 6133 : [mq]: newstackbang-reviews


1981   __ load_klass(rscratch1, receiver);
1982   __ cmpq(ic_reg, rscratch1);
1983   __ jcc(Assembler::equal, hit);
1984 
1985   __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
1986 
1987   // Verified entry point must be aligned
1988   __ align(8);
1989 
1990   __ bind(hit);
1991 
1992   int vep_offset = ((intptr_t)__ pc()) - start;
1993 
1994   // The instruction at the verified entry point must be 5 bytes or longer
1995   // because it can be patched on the fly by make_non_entrant. The stack bang
1996   // instruction fits that requirement.
1997 
1998   // Generate stack overflow check
1999 
2000   if (UseStackBanging) {
2001     __ bang_stack_with_offset(StackShadowPages*os::vm_page_size());

2002   } else {
2003     // need a 5 byte instruction to allow MT safe patching to non-entrant
2004     __ fat_nop();
2005   }
2006 
2007   // Generate a new frame for the wrapper.
2008   __ enter();
2009   // -2 because return address is already present and so is saved rbp
2010   __ subptr(rsp, stack_size - 2*wordSize);
2011 
2012   // Frame is now completed as far as size and linkage.
2013   int frame_complete = ((intptr_t)__ pc()) - start;
2014 
2015 #ifdef ASSERT
2016     {
2017       Label L;
2018       __ mov(rax, rsp);
2019       __ andptr(rax, -16); // must be 16 byte boundary (see amd64 ABI)
2020       __ cmpptr(rax, rsp);
2021       __ jcc(Assembler::equal, L);


3460   //
3461   // Frame picture (youngest to oldest)
3462   // 1: self-frame (no frame link)
3463   // 2: deopting frame  (no frame link)
3464   // 3: caller of deopting frame (could be compiled/interpreted).
3465   //
3466   // Note: by leaving the return address of self-frame on the stack
3467   // and using the size of frame 2 to adjust the stack
3468   // when we are done the return to frame 3 will still be on the stack.
3469 
3470   // Pop deoptimized frame
3471   __ movl(rcx, Address(rdi, Deoptimization::UnrollBlock::size_of_deoptimized_frame_offset_in_bytes()));
3472   __ addptr(rsp, rcx);
3473 
3474   // rsp should be pointing at the return address to the caller (3)
3475 
3476   // Pick up the initial fp we should save
3477   // restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved)
3478   __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
3479 
3480   // Stack bang to make sure there's enough room for these interpreter frames.



3481   if (UseStackBanging) {
3482     __ movl(rbx, Address(rdi, Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes()));
3483     __ bang_stack_size(rbx, rcx);
3484   }

3485 
3486   // Load address of array of frame pcs into rcx
3487   __ movptr(rcx, Address(rdi, Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes()));
3488 
3489   // Trash the old pc
3490   __ addptr(rsp, wordSize);
3491 
3492   // Load address of array of frame sizes into rsi
3493   __ movptr(rsi, Address(rdi, Deoptimization::UnrollBlock::frame_sizes_offset_in_bytes()));
3494 
3495   // Load counter into rdx
3496   __ movl(rdx, Address(rdi, Deoptimization::UnrollBlock::number_of_frames_offset_in_bytes()));
3497 
3498   // Now adjust the caller's stack to make up for the extra locals
3499   // but record the original sp so that we can save it in the skeletal interpreter
3500   // frame and the stack walking of interpreter_sender will get the unextended sp
3501   // value and not the "real" sp value.
3502 
3503   const Register sender_sp = r8;
3504 


3653   // Frame picture (youngest to oldest)
3654   // 1: self-frame (no frame link)
3655   // 2: deopting frame  (no frame link)
3656   // 3: caller of deopting frame (could be compiled/interpreted).
3657 
3658   // Pop self-frame.  We have no frame, and must rely only on rax and rsp.
3659   __ addptr(rsp, (SimpleRuntimeFrame::framesize - 2) << LogBytesPerInt); // Epilog!
3660 
3661   // Pop deoptimized frame (int)
3662   __ movl(rcx, Address(rdi,
3663                        Deoptimization::UnrollBlock::
3664                        size_of_deoptimized_frame_offset_in_bytes()));
3665   __ addptr(rsp, rcx);
3666 
3667   // rsp should be pointing at the return address to the caller (3)
3668 
3669   // Pick up the initial fp we should save
3670   // restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved)
3671   __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
3672 
3673   // Stack bang to make sure there's enough room for these interpreter frames.



3674   if (UseStackBanging) {
3675     __ movl(rbx, Address(rdi ,Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes()));
3676     __ bang_stack_size(rbx, rcx);
3677   }

3678 
3679   // Load address of array of frame pcs into rcx (address*)
3680   __ movptr(rcx, Address(rdi, Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes()));
3681 
3682   // Trash the return pc
3683   __ addptr(rsp, wordSize);
3684 
3685   // Load address of array of frame sizes into rsi (intptr_t*)
3686   __ movptr(rsi, Address(rdi, Deoptimization::UnrollBlock:: frame_sizes_offset_in_bytes()));
3687 
3688   // Counter
3689   __ movl(rdx, Address(rdi, Deoptimization::UnrollBlock:: number_of_frames_offset_in_bytes())); // (int)
3690 
3691   // Now adjust the caller's stack to make up for the extra locals but
3692   // record the original sp so that we can save it in the skeletal
3693   // interpreter frame and the stack walking of interpreter_sender
3694   // will get the unextended sp value and not the "real" sp value.
3695 
3696   const Register sender_sp = r8;
3697 




1981   __ load_klass(rscratch1, receiver);
1982   __ cmpq(ic_reg, rscratch1);
1983   __ jcc(Assembler::equal, hit);
1984 
1985   __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
1986 
1987   // Verified entry point must be aligned
1988   __ align(8);
1989 
1990   __ bind(hit);
1991 
1992   int vep_offset = ((intptr_t)__ pc()) - start;
1993 
1994   // The instruction at the verified entry point must be 5 bytes or longer
1995   // because it can be patched on the fly by make_non_entrant. The stack bang
1996   // instruction fits that requirement.
1997 
1998   // Generate stack overflow check
1999 
2000   if (UseStackBanging) {
2001     // See AbstractAssembler::generate_stack_overflow_check
2002     __ bang_stack_with_offset((StackShadowPages+1)*os::vm_page_size());
2003   } else {
2004     // need a 5 byte instruction to allow MT safe patching to non-entrant
2005     __ fat_nop();
2006   }
2007 
2008   // Generate a new frame for the wrapper.
2009   __ enter();
2010   // -2 because return address is already present and so is saved rbp
2011   __ subptr(rsp, stack_size - 2*wordSize);
2012 
2013   // Frame is now completed as far as size and linkage.
2014   int frame_complete = ((intptr_t)__ pc()) - start;
2015 
2016 #ifdef ASSERT
2017     {
2018       Label L;
2019       __ mov(rax, rsp);
2020       __ andptr(rax, -16); // must be 16 byte boundary (see amd64 ABI)
2021       __ cmpptr(rax, rsp);
2022       __ jcc(Assembler::equal, L);


3461   //
3462   // Frame picture (youngest to oldest)
3463   // 1: self-frame (no frame link)
3464   // 2: deopting frame  (no frame link)
3465   // 3: caller of deopting frame (could be compiled/interpreted).
3466   //
3467   // Note: by leaving the return address of self-frame on the stack
3468   // and using the size of frame 2 to adjust the stack
3469   // when we are done the return to frame 3 will still be on the stack.
3470 
3471   // Pop deoptimized frame
3472   __ movl(rcx, Address(rdi, Deoptimization::UnrollBlock::size_of_deoptimized_frame_offset_in_bytes()));
3473   __ addptr(rsp, rcx);
3474 
3475   // rsp should be pointing at the return address to the caller (3)
3476 
3477   // Pick up the initial fp we should save
3478   // restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved)
3479   __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
3480 
3481 #ifdef ASSERT
3482   // Compilers generate code that bang the stack by as much as the
3483   // interpreter would need. So this stack banging should never
3484   // trigger a fault. Verify that it does not on non product builds.
3485   if (UseStackBanging) {
3486     __ movl(rbx, Address(rdi, Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes()));
3487     __ bang_stack_size(rbx, rcx);
3488   }
3489 #endif
3490 
3491   // Load address of array of frame pcs into rcx
3492   __ movptr(rcx, Address(rdi, Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes()));
3493 
3494   // Trash the old pc
3495   __ addptr(rsp, wordSize);
3496 
3497   // Load address of array of frame sizes into rsi
3498   __ movptr(rsi, Address(rdi, Deoptimization::UnrollBlock::frame_sizes_offset_in_bytes()));
3499 
3500   // Load counter into rdx
3501   __ movl(rdx, Address(rdi, Deoptimization::UnrollBlock::number_of_frames_offset_in_bytes()));
3502 
3503   // Now adjust the caller's stack to make up for the extra locals
3504   // but record the original sp so that we can save it in the skeletal interpreter
3505   // frame and the stack walking of interpreter_sender will get the unextended sp
3506   // value and not the "real" sp value.
3507 
3508   const Register sender_sp = r8;
3509 


3658   // Frame picture (youngest to oldest)
3659   // 1: self-frame (no frame link)
3660   // 2: deopting frame  (no frame link)
3661   // 3: caller of deopting frame (could be compiled/interpreted).
3662 
3663   // Pop self-frame.  We have no frame, and must rely only on rax and rsp.
3664   __ addptr(rsp, (SimpleRuntimeFrame::framesize - 2) << LogBytesPerInt); // Epilog!
3665 
3666   // Pop deoptimized frame (int)
3667   __ movl(rcx, Address(rdi,
3668                        Deoptimization::UnrollBlock::
3669                        size_of_deoptimized_frame_offset_in_bytes()));
3670   __ addptr(rsp, rcx);
3671 
3672   // rsp should be pointing at the return address to the caller (3)
3673 
3674   // Pick up the initial fp we should save
3675   // restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved)
3676   __ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
3677 
3678 #ifdef ASSERT
3679   // Compilers generate code that bang the stack by as much as the
3680   // interpreter would need. So this stack banging should never
3681   // trigger a fault. Verify that it does not on non product builds.
3682   if (UseStackBanging) {
3683     __ movl(rbx, Address(rdi ,Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes()));
3684     __ bang_stack_size(rbx, rcx);
3685   }
3686 #endif
3687 
3688   // Load address of array of frame pcs into rcx (address*)
3689   __ movptr(rcx, Address(rdi, Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes()));
3690 
3691   // Trash the return pc
3692   __ addptr(rsp, wordSize);
3693 
3694   // Load address of array of frame sizes into rsi (intptr_t*)
3695   __ movptr(rsi, Address(rdi, Deoptimization::UnrollBlock:: frame_sizes_offset_in_bytes()));
3696 
3697   // Counter
3698   __ movl(rdx, Address(rdi, Deoptimization::UnrollBlock:: number_of_frames_offset_in_bytes())); // (int)
3699 
3700   // Now adjust the caller's stack to make up for the extra locals but
3701   // record the original sp so that we can save it in the skeletal
3702   // interpreter frame and the stack walking of interpreter_sender
3703   // will get the unextended sp value and not the "real" sp value.
3704 
3705   const Register sender_sp = r8;
3706 


src/cpu/x86/vm/sharedRuntime_x86_64.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File