diff --git a/src/hotspot/share/runtime/interfaceSupport.inline.hpp b/src/hotspot/share/runtime/interfaceSupport.inline.hpp index 82cd2c180a173..efa794c481b0a 100644 --- a/src/hotspot/share/runtime/interfaceSupport.inline.hpp +++ b/src/hotspot/share/runtime/interfaceSupport.inline.hpp @@ -228,15 +228,13 @@ class ThreadBlockInVMPreprocess : public ThreadStateTransition { } ~ThreadBlockInVMPreprocess() { assert(_thread->thread_state() == _thread_blocked, "coming from wrong thread state"); - // Change to transition state and ensure it is seen by the VM thread. - _thread->set_thread_state_fence(_thread_blocked_trans); + // Change back to _thread_in_vm and ensure it is seen by the VM thread. + _thread->set_thread_state_fence(_thread_in_vm); if (SafepointMechanism::should_process(_thread, _allow_suspend)) { _pr(_thread); SafepointMechanism::process_if_requested(_thread, _allow_suspend); } - - _thread->set_thread_state(_thread_in_vm); } static void emptyOp(JavaThread* current) {} diff --git a/src/hotspot/share/runtime/safepoint.cpp b/src/hotspot/share/runtime/safepoint.cpp index be371446242a1..039f8b495b0c6 100644 --- a/src/hotspot/share/runtime/safepoint.cpp +++ b/src/hotspot/share/runtime/safepoint.cpp @@ -706,7 +706,6 @@ void SafepointSynchronize::block(JavaThread *thread) { } JavaThreadState state = thread->thread_state(); - assert(is_a_block_safe_state(state), "Illegal threadstate encountered: %d", state); thread->frame_anchor()->make_walkable(thread); uint64_t safepoint_id = SafepointSynchronize::safepoint_counter(); diff --git a/src/hotspot/share/runtime/safepoint.hpp b/src/hotspot/share/runtime/safepoint.hpp index a2aaf381e8d52..268a315dd7bf0 100644 --- a/src/hotspot/share/runtime/safepoint.hpp +++ b/src/hotspot/share/runtime/safepoint.hpp @@ -128,14 +128,7 @@ class SafepointSynchronize : AllStatic { static bool is_a_block_safe_state(JavaThreadState state) { // Check that we have a valid thread_state before blocking for safepoints - switch(state) { - case _thread_in_vm: - case _thread_in_Java: // From compiled code - case _thread_blocked_trans: - return true; - default: - return false; - } + return state == _thread_in_vm || state == _thread_in_Java; } // Called when a thread voluntarily blocks static void block(JavaThread *thread);