< prev index next >

src/hotspot/share/runtime/safepointMechanism.inline.hpp

Print this page
rev 47554 : Introduce SafepointMechanism
rev 47556 : Add Thread Local handshakes and thread local polling
rev 47559 : imported patch Assorted-Karen-5


  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_SAFEPOINTMECHANISM_INLINE_HPP
  26 #define SHARE_VM_RUNTIME_SAFEPOINTMECHANISM_INLINE_HPP
  27 
  28 #include "runtime/safepointMechanism.hpp"
  29 #include "runtime/safepoint.hpp"
  30 #include "runtime/thread.inline.hpp"
  31 
  32 bool SafepointMechanism::local_poll_armed(JavaThread* thread) {
  33   const intptr_t poll_word = reinterpret_cast<intptr_t>(thread->get_polling_page());
  34   return mask_bits_are_true(poll_word, poll_bit());
  35 }
  36 
  37 bool SafepointMechanism::global_poll() {
  38   return SafepointSynchronize::do_call_back();
  39 }
  40 
  41 bool SafepointMechanism::local_poll(Thread* thread) {
  42   // Mutexes can be taken but none JavaThread. These cannot have handshakes
  43   // operation but they must stop for safepoints.
  44   if (thread->is_Java_thread()) {
  45     return local_poll_armed((JavaThread*)thread);
  46   } else {

  47     return global_poll();
  48   }
  49 }
  50 
  51 bool SafepointMechanism::poll(Thread* thread) {
  52   if (uses_thread_local_poll()) {
  53     return local_poll(thread);
  54   } else {
  55     return global_poll();
  56   }
  57 }
  58 
  59 void SafepointMechanism::block_if_requested_local_poll(JavaThread *thread) {
  60   bool armed = local_poll_armed(thread); // load acquire, polling page -> op / global state
  61   if(armed) {
  62     // We could be armed for either a handshake operation or a safepoint
  63     if (thread->has_handshake()) {
  64       thread->handshake_process_by_self();
  65     } else {
  66       if (global_poll()) {




  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_SAFEPOINTMECHANISM_INLINE_HPP
  26 #define SHARE_VM_RUNTIME_SAFEPOINTMECHANISM_INLINE_HPP
  27 
  28 #include "runtime/safepointMechanism.hpp"
  29 #include "runtime/safepoint.hpp"
  30 #include "runtime/thread.inline.hpp"
  31 
  32 bool SafepointMechanism::local_poll_armed(JavaThread* thread) {
  33   const intptr_t poll_word = reinterpret_cast<intptr_t>(thread->get_polling_page());
  34   return mask_bits_are_true(poll_word, poll_bit());
  35 }
  36 
  37 bool SafepointMechanism::global_poll() {
  38   return SafepointSynchronize::do_call_back();
  39 }
  40 
  41 bool SafepointMechanism::local_poll(Thread* thread) {


  42   if (thread->is_Java_thread()) {
  43     return local_poll_armed((JavaThread*)thread);
  44   } else {
  45     // If the poll is on a non-java thread we can only check the global state.
  46     return global_poll();
  47   }
  48 }
  49 
  50 bool SafepointMechanism::poll(Thread* thread) {
  51   if (uses_thread_local_poll()) {
  52     return local_poll(thread);
  53   } else {
  54     return global_poll();
  55   }
  56 }
  57 
  58 void SafepointMechanism::block_if_requested_local_poll(JavaThread *thread) {
  59   bool armed = local_poll_armed(thread); // load acquire, polling page -> op / global state
  60   if(armed) {
  61     // We could be armed for either a handshake operation or a safepoint
  62     if (thread->has_handshake()) {
  63       thread->handshake_process_by_self();
  64     } else {
  65       if (global_poll()) {


< prev index next >