mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8265327: Remove check_safepoint_and_suspend_for_native_trans()
Reviewed-by: dcubed, dholmes, rrich
This commit is contained in:
parent
c9b70c8042
commit
8e312297d8
3 changed files with 15 additions and 34 deletions
|
@ -111,18 +111,18 @@ class ThreadStateTransition : public StackObj {
|
||||||
static inline void transition_from_native(JavaThread *thread, JavaThreadState to) {
|
static inline void transition_from_native(JavaThread *thread, JavaThreadState to) {
|
||||||
assert((to & 1) == 0, "odd numbers are transitions states");
|
assert((to & 1) == 0, "odd numbers are transitions states");
|
||||||
assert(thread->thread_state() == _thread_in_native, "coming from wrong thread state");
|
assert(thread->thread_state() == _thread_in_native, "coming from wrong thread state");
|
||||||
|
assert(!thread->has_last_Java_frame() || thread->frame_anchor()->walkable(), "Unwalkable stack in native->vm transition");
|
||||||
|
|
||||||
// Change to transition state and ensure it is seen by the VM thread.
|
// Change to transition state and ensure it is seen by the VM thread.
|
||||||
thread->set_thread_state_fence(_thread_in_native_trans);
|
thread->set_thread_state_fence(_thread_in_native_trans);
|
||||||
|
|
||||||
// We never install asynchronous exceptions when coming (back) in
|
// We never install asynchronous exceptions when coming (back) in
|
||||||
// to the runtime from native code because the runtime is not set
|
// to the runtime from native code because the runtime is not set
|
||||||
// up to handle exceptions floating around at arbitrary points.
|
// up to handle exceptions floating around at arbitrary points.
|
||||||
if (SafepointMechanism::should_process(thread) || thread->is_suspend_after_native()) {
|
SafepointMechanism::process_if_requested_with_exit_check(thread, false /* check asyncs */);
|
||||||
JavaThread::check_safepoint_and_suspend_for_native_trans(thread);
|
|
||||||
}
|
|
||||||
|
|
||||||
thread->set_thread_state(to);
|
thread->set_thread_state(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void trans(JavaThreadState from, JavaThreadState to) { transition(_thread, from, to); }
|
void trans(JavaThreadState from, JavaThreadState to) { transition(_thread, from, to); }
|
||||||
void trans_from_java(JavaThreadState to) { transition_from_java(_thread, to); }
|
void trans_from_java(JavaThreadState to) { transition_from_java(_thread, to); }
|
||||||
|
|
|
@ -1869,32 +1869,19 @@ void JavaThread::verify_not_published() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Slow path when the native==>VM/Java barriers detect a safepoint is in
|
// Slow path when the native==>Java barriers detect a safepoint/handshake is
|
||||||
// progress or when _suspend_flags is non-zero.
|
// pending, when _suspend_flags is non-zero or when we need to process a stack
|
||||||
// Current thread needs to self-suspend if there is a suspend request and/or
|
// watermark. Also check for pending async exceptions (except unsafe access error).
|
||||||
// block if a safepoint is in progress.
|
// Note only the native==>Java barriers can call this function when thread state
|
||||||
// Async exception ISN'T checked.
|
// is _thread_in_native_trans.
|
||||||
// Note only the ThreadInVMfromNative transition can call this function
|
|
||||||
// directly and when thread state is _thread_in_native_trans
|
|
||||||
void JavaThread::check_safepoint_and_suspend_for_native_trans(JavaThread *thread) {
|
|
||||||
assert(thread->thread_state() == _thread_in_native_trans, "wrong state");
|
|
||||||
assert(!thread->has_last_Java_frame() || thread->frame_anchor()->walkable(), "Unwalkable stack in native->vm transition");
|
|
||||||
|
|
||||||
SafepointMechanism::process_if_requested_with_exit_check(thread, false /* check asyncs */);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Slow path when the native==>VM/Java barriers detect a safepoint is in
|
|
||||||
// progress or when _suspend_flags is non-zero.
|
|
||||||
// Current thread needs to self-suspend if there is a suspend request and/or
|
|
||||||
// block if a safepoint is in progress.
|
|
||||||
// Also check for pending async exception (not including unsafe access error).
|
|
||||||
// Note only the native==>VM/Java barriers can call this function and when
|
|
||||||
// thread state is _thread_in_native_trans.
|
|
||||||
void JavaThread::check_special_condition_for_native_trans(JavaThread *thread) {
|
void JavaThread::check_special_condition_for_native_trans(JavaThread *thread) {
|
||||||
|
assert(thread->thread_state() == _thread_in_native_trans, "wrong state");
|
||||||
|
assert(!thread->has_last_Java_frame() || thread->frame_anchor()->walkable(), "Unwalkable stack in native->Java transition");
|
||||||
|
|
||||||
// Enable WXWrite: called directly from interpreter native wrapper.
|
// Enable WXWrite: called directly from interpreter native wrapper.
|
||||||
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, thread));
|
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, thread));
|
||||||
|
|
||||||
check_safepoint_and_suspend_for_native_trans(thread);
|
SafepointMechanism::process_if_requested_with_exit_check(thread, false /* check asyncs */);
|
||||||
|
|
||||||
// After returning from native, it could be that the stack frames are not
|
// After returning from native, it could be that the stack frames are not
|
||||||
// yet safe to use. We catch such situations in the subsequent stack watermark
|
// yet safe to use. We catch such situations in the subsequent stack watermark
|
||||||
|
|
|
@ -1145,16 +1145,9 @@ class JavaThread: public Thread {
|
||||||
bool java_resume(); // higher-level resume logic called by the public APIs
|
bool java_resume(); // higher-level resume logic called by the public APIs
|
||||||
bool is_suspended() { return _handshake.is_suspended(); }
|
bool is_suspended() { return _handshake.is_suspended(); }
|
||||||
|
|
||||||
static void check_safepoint_and_suspend_for_native_trans(JavaThread *thread);
|
|
||||||
// Check for async exception in addition to safepoint.
|
// Check for async exception in addition to safepoint.
|
||||||
static void check_special_condition_for_native_trans(JavaThread *thread);
|
static void check_special_condition_for_native_trans(JavaThread *thread);
|
||||||
|
|
||||||
// Whenever a thread transitions from native to vm/java it must suspend
|
|
||||||
// if deopt suspend is present.
|
|
||||||
bool is_suspend_after_native() const {
|
|
||||||
return (_suspend_flags & (_obj_deopt JFR_ONLY(| _trace_flag))) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Synchronize with another thread that is deoptimizing objects of the
|
// Synchronize with another thread that is deoptimizing objects of the
|
||||||
// current thread, i.e. reverts optimizations based on escape analysis.
|
// current thread, i.e. reverts optimizations based on escape analysis.
|
||||||
void wait_for_object_deoptimization();
|
void wait_for_object_deoptimization();
|
||||||
|
@ -1178,7 +1171,8 @@ class JavaThread: public Thread {
|
||||||
// Return true if JavaThread has an asynchronous condition or
|
// Return true if JavaThread has an asynchronous condition or
|
||||||
// if external suspension is requested.
|
// if external suspension is requested.
|
||||||
bool has_special_runtime_exit_condition() {
|
bool has_special_runtime_exit_condition() {
|
||||||
return (_special_runtime_exit_condition != _no_async_condition) || is_trace_suspend() || is_obj_deopt_suspend();
|
return (_special_runtime_exit_condition != _no_async_condition) ||
|
||||||
|
(_suspend_flags & (_obj_deopt JFR_ONLY(| _trace_flag))) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_pending_unsafe_access_error() { _special_runtime_exit_condition = _async_unsafe_access_error; }
|
void set_pending_unsafe_access_error() { _special_runtime_exit_condition = _async_unsafe_access_error; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue