2342 (!check_unsafe_error && condition == _async_unsafe_access_error), |
2342 (!check_unsafe_error && condition == _async_unsafe_access_error), |
2343 "must have handled the async condition, if no exception"); |
2343 "must have handled the async condition, if no exception"); |
2344 } |
2344 } |
2345 |
2345 |
2346 void JavaThread::handle_special_runtime_exit_condition(bool check_asyncs) { |
2346 void JavaThread::handle_special_runtime_exit_condition(bool check_asyncs) { |
2347 // |
2347 |
2348 // Check for pending external suspend. |
2348 // Check for pending external suspend. |
2349 // If JNIEnv proxies are allowed, don't self-suspend if the target |
2349 if (is_external_suspend_with_lock()) { |
2350 // thread is not the current thread. In older versions of jdbx, jdbx |
|
2351 // threads could call into the VM with another thread's JNIEnv so we |
|
2352 // can be here operating on behalf of a suspended thread (4432884). |
|
2353 bool do_self_suspend = is_external_suspend_with_lock(); |
|
2354 if (do_self_suspend && (!AllowJNIEnvProxy || this == JavaThread::current())) { |
|
2355 frame_anchor()->make_walkable(this); |
2350 frame_anchor()->make_walkable(this); |
2356 java_suspend_self_with_safepoint_check(); |
2351 java_suspend_self_with_safepoint_check(); |
2357 } |
2352 } |
2358 |
2353 |
2359 // We might be here for reasons in addition to the self-suspend request |
2354 // We might be here for reasons in addition to the self-suspend request |
2574 // Note only the ThreadInVMfromNative transition can call this function |
2569 // Note only the ThreadInVMfromNative transition can call this function |
2575 // directly and when thread state is _thread_in_native_trans |
2570 // directly and when thread state is _thread_in_native_trans |
2576 void JavaThread::check_safepoint_and_suspend_for_native_trans(JavaThread *thread) { |
2571 void JavaThread::check_safepoint_and_suspend_for_native_trans(JavaThread *thread) { |
2577 assert(thread->thread_state() == _thread_in_native_trans, "wrong state"); |
2572 assert(thread->thread_state() == _thread_in_native_trans, "wrong state"); |
2578 |
2573 |
2579 JavaThread *curJT = JavaThread::current(); |
2574 assert(!thread->has_last_Java_frame() || thread->frame_anchor()->walkable(), "Unwalkable stack in native->vm transition"); |
2580 bool do_self_suspend = thread->is_external_suspend(); |
2575 |
2581 |
2576 if (thread->is_external_suspend()) { |
2582 assert(!curJT->has_last_Java_frame() || curJT->frame_anchor()->walkable(), "Unwalkable stack in native->vm transition"); |
|
2583 |
|
2584 // If JNIEnv proxies are allowed, don't self-suspend if the target |
|
2585 // thread is not the current thread. In older versions of jdbx, jdbx |
|
2586 // threads could call into the VM with another thread's JNIEnv so we |
|
2587 // can be here operating on behalf of a suspended thread (4432884). |
|
2588 if (do_self_suspend && (!AllowJNIEnvProxy || curJT == thread)) { |
|
2589 thread->java_suspend_self_with_safepoint_check(); |
2577 thread->java_suspend_self_with_safepoint_check(); |
2590 } else { |
2578 } else { |
2591 SafepointMechanism::block_if_requested(curJT); |
2579 SafepointMechanism::block_if_requested(thread); |
2592 } |
2580 } |
2593 |
2581 |
2594 JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(thread);) |
2582 JFR_ONLY(SUSPEND_THREAD_CONDITIONAL(thread);) |
2595 } |
2583 } |
2596 |
2584 |