< prev index next >

src/hotspot/cpu/x86/macroAssembler_x86.cpp

Print this page
rev 47591 : Add Thread Local handshakes and thread local polling


  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/assembler.hpp"
  27 #include "asm/assembler.inline.hpp"
  28 #include "compiler/disassembler.hpp"
  29 #include "gc/shared/cardTableModRefBS.hpp"
  30 #include "gc/shared/collectedHeap.inline.hpp"
  31 #include "interpreter/interpreter.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "memory/universe.hpp"
  34 #include "oops/klass.inline.hpp"
  35 #include "prims/jvm.h"
  36 #include "prims/methodHandles.hpp"
  37 #include "runtime/biasedLocking.hpp"
  38 #include "runtime/interfaceSupport.hpp"
  39 #include "runtime/objectMonitor.hpp"
  40 #include "runtime/os.hpp"


  41 #include "runtime/sharedRuntime.hpp"
  42 #include "runtime/stubRoutines.hpp"
  43 #include "runtime/thread.hpp"
  44 #include "utilities/macros.hpp"
  45 #if INCLUDE_ALL_GCS
  46 #include "gc/g1/g1CollectedHeap.inline.hpp"
  47 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  48 #include "gc/g1/heapRegion.hpp"
  49 #endif // INCLUDE_ALL_GCS
  50 #include "crc32c.h"
  51 #ifdef COMPILER2
  52 #include "opto/intrinsicnode.hpp"
  53 #endif
  54 
  55 #ifdef PRODUCT
  56 #define BLOCK_COMMENT(str) /* nothing */
  57 #define STOP(error) stop(error)
  58 #else
  59 #define BLOCK_COMMENT(str) block_comment(str)
  60 #define STOP(error) block_comment(error); stop(error)


3741 void MacroAssembler::save_rax(Register tmp) {
3742   if (tmp == noreg) push(rax);
3743   else if (tmp != rax) mov(tmp, rax);
3744 }
3745 
3746 // Write serialization page so VM thread can do a pseudo remote membar.
3747 // We use the current thread pointer to calculate a thread specific
3748 // offset to write to within the page. This minimizes bus traffic
3749 // due to cache line collision.
3750 void MacroAssembler::serialize_memory(Register thread, Register tmp) {
3751   movl(tmp, thread);
3752   shrl(tmp, os::get_serialize_page_shift_count());
3753   andl(tmp, (os::vm_page_size() - sizeof(int)));
3754 
3755   Address index(noreg, tmp, Address::times_1);
3756   ExternalAddress page(os::get_memory_serialize_page());
3757 
3758   // Size of store must match masking code above
3759   movl(as_Address(ArrayAddress(page, index)), tmp);
3760 }



















3761 
3762 // Calls to C land
3763 //
3764 // When entering C land, the rbp, & rsp of the last Java frame have to be recorded
3765 // in the (thread-local) JavaThread object. When leaving C land, the last Java fp
3766 // has to be reset to 0. This is required to allow proper stack traversal.
3767 void MacroAssembler::set_last_Java_frame(Register java_thread,
3768                                          Register last_java_sp,
3769                                          Register last_java_fp,
3770                                          address  last_java_pc) {
3771   vzeroupper();
3772   // determine java_thread register
3773   if (!java_thread->is_valid()) {
3774     java_thread = rdi;
3775     get_thread(java_thread);
3776   }
3777   // determine last_java_sp register
3778   if (!last_java_sp->is_valid()) {
3779     last_java_sp = rsp;
3780   }




  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/assembler.hpp"
  27 #include "asm/assembler.inline.hpp"
  28 #include "compiler/disassembler.hpp"
  29 #include "gc/shared/cardTableModRefBS.hpp"
  30 #include "gc/shared/collectedHeap.inline.hpp"
  31 #include "interpreter/interpreter.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "memory/universe.hpp"
  34 #include "oops/klass.inline.hpp"
  35 #include "prims/jvm.h"
  36 #include "prims/methodHandles.hpp"
  37 #include "runtime/biasedLocking.hpp"
  38 #include "runtime/interfaceSupport.hpp"
  39 #include "runtime/objectMonitor.hpp"
  40 #include "runtime/os.hpp"
  41 #include "runtime/safepoint.hpp"
  42 #include "runtime/safepointMechanism.hpp"
  43 #include "runtime/sharedRuntime.hpp"
  44 #include "runtime/stubRoutines.hpp"
  45 #include "runtime/thread.hpp"
  46 #include "utilities/macros.hpp"
  47 #if INCLUDE_ALL_GCS
  48 #include "gc/g1/g1CollectedHeap.inline.hpp"
  49 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  50 #include "gc/g1/heapRegion.hpp"
  51 #endif // INCLUDE_ALL_GCS
  52 #include "crc32c.h"
  53 #ifdef COMPILER2
  54 #include "opto/intrinsicnode.hpp"
  55 #endif
  56 
  57 #ifdef PRODUCT
  58 #define BLOCK_COMMENT(str) /* nothing */
  59 #define STOP(error) stop(error)
  60 #else
  61 #define BLOCK_COMMENT(str) block_comment(str)
  62 #define STOP(error) block_comment(error); stop(error)


3743 void MacroAssembler::save_rax(Register tmp) {
3744   if (tmp == noreg) push(rax);
3745   else if (tmp != rax) mov(tmp, rax);
3746 }
3747 
3748 // Write serialization page so VM thread can do a pseudo remote membar.
3749 // We use the current thread pointer to calculate a thread specific
3750 // offset to write to within the page. This minimizes bus traffic
3751 // due to cache line collision.
3752 void MacroAssembler::serialize_memory(Register thread, Register tmp) {
3753   movl(tmp, thread);
3754   shrl(tmp, os::get_serialize_page_shift_count());
3755   andl(tmp, (os::vm_page_size() - sizeof(int)));
3756 
3757   Address index(noreg, tmp, Address::times_1);
3758   ExternalAddress page(os::get_memory_serialize_page());
3759 
3760   // Size of store must match masking code above
3761   movl(as_Address(ArrayAddress(page, index)), tmp);
3762 }
3763 
3764 #ifdef _LP64
3765 void MacroAssembler::safepoint_poll(Label& slow_path, Register thread_reg, Register temp_reg) {
3766   if (SafepointMechanism::uses_thread_local_poll()) {
3767     testb(Address(r15_thread, Thread::polling_page_offset()), SafepointMechanism::poll_bit());
3768     jcc(Assembler::notZero, slow_path); // handshake bit set implies poll
3769   } else {
3770     cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
3771         SafepointSynchronize::_not_synchronized);
3772     jcc(Assembler::notEqual, slow_path);
3773   }
3774 }
3775 #else
3776 void MacroAssembler::safepoint_poll(Label& slow_path) {
3777   cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
3778       SafepointSynchronize::_not_synchronized);
3779   jcc(Assembler::notEqual, slow_path);
3780 }
3781 #endif
3782 
3783 // Calls to C land
3784 //
3785 // When entering C land, the rbp, & rsp of the last Java frame have to be recorded
3786 // in the (thread-local) JavaThread object. When leaving C land, the last Java fp
3787 // has to be reset to 0. This is required to allow proper stack traversal.
3788 void MacroAssembler::set_last_Java_frame(Register java_thread,
3789                                          Register last_java_sp,
3790                                          Register last_java_fp,
3791                                          address  last_java_pc) {
3792   vzeroupper();
3793   // determine java_thread register
3794   if (!java_thread->is_valid()) {
3795     java_thread = rdi;
3796     get_thread(java_thread);
3797   }
3798   // determine last_java_sp register
3799   if (!last_java_sp->is_valid()) {
3800     last_java_sp = rsp;
3801   }


< prev index next >