src/cpu/x86/vm/sharedRuntime_x86_32.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 8031320_8u Sdiff src/cpu/x86/vm

src/cpu/x86/vm/sharedRuntime_x86_32.cpp

Print this page
rev 5968 : 8031320: Use Intel RTM instructions for locks
Summary: Use RTM for inflated locks and stack locks.
Reviewed-by: iveresov, twisti, roland, dcubed


1798   // because it can be patched on the fly by make_non_entrant. The stack bang
1799   // instruction fits that requirement.
1800 
1801   // Generate stack overflow check
1802 
1803   if (UseStackBanging) {
1804     __ bang_stack_with_offset(StackShadowPages*os::vm_page_size());
1805   } else {
1806     // need a 5 byte instruction to allow MT safe patching to non-entrant
1807     __ fat_nop();
1808   }
1809 
1810   // Generate a new frame for the wrapper.
1811   __ enter();
1812   // -2 because return address is already present and so is saved rbp
1813   __ subptr(rsp, stack_size - 2*wordSize);
1814 
1815   // Frame is now completed as far as size and linkage.
1816   int frame_complete = ((intptr_t)__ pc()) - start;
1817 







1818   // Calculate the difference between rsp and rbp,. We need to know it
1819   // after the native call because on windows Java Natives will pop
1820   // the arguments and it is painful to do rsp relative addressing
1821   // in a platform independent way. So after the call we switch to
1822   // rbp, relative addressing.
1823 
1824   int fp_adjustment = stack_size - 2*wordSize;
1825 
1826 #ifdef COMPILER2
1827   // C2 may leave the stack dirty if not in SSE2+ mode
1828   if (UseSSE >= 2) {
1829     __ verify_FPU(0, "c2i transition should have clean FPU stack");
1830   } else {
1831     __ empty_FPU_stack();
1832   }
1833 #endif /* COMPILER2 */
1834 
1835   // Compute the rbp, offset for any slots used after the jni call
1836 
1837   int lock_slot_rbp_offset = (lock_slot_offset*VMRegImpl::stack_slot_size) - fp_adjustment;


3151 //------------------------------generate_uncommon_trap_blob--------------------
3152 void SharedRuntime::generate_uncommon_trap_blob() {
3153   // allocate space for the code
3154   ResourceMark rm;
3155   // setup code generation tools
3156   CodeBuffer   buffer("uncommon_trap_blob", 512, 512);
3157   MacroAssembler* masm = new MacroAssembler(&buffer);
3158 
3159   enum frame_layout {
3160     arg0_off,      // thread                     sp + 0 // Arg location for
3161     arg1_off,      // unloaded_class_index       sp + 1 // calling C
3162     // The frame sender code expects that rbp will be in the "natural" place and
3163     // will override any oopMap setting for it. We must therefore force the layout
3164     // so that it agrees with the frame sender code.
3165     rbp_off,       // callee saved register      sp + 2
3166     return_off,    // slot for return address    sp + 3
3167     framesize
3168   };
3169 
3170   address start = __ pc();






3171   // Push self-frame.
3172   __ subptr(rsp, return_off*wordSize);     // Epilog!
3173 
3174   // rbp, is an implicitly saved callee saved register (i.e. the calling
3175   // convention will save restore it in prolog/epilog) Other than that
3176   // there are no callee save registers no that adapter frames are gone.
3177   __ movptr(Address(rsp, rbp_off*wordSize), rbp);
3178 
3179   // Clear the floating point exception stack
3180   __ empty_FPU_stack();
3181 
3182   // set last_Java_sp
3183   __ get_thread(rdx);
3184   __ set_last_Java_frame(rdx, noreg, noreg, NULL);
3185 
3186   // Call C code.  Need thread but NOT official VM entry
3187   // crud.  We cannot block on this call, no GC can happen.  Call should
3188   // capture callee-saved registers as well as return values.
3189   __ movptr(Address(rsp, arg0_off*wordSize), rdx);
3190   // argument already in ECX


3336   // Account for thread arg in our frame
3337   const int additional_words = 1;
3338   int frame_size_in_words;
3339 
3340   assert (StubRoutines::forward_exception_entry() != NULL, "must be generated before");
3341 
3342   ResourceMark rm;
3343   OopMapSet *oop_maps = new OopMapSet();
3344   OopMap* map;
3345 
3346   // allocate space for the code
3347   // setup code generation tools
3348   CodeBuffer   buffer("handler_blob", 1024, 512);
3349   MacroAssembler* masm = new MacroAssembler(&buffer);
3350 
3351   const Register java_thread = rdi; // callee-saved for VC++
3352   address start   = __ pc();
3353   address call_pc = NULL;
3354   bool cause_return = (poll_type == POLL_AT_RETURN);
3355   bool save_vectors = (poll_type == POLL_AT_VECTOR_LOOP);








3356   // If cause_return is true we are at a poll_return and there is
3357   // the return address on the stack to the caller on the nmethod
3358   // that is safepoint. We can leave this return on the stack and
3359   // effectively complete the return and safepoint in the caller.
3360   // Otherwise we push space for a return address that the safepoint
3361   // handler will install later to make the stack walking sensible.
3362   if (!cause_return)
3363     __ push(rbx);  // Make room for return address (or push it again)
3364 
3365   map = RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words, false, save_vectors);
3366 
3367   // The following is basically a call_VM. However, we need the precise
3368   // address of the call in order to generate an oopmap. Hence, we do all the
3369   // work ourselves.
3370 
3371   // Push thread argument and setup last_Java_sp
3372   __ get_thread(java_thread);
3373   __ push(java_thread);
3374   __ set_last_Java_frame(java_thread, noreg, noreg, NULL);
3375 




