< prev index next >

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

Print this page




  86     assert(from != _thread_in_Java, "use transition_from_java");
  87     assert(from != _thread_in_native, "use transition_from_native");
  88     assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states");
  89     assert(thread->thread_state() == from, "coming from wrong thread state");
  90 
  91     // Check NoSafepointVerifier
  92     // This also clears unhandled oops if CheckUnhandledOops is used.
  93     thread->check_possible_safepoint();
  94 
  95     // Change to transition state and ensure it is seen by the VM thread.
  96     thread->set_thread_state_fence((JavaThreadState)(from + 1));
  97 
  98     SafepointMechanism::block_if_requested(thread);
  99     thread->set_thread_state(to);
 100   }
 101 
 102   // Same as above, but assumes from = _thread_in_Java. This is simpler, since we
 103   // never block on entry to the VM. This will break the code, since e.g. preserve arguments
 104   // have not been setup.
 105   static inline void transition_from_java(JavaThread *thread, JavaThreadState to) {
 106     assert(thread->thread_state() == _thread_in_Java, "coming from wrong thread state");
 107     thread->set_thread_state(to);
 108   }
 109 
 110   static inline void transition_from_native(JavaThread *thread, JavaThreadState to) {
 111     assert((to & 1) == 0, "odd numbers are transitions states");
 112     assert(thread->thread_state() == _thread_in_native, "coming from wrong thread state");
 113     // Change to transition state and ensure it is seen by the VM thread.
 114     thread->set_thread_state_fence(_thread_in_native_trans);
 115 
 116     // We never install asynchronous exceptions when coming (back) in
 117     // to the runtime from native code because the runtime is not set
 118     // up to handle exceptions floating around at arbitrary points.
 119     if (SafepointMechanism::should_block(thread) || thread->is_suspend_after_native()) {
 120       JavaThread::check_safepoint_and_suspend_for_native_trans(thread);
 121     }
 122 
 123     thread->set_thread_state(to);
 124   }
 125  protected:
 126    void trans(JavaThreadState from, JavaThreadState to)  { transition(_thread, from, to); }
 127    void trans_from_java(JavaThreadState to)              { transition_from_java(_thread, to); }
 128    void trans_from_native(JavaThreadState to)            { transition_from_native(_thread, to); }
 129 };
 130 
 131 class ThreadInVMForHandshake : public ThreadStateTransition {
 132   const JavaThreadState _original_state;




  86     assert(from != _thread_in_Java, "use transition_from_java");
  87     assert(from != _thread_in_native, "use transition_from_native");
  88     assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states");
  89     assert(thread->thread_state() == from, "coming from wrong thread state");
  90 
  91     // Check NoSafepointVerifier
  92     // This also clears unhandled oops if CheckUnhandledOops is used.
  93     thread->check_possible_safepoint();
  94 
  95     // Change to transition state and ensure it is seen by the VM thread.
  96     thread->set_thread_state_fence((JavaThreadState)(from + 1));
  97 
  98     SafepointMechanism::block_if_requested(thread);
  99     thread->set_thread_state(to);
 100   }
 101 
 102   // Same as above, but assumes from = _thread_in_Java. This is simpler, since we
 103   // never block on entry to the VM. This will break the code, since e.g. preserve arguments
 104   // have not been setup.
 105   static inline void transition_from_java(JavaThread *thread, JavaThreadState to) {
 106     assert(thread->thread_state() == _thread_in_Java, "coming from wrong thread state: %s", thread->thread_state_name());
 107     thread->set_thread_state(to);
 108   }
 109 
 110   static inline void transition_from_native(JavaThread *thread, JavaThreadState to) {
 111     assert((to & 1) == 0, "odd numbers are transitions states");
 112     assert(thread->thread_state() == _thread_in_native, "coming from wrong thread state: %s", thread->thread_state_name());
 113     // Change to transition state and ensure it is seen by the VM thread.
 114     thread->set_thread_state_fence(_thread_in_native_trans);
 115 
 116     // We never install asynchronous exceptions when coming (back) in
 117     // to the runtime from native code because the runtime is not set
 118     // up to handle exceptions floating around at arbitrary points.
 119     if (SafepointMechanism::should_block(thread) || thread->is_suspend_after_native()) {
 120       JavaThread::check_safepoint_and_suspend_for_native_trans(thread);
 121     }
 122 
 123     thread->set_thread_state(to);
 124   }
 125  protected:
 126    void trans(JavaThreadState from, JavaThreadState to)  { transition(_thread, from, to); }
 127    void trans_from_java(JavaThreadState to)              { transition_from_java(_thread, to); }
 128    void trans_from_native(JavaThreadState to)            { transition_from_native(_thread, to); }
 129 };
 130 
 131 class ThreadInVMForHandshake : public ThreadStateTransition {
 132   const JavaThreadState _original_state;


< prev index next >