@@ -737,29 +737,6 @@ void SafepointSynchronize::block(JavaThread *thread) {
737737 guarantee (thread->safepoint_state ()->get_safepoint_id () == InactiveSafepointCounter,
738738 " The safepoint id should be set only in block path" );
739739
740- // Check for pending. async. exceptions or suspends - except if the
741- // thread was blocked inside the VM. has_special_runtime_exit_condition()
742- // is called last since it grabs a lock and we only want to do that when
743- // we must.
744- //
745- // Note: we never deliver an async exception at a polling point as the
746- // compiler may not have an exception handler for it. The polling
747- // code will notice the async and deoptimize and the exception will
748- // be delivered. (Polling at a return point is ok though). Sure is
749- // a lot of bother for a deprecated feature...
750- //
751- // We don't deliver an async exception if the thread state is
752- // _thread_in_native_trans so JNI functions won't be called with
753- // a surprising pending exception. If the thread state is going back to java,
754- // async exception is checked in check_special_condition_for_native_trans().
755-
756- if (state != _thread_blocked_trans &&
757- state != _thread_in_vm_trans &&
758- thread->has_special_runtime_exit_condition ()) {
759- thread->handle_special_runtime_exit_condition (
760- !thread->is_at_poll_safepoint () && (state != _thread_in_native_trans));
761- }
762-
763740 // cross_modify_fence is done by SafepointMechanism::process_if_requested
764741 // which is the only caller here.
765742}
@@ -955,12 +932,7 @@ void ThreadSafepointState::handle_polling_page_exception() {
955932 StackWatermarkSet::after_unwind (self);
956933
957934 // Process pending operation
958- SafepointMechanism::process_if_requested (self);
959- // We have to wait if we are here because of a handshake for object deoptimization.
960- if (self->is_obj_deopt_suspend ()) {
961- self->wait_for_object_deoptimization ();
962- }
963- self->check_and_handle_async_exceptions ();
935+ SafepointMechanism::process_if_requested_with_exit_check (self, true /* check asyncs */ );
964936
965937 // restore oop result, if any
966938 if (return_oop) {
@@ -970,17 +942,18 @@ void ThreadSafepointState::handle_polling_page_exception() {
970942
971943 // This is a safepoint poll. Verify the return address and block.
972944 else {
973- set_at_poll_safepoint (true );
974945
975946 // verify the blob built the "return address" correctly
976947 assert (real_return_addr == caller_fr.pc (), " must match" );
977948
949+ set_at_poll_safepoint (true );
978950 // Process pending operation
979- SafepointMechanism::process_if_requested (self);
980- // We have to wait if we are here because of a handshake for object deoptimization.
981- if (self->is_obj_deopt_suspend ()) {
982- self->wait_for_object_deoptimization ();
983- }
951+ // We never deliver an async exception at a polling point as the
952+ // compiler may not have an exception handler for it. The polling
953+ // code will notice the pending async exception, deoptimize and
954+ // the exception will be delivered. (Polling at a return point
955+ // is ok though). Sure is a lot of bother for a deprecated feature...
956+ SafepointMechanism::process_if_requested_with_exit_check (self, false /* check asyncs */ );
984957 set_at_poll_safepoint (false );
985958
986959 // If we have a pending async exception deoptimize the frame
0 commit comments