Skip to content

Commit 3675653

Browse files
committed
8255384: Remove special_runtime_exit_condition() check from SS::block()
Reviewed-by: dholmes, rrich, dcubed
1 parent f611fdf commit 3675653

File tree

6 files changed

+30
-57
lines changed

6 files changed

+30
-57
lines changed

src/hotspot/share/interpreter/zero/bytecodeInterpreter.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,14 @@
102102
There really shouldn't be any handles remaining to trash but this is cheap
103103
in relation to a safepoint.
104104
*/
105-
#define SAFEPOINT \
106-
{ \
107-
/* zap freed handles rather than GC'ing them */ \
108-
HandleMarkCleaner __hmc(THREAD); \
109-
CALL_VM(SafepointMechanism::process_if_requested(THREAD), handle_exception); \
105+
#define SAFEPOINT \
106+
{ \
107+
/* zap freed handles rather than GC'ing them */ \
108+
HandleMarkCleaner __hmc(THREAD); \
109+
if (SafepointMechanism::should_process(THREAD)) { \
110+
CALL_VM(SafepointMechanism::process_if_requested_with_exit_check(THREAD, true /* check asyncs */), \
111+
handle_exception); \
112+
} \
110113
}
111114

112115
/*

src/hotspot/share/runtime/safepoint.cpp

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/hotspot/share/runtime/safepointMechanism.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void SafepointMechanism::process(JavaThread *thread) {
8080
// Any load in ::block must not pass the global poll load.
8181
// Otherwise we might load an old safepoint counter (for example).
8282
OrderAccess::loadload();
83-
SafepointSynchronize::block(thread); // Recursive
83+
SafepointSynchronize::block(thread);
8484
}
8585

8686
// The call to on_safepoint fixes the thread's oops and the first few frames.

src/hotspot/share/runtime/safepointMechanism.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class SafepointMechanism : public AllStatic {
8383

8484
// Processes a pending requested operation.
8585
static inline void process_if_requested(JavaThread* thread);
86+
static inline void process_if_requested_with_exit_check(JavaThread* thread, bool check_asyncs);
8687
// Compute what the poll values should be and install them.
8788
static void update_poll_values(JavaThread* thread);
8889

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ void SafepointMechanism::process_if_requested(JavaThread *thread) {
8080
process_if_requested_slow(thread);
8181
}
8282

83+
void SafepointMechanism::process_if_requested_with_exit_check(JavaThread* thread, bool check_asyncs) {
84+
process_if_requested(thread);
85+
if (thread->has_special_runtime_exit_condition()) {
86+
thread->handle_special_runtime_exit_condition(check_asyncs);
87+
}
88+
}
89+
8390
void SafepointMechanism::arm_local_poll(JavaThread* thread) {
8491
thread->poll_data()->set_polling_word(_poll_word_armed_value);
8592
thread->poll_data()->set_polling_page(_poll_page_armed_value);

src/hotspot/share/runtime/thread.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,11 +2409,11 @@ void JavaThread::java_suspend_self_with_safepoint_check() {
24092409
// might return to _thread_in_Java and execute bytecodes for an arbitrary
24102410
// long time.
24112411
set_thread_state_fence(state);
2412-
} while (is_external_suspend());
24132412

2414-
if (state != _thread_in_native) {
2415-
SafepointMechanism::process_if_requested(this);
2416-
}
2413+
if (state != _thread_in_native) {
2414+
SafepointMechanism::process_if_requested(this);
2415+
}
2416+
} while (is_external_suspend());
24172417
}
24182418

24192419
// Wait for another thread to perform object reallocation and relocking on behalf of
@@ -2493,20 +2493,9 @@ void JavaThread::verify_not_published() {
24932493
// directly and when thread state is _thread_in_native_trans
24942494
void JavaThread::check_safepoint_and_suspend_for_native_trans(JavaThread *thread) {
24952495
assert(thread->thread_state() == _thread_in_native_trans, "wrong state");
2496-
24972496
assert(!thread->has_last_Java_frame() || thread->frame_anchor()->walkable(), "Unwalkable stack in native->vm transition");
24982497

2499-
if (thread->is_external_suspend()) {
2500-
thread->java_suspend_self_with_safepoint_check();
2501-
} else {
2502-
SafepointMechanism::process_if_requested(thread);
2503-
}
2504-
2505-
if (thread->is_obj_deopt_suspend()) {
2506-
thread->wait_for_object_deoptimization();
2507-
}
2508-
2509-
JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(thread);)
2498+
SafepointMechanism::process_if_requested_with_exit_check(thread, false /* check asyncs */);
25102499
}
25112500

25122501
// Slow path when the native==>VM/Java barriers detect a safepoint is in

0 commit comments

Comments
 (0)