8293922: Extend barrier-less Java thread transitions to native transitions

Reviewed-by: mdoerr, pchilanomate, dcubed
This commit is contained in:
Robbin Ehn 2022-09-20 08:41:39 +00:00
parent a07902bcbe
commit 1b496064bf
2 changed files with 10 additions and 5 deletions

View File

@ -29,6 +29,7 @@
// No interfaceSupport.hpp
#include "gc/shared/gc_globals.hpp"
#include "runtime/globals.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/javaThread.inline.hpp"
#include "runtime/mutexLocker.hpp"
@ -97,7 +98,11 @@ class ThreadStateTransition : public StackObj {
assert(to == _thread_in_vm || to == _thread_in_Java, "invalid transition");
assert(!thread->has_last_Java_frame() || thread->frame_anchor()->walkable(), "Unwalkable stack in native transition");
thread->set_thread_state_fence(_thread_in_vm);
if (!UseSystemMemoryBarrier) {
thread->set_thread_state_fence(_thread_in_vm);
} else {
thread->set_thread_state(_thread_in_vm);
}
SafepointMechanism::process_if_requested_with_exit_check(thread, to != _thread_in_Java ? false : check_asyncs);
thread->set_thread_state(to);
}

View File

@ -145,9 +145,9 @@ inline JavaThreadState JavaThread::thread_state() const {
#if defined(PPC64) || defined (AARCH64) || defined(RISCV64)
// Use membars when accessing volatile _thread_state. See
// Threads::create_vm() for size checks.
return (JavaThreadState) Atomic::load_acquire((volatile jint*)&_thread_state);
return Atomic::load_acquire(&_thread_state);
#else
return _thread_state;
return Atomic::load(&_thread_state);
#endif
}
@ -157,9 +157,9 @@ inline void JavaThread::set_thread_state(JavaThreadState s) {
#if defined(PPC64) || defined (AARCH64) || defined(RISCV64)
// Use membars when accessing volatile _thread_state. See
// Threads::create_vm() for size checks.
Atomic::release_store((volatile jint*)&_thread_state, (jint)s);
Atomic::release_store(&_thread_state, s);
#else
_thread_state = s;
Atomic::store(&_thread_state, s);
#endif
}