Skip to content

Commit 1b49606

Browse files
committed
8293922: Extend barrier-less Java thread transitions to native transitions
Reviewed-by: mdoerr, pchilanomate, dcubed
1 parent a07902b commit 1b49606

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
// No interfaceSupport.hpp
3030

3131
#include "gc/shared/gc_globals.hpp"
32+
#include "runtime/globals.hpp"
3233
#include "runtime/handles.inline.hpp"
3334
#include "runtime/javaThread.inline.hpp"
3435
#include "runtime/mutexLocker.hpp"
@@ -97,7 +98,11 @@ class ThreadStateTransition : public StackObj {
9798
assert(to == _thread_in_vm || to == _thread_in_Java, "invalid transition");
9899
assert(!thread->has_last_Java_frame() || thread->frame_anchor()->walkable(), "Unwalkable stack in native transition");
99100

100-
thread->set_thread_state_fence(_thread_in_vm);
101+
if (!UseSystemMemoryBarrier) {
102+
thread->set_thread_state_fence(_thread_in_vm);
103+
} else {
104+
thread->set_thread_state(_thread_in_vm);
105+
}
101106
SafepointMechanism::process_if_requested_with_exit_check(thread, to != _thread_in_Java ? false : check_asyncs);
102107
thread->set_thread_state(to);
103108
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ inline JavaThreadState JavaThread::thread_state() const {
145145
#if defined(PPC64) || defined (AARCH64) || defined(RISCV64)
146146
// Use membars when accessing volatile _thread_state. See
147147
// Threads::create_vm() for size checks.
148-
return (JavaThreadState) Atomic::load_acquire((volatile jint*)&_thread_state);
148+
return Atomic::load_acquire(&_thread_state);
149149
#else
150-
return _thread_state;
150+
return Atomic::load(&_thread_state);
151151
#endif
152152
}
153153

@@ -157,9 +157,9 @@ inline void JavaThread::set_thread_state(JavaThreadState s) {
157157
#if defined(PPC64) || defined (AARCH64) || defined(RISCV64)
158158
// Use membars when accessing volatile _thread_state. See
159159
// Threads::create_vm() for size checks.
160-
Atomic::release_store((volatile jint*)&_thread_state, (jint)s);
160+
Atomic::release_store(&_thread_state, s);
161161
#else
162-
_thread_state = s;
162+
Atomic::store(&_thread_state, s);
163163
#endif
164164
}
165165

0 commit comments

Comments
 (0)