@@ -705,45 +705,34 @@ void SafepointSynchronize::block(JavaThread *thread) {
705
705
}
706
706
707
707
JavaThreadState state = thread->thread_state ();
708
+ assert (is_a_block_safe_state (state), " Illegal threadstate encountered: %d" , state);
708
709
thread->frame_anchor ()->make_walkable (thread);
709
710
710
711
uint64_t safepoint_id = SafepointSynchronize::safepoint_counter ();
711
- // Check that we have a valid thread_state at this point
712
- switch (state) {
713
- case _thread_in_vm_trans:
714
- case _thread_in_Java: // From compiled code
715
- case _thread_in_native_trans:
716
- case _thread_blocked_trans:
717
- case _thread_new_trans:
718
-
719
- // We have no idea where the VMThread is, it might even be at next safepoint.
720
- // So we can miss this poll, but stop at next.
721
712
722
- // Load dependent store , it must not pass loading of safepoint_id .
723
- thread-> safepoint_state ()-> set_safepoint_id (safepoint_id); // Release store
713
+ // We have no idea where the VMThread is , it might even be at next safepoint .
714
+ // So we can miss this poll, but stop at next.
724
715
725
- // This part we can skip if we notice we miss or are in a future safepoint.
726
- OrderAccess::storestore ();
727
- // Load in wait barrier should not float up
728
- thread->set_thread_state_fence (_thread_blocked);
716
+ // Load dependent store, it must not pass loading of safepoint_id.
717
+ thread->safepoint_state ()->set_safepoint_id (safepoint_id); // Release store
729
718
730
- _wait_barrier->wait (static_cast <int >(safepoint_id));
731
- assert (_state != _synchronized, " Can't be" );
719
+ // This part we can skip if we notice we miss or are in a future safepoint.
720
+ OrderAccess::storestore ();
721
+ // Load in wait barrier should not float up
722
+ thread->set_thread_state_fence (_thread_blocked);
732
723
733
- // If barrier is disarmed stop store from floating above loads in barrier.
734
- OrderAccess::loadstore ();
735
- thread->set_thread_state (state);
724
+ _wait_barrier->wait (static_cast <int >(safepoint_id));
725
+ assert (_state != _synchronized, " Can't be" );
736
726
737
- // Then we reset the safepoint id to inactive.
738
- thread->safepoint_state ()->reset_safepoint_id (); // Release store
727
+ // If barrier is disarmed stop store from floating above loads in barrier.
728
+ OrderAccess::loadstore ();
729
+ thread->set_thread_state (state);
739
730
740
- OrderAccess::fence ();
731
+ // Then we reset the safepoint id to inactive.
732
+ thread->safepoint_state ()->reset_safepoint_id (); // Release store
741
733
742
- break ;
734
+ OrderAccess::fence () ;
743
735
744
- default :
745
- fatal (" Illegal threadstate encountered: %d" , state);
746
- }
747
736
guarantee (thread->safepoint_state ()->get_safepoint_id () == InactiveSafepointCounter,
748
737
" The safepoint id should be set only in block path" );
749
738
0 commit comments