85 static inline void transition(JavaThread *thread, JavaThreadState from, JavaThreadState to) { |
85 static inline void transition(JavaThread *thread, JavaThreadState from, JavaThreadState to) { |
86 assert(from != _thread_in_Java, "use transition_from_java"); |
86 assert(from != _thread_in_Java, "use transition_from_java"); |
87 assert(from != _thread_in_native, "use transition_from_native"); |
87 assert(from != _thread_in_native, "use transition_from_native"); |
88 assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states"); |
88 assert((from & 1) == 0 && (to & 1) == 0, "odd numbers are transitions states"); |
89 assert(thread->thread_state() == from, "coming from wrong thread state"); |
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 |
90 // Change to transition state and ensure it is seen by the VM thread. |
95 // Change to transition state and ensure it is seen by the VM thread. |
91 thread->set_thread_state_fence((JavaThreadState)(from + 1)); |
96 thread->set_thread_state_fence((JavaThreadState)(from + 1)); |
92 |
97 |
93 SafepointMechanism::block_if_requested(thread); |
98 SafepointMechanism::block_if_requested(thread); |
94 thread->set_thread_state(to); |
99 thread->set_thread_state(to); |
95 |
|
96 CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();) |
|
97 } |
100 } |
98 |
101 |
99 // Same as above, but assumes from = _thread_in_Java. This is simpler, since we |
102 // Same as above, but assumes from = _thread_in_Java. This is simpler, since we |
100 // never block on entry to the VM. This will break the code, since e.g. preserve arguments |
103 // never block on entry to the VM. This will break the code, since e.g. preserve arguments |
101 // have not been setup. |
104 // have not been setup. |