1798   // because it can be patched on the fly by make_non_entrant. The stack bang
1799   // instruction fits that requirement.
1800 
1801   // Generate stack overflow check
1802 
1803   if (UseStackBanging) {
1804     __ bang_stack_with_offset(StackShadowPages*os::vm_page_size());
1805   } else {
1806     // need a 5 byte instruction to allow MT safe patching to non-entrant
1807     __ fat_nop();
1808   }
1809 
1810   // Generate a new frame for the wrapper.
1811   __ enter();
1812   // -2 because return address is already present and so is saved rbp
1813   __ subptr(rsp, stack_size - 2*wordSize);
1814 
1815   // Frame is now completed as far as size and linkage.
1816   int frame_complete = ((intptr_t)__ pc()) - start;
1817 
1818   if (UseRTMLocking) {
1819     // Abort RTM transaction before calling JNI
1820     // because critical section will be large and will be
1821     // aborted anyway. Also nmethod could be deoptimized.
1822     __ xabort(0);
1823   }
1824 
1825   // Calculate the difference between rsp and rbp,. We need to know it
1826   // after the native call because on windows Java Natives will pop
1827   // the arguments and it is painful to do rsp relative addressing
1828   // in a platform independent way. So after the call we switch to
1829   // rbp, relative addressing.
1830 
1831   int fp_adjustment = stack_size - 2*wordSize;
1832 
1833 #ifdef COMPILER2
1834   // C2 may leave the stack dirty if not in SSE2+ mode
1835   if (UseSSE >= 2) {
1836     __ verify_FPU(0, "c2i transition should have clean FPU stack");
1837   } else {
1838     __ empty_FPU_stack();
1839   }
1840 #endif /* COMPILER2 */
1841 
1842   // Compute the rbp, offset for any slots used after the jni call
1843 
1844   int lock_slot_rbp_offset = (lock_slot_offset*VMRegImpl::stack_slot_size) - fp_adjustment;


3158 //------------------------------generate_uncommon_trap_blob--------------------
3159 void SharedRuntime::generate_uncommon_trap_blob() {
3160   // allocate space for the code
3161   ResourceMark rm;
3162   // setup code generation tools
3163   CodeBuffer   buffer("uncommon_trap_blob", 512, 512);
3164   MacroAssembler* masm = new MacroAssembler(&buffer);
3165 
3166   enum frame_layout {
3167     arg0_off,      // thread                     sp + 0 // Arg location for
3168     arg1_off,      // unloaded_class_index       sp + 1 // calling C
3169     // The frame sender code expects that rbp will be in the "natural" place and
3170     // will override any oopMap setting for it. We must therefore force the layout
3171     // so that it agrees with the frame sender code.
3172     rbp_off,       // callee saved register      sp + 2
3173     return_off,    // slot for return address    sp + 3
3174     framesize
3175   };
3176 
3177   address start = __ pc();
3178 
3179   if (UseRTMLocking) {
3180     // Abort RTM transaction before possible nmethod deoptimization.
3181     __ xabort(0);
3182   }
3183 
3184   // Push self-frame.
3185   __ subptr(rsp, return_off*wordSize);     // Epilog!
3186 
3187   // rbp, is an implicitly saved callee saved register (i.e. the calling
3188   // convention will save restore it in prolog/epilog) Other than that
3189   // there are no callee save registers no that adapter frames are gone.
3190   __ movptr(Address(rsp, rbp_off*wordSize), rbp);
3191 
3192   // Clear the floating point exception stack
3193   __ empty_FPU_stack();
3194 
3195   // set last_Java_sp
3196   __ get_thread(rdx);
3197   __ set_last_Java_frame(rdx, noreg, noreg, NULL);
3198 
3199   // Call C code.  Need thread but NOT official VM entry
3200   // crud.  We cannot block on this call, no GC can happen.  Call should
3201   // capture callee-saved registers as well as return values.
3202   __ movptr(Address(rsp, arg0_off*wordSize), rdx);
3203   // argument already in ECX


3349   // Account for thread arg in our frame
3350   const int additional_words = 1;
3351   int frame_size_in_words;
3352 
3353   assert (StubRoutines::forward_exception_entry() != NULL, "must be generated before");
3354 
3355   ResourceMark rm;
3356   OopMapSet *oop_maps = new OopMapSet();
3357   OopMap* map;
3358 
3359   // allocate space for the code
3360   // setup code generation tools
3361   CodeBuffer   buffer("handler_blob", 1024, 512);
3362   MacroAssembler* masm = new MacroAssembler(&buffer);
3363 
3364   const Register java_thread = rdi; // callee-saved for VC++
3365   address start   = __ pc();
3366   address call_pc = NULL;
3367   bool cause_return = (poll_type == POLL_AT_RETURN);
3368   bool save_vectors = (poll_type == POLL_AT_VECTOR_LOOP);
3369 
3370   if (UseRTMLocking) {
3371     // Abort RTM transaction before calling runtime
3372     // because critical section will be large and will be
3373     // aborted anyway. Also nmethod could be deoptimized.
3374     __ xabort(0);
3375   }
3376 
3377   // If cause_return is true we are at a poll_return and there is
3378   // the return address on the stack to the caller on the nmethod
3379   // that is safepoint. We can leave this return on the stack and
3380   // effectively complete the return and safepoint in the caller.
3381   // Otherwise we push space for a return address that the safepoint
3382   // handler will install later to make the stack walking sensible.
3383   if (!cause_return)
3384     __ push(rbx);  // Make room for return address (or push it again)
3385 
3386   map = RegisterSaver::save_live_registers(masm, additional_words, &frame_size_in_words, false, save_vectors);
3387 
3388   // The following is basically a call_VM. However, we need the precise
3389   // address of the call in order to generate an oopmap. Hence, we do all the
3390   // work ourselves.
3391 
3392   // Push thread argument and setup last_Java_sp
3393   __ get_thread(java_thread);
3394   __ push(java_thread);
3395   __ set_last_Java_frame(java_thread, noreg, noreg, NULL);
3396 


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