src/cpu/x86/vm/macroAssembler_x86.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8068945-8u-patched Sdiff src/cpu/x86/vm

src/cpu/x86/vm/macroAssembler_x86.cpp

Print this page
rev 7386 : 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
Summary: Introduce the PreserveFramePointer flag to control if RBP is used as the frame pointer or as a general purpose register.
Reviewed-by: kvn, roland, dlong, enevill, shade


6105   // stack bang then we must use the 6 byte frame allocation even if
6106   // we have no frame. :-(
6107   assert(stack_bang_size >= framesize || stack_bang_size <= 0, "stack bang size incorrect");
6108 
6109   assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
6110   // Remove word for return addr
6111   framesize -= wordSize;
6112   stack_bang_size -= wordSize;
6113 
6114   // Calls to C2R adapters often do not accept exceptional returns.
6115   // We require that their callers must bang for them.  But be careful, because
6116   // some VM calls (such as call site linkage) can use several kilobytes of
6117   // stack.  But the stack safety zone should account for that.
6118   // See bugs 4446381, 4468289, 4497237.
6119   if (stack_bang_size > 0) {
6120     generate_stack_overflow_check(stack_bang_size);
6121 
6122     // We always push rbp, so that on return to interpreter rbp, will be
6123     // restored correctly and we can correct the stack.
6124     push(rbp);




6125     // Remove word for ebp
6126     framesize -= wordSize;
6127 
6128     // Create frame
6129     if (framesize) {
6130       subptr(rsp, framesize);
6131     }
6132   } else {
6133     // Create frame (force generation of a 4 byte immediate value)
6134     subptr_imm32(rsp, framesize);
6135 
6136     // Save RBP register now.
6137     framesize -= wordSize;
6138     movptr(Address(rsp, framesize), rbp);





6139   }
6140 
6141   if (VerifyStackAtCalls) { // Majik cookie to verify stack depth
6142     framesize -= wordSize;
6143     movptr(Address(rsp, framesize), (int32_t)0xbadb100d);
6144   }
6145 
6146 #ifndef _LP64
6147   // If method sets FPU control word do it now
6148   if (fp_mode_24b) {
6149     fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24()));
6150   }
6151   if (UseSSE >= 2 && VerifyFPU) {
6152     verify_FPU(0, "FPU stack must be clean on entry");
6153   }
6154 #endif
6155 
6156 #ifdef ASSERT
6157   if (VerifyStackAtCalls) {
6158     Label L;




6105   // stack bang then we must use the 6 byte frame allocation even if
6106   // we have no frame. :-(
6107   assert(stack_bang_size >= framesize || stack_bang_size <= 0, "stack bang size incorrect");
6108 
6109   assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
6110   // Remove word for return addr
6111   framesize -= wordSize;
6112   stack_bang_size -= wordSize;
6113 
6114   // Calls to C2R adapters often do not accept exceptional returns.
6115   // We require that their callers must bang for them.  But be careful, because
6116   // some VM calls (such as call site linkage) can use several kilobytes of
6117   // stack.  But the stack safety zone should account for that.
6118   // See bugs 4446381, 4468289, 4497237.
6119   if (stack_bang_size > 0) {
6120     generate_stack_overflow_check(stack_bang_size);
6121 
6122     // We always push rbp, so that on return to interpreter rbp, will be
6123     // restored correctly and we can correct the stack.
6124     push(rbp);
6125     // Save caller's stack pointer into RBP if the frame pointer is preserved.
6126     if (PreserveFramePointer) {
6127       mov(rbp, rsp);
6128     }
6129     // Remove word for ebp
6130     framesize -= wordSize;
6131 
6132     // Create frame
6133     if (framesize) {
6134       subptr(rsp, framesize);
6135     }
6136   } else {
6137     // Create frame (force generation of a 4 byte immediate value)
6138     subptr_imm32(rsp, framesize);
6139 
6140     // Save RBP register now.
6141     framesize -= wordSize;
6142     movptr(Address(rsp, framesize), rbp);
6143     // Save caller's stack pointer into RBP if the frame pointer is preserved.
6144     if (PreserveFramePointer) {
6145       movptr(rbp, rsp);
6146       addptr(rbp, framesize + wordSize);
6147     }
6148   }
6149 
6150   if (VerifyStackAtCalls) { // Majik cookie to verify stack depth
6151     framesize -= wordSize;
6152     movptr(Address(rsp, framesize), (int32_t)0xbadb100d);
6153   }
6154 
6155 #ifndef _LP64
6156   // If method sets FPU control word do it now
6157   if (fp_mode_24b) {
6158     fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_24()));
6159   }
6160   if (UseSSE >= 2 && VerifyFPU) {
6161     verify_FPU(0, "FPU stack must be clean on entry");
6162   }
6163 #endif
6164 
6165 #ifdef ASSERT
6166   if (VerifyStackAtCalls) {
6167     Label L;


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