Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atomic-free JNI work #1651

Merged
merged 1 commit into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions buildspecs/j9.flags
Original file line number Diff line number Diff line change
Expand Up @@ -829,13 +829,6 @@ Currently only available on linux_x86 and win_x96 32 bit builds.</description>
<description>Use the new atomic-free JNI support</description>
<ifRemoved>Atomics used to release/acquire VM access at JNI calls</ifRemoved>
</flag>
<flag id="interp_atomicFreeJniClearsVmAccess">
<description>Atomic free steals VM access from threads in JNI</description>
<ifRemoved>Atomic free leaves JNI thread with VM access</ifRemoved>
<requires>
<require flag="interp_atomicFreeJni"/>
</requires>
</flag>
<flag id="interp_atomicFreeJniUsesFlush">
<description>Atomic free uses FlushProcessWriteBuffers instead of barriers</description>
<ifRemoved>Atomic free uses barriers</ifRemoved>
Expand Down
6 changes: 1 addition & 5 deletions runtime/oti/VMAccess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,7 @@ class VM_VMAccess
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI)
if (vmThread->publicFlags & J9_PUBLIC_FLAGS_VM_ACCESS) {
VM_AtomicSupport::readBarrier(); // necessary?
if (vmThread->inNative) {
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI_CLEARS_VM_ACCESS)
clearPublicFlags(vmThread, J9_PUBLIC_FLAGS_VM_ACCESS);
#endif /* J9VM_INTERP_ATOMIC_FREE_JNI_CLEARS_VM_ACCESS */
} else {
if (!vmThread->inNative) {
mustWait = true;
}
}
Expand Down
16 changes: 4 additions & 12 deletions runtime/vm/VMAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ acquireExclusiveVMAccess(J9VMThread * vmThread)
if (currentThread->publicFlags & J9_PUBLIC_FLAGS_VM_ACCESS) {
VM_AtomicSupport::readBarrier(); // necessary?
if (currentThread->inNative) {
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI_CLEARS_VM_ACCESS)
VM_VMAccess::clearPublicFlags(currentThread, J9_PUBLIC_FLAGS_VM_ACCESS);
#elif !defined(J9VM_INTERP_TWO_PASS_EXCLUSIVE) /* J9VM_INTERP_ATOMIC_FREE_JNI_CLEARS_VM_ACCESS */
#if !defined(J9VM_INTERP_TWO_PASS_EXCLUSIVE)
VM_VMAccess::setPublicFlags(currentThread, J9_PUBLIC_FLAGS_NOT_COUNTED_BY_EXCLUSIVE);
#endif /* !J9VM_INTERP_TWO_PASS_EXCLUSIVE */
} else {
Expand Down Expand Up @@ -741,9 +739,7 @@ acquireExclusiveVMAccessFromExternalThread(J9JavaVM * vm)
if (currentThread->publicFlags & J9_PUBLIC_FLAGS_VM_ACCESS) {
VM_AtomicSupport::readBarrier(); // necessary?
if (currentThread->inNative) {
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI_CLEARS_VM_ACCESS)
VM_VMAccess::clearPublicFlags(currentThread, J9_PUBLIC_FLAGS_VM_ACCESS);
#elif !defined(J9VM_INTERP_TWO_PASS_EXCLUSIVE) /* J9VM_INTERP_ATOMIC_FREE_JNI_CLEARS_VM_ACCESS */
#if !defined(J9VM_INTERP_TWO_PASS_EXCLUSIVE)
VM_VMAccess::setPublicFlags(currentThread, J9_PUBLIC_FLAGS_NOT_COUNTED_BY_EXCLUSIVE);
#endif /* !J9VM_INTERP_TWO_PASS_EXCLUSIVE */
} else {
Expand Down Expand Up @@ -895,9 +891,7 @@ requestExclusiveVMAccessMetronomeTemp(J9JavaVM *vm, UDATA block, UDATA *vmRespon
if (thread->publicFlags & J9_PUBLIC_FLAGS_VM_ACCESS) {
VM_AtomicSupport::readBarrier(); // necessary?
if (thread->inNative) {
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI_CLEARS_VM_ACCESS)
VM_VMAccess::clearPublicFlags(thread, J9_PUBLIC_FLAGS_VM_ACCESS);
#elif !defined(J9VM_INTERP_TWO_PASS_EXCLUSIVE) /* J9VM_INTERP_ATOMIC_FREE_JNI_CLEARS_VM_ACCESS */
#if !defined(J9VM_INTERP_TWO_PASS_EXCLUSIVE)
VM_VMAccess::setPublicFlags(thread, J9_PUBLIC_FLAGS_NOT_COUNTED_BY_EXCLUSIVE);
#endif /* !J9VM_INTERP_TWO_PASS_EXCLUSIVE */
} else {
Expand Down Expand Up @@ -1103,9 +1097,7 @@ acquireSafePointVMAccess(J9VMThread * vmThread)
VM_AtomicSupport::readBarrier(); // necessary?
if (currentThread->inNative) {
Assert_VM_false(J9_ARE_ANY_BITS_SET(currentThread->publicFlags, J9_PUBLIC_FLAGS_NOT_AT_SAFE_POINT));
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI_CLEARS_VM_ACCESS)
VM_VMAccess::clearPublicFlags(currentThread, J9_PUBLIC_FLAGS_VM_ACCESS);
#elif !defined(J9VM_INTERP_TWO_PASS_EXCLUSIVE) /* J9VM_INTERP_ATOMIC_FREE_JNI_CLEARS_VM_ACCESS */
#if !defined(J9VM_INTERP_TWO_PASS_EXCLUSIVE)
VM_VMAccess::setPublicFlags(currentThread, J9_PUBLIC_FLAGS_NOT_COUNTED_BY_SAFE_POINT);
#endif /* !J9VM_INTERP_TWO_PASS_EXCLUSIVE */
VM_VMAccess::setPublicFlags(currentThread, J9_PUBLIC_FLAGS_HALTED_AT_SAFE_POINT, true);
Expand Down