Skip to content

Commit

Permalink
Merge pull request #5936 from amicic/acquring_exclusive_in_native
Browse files Browse the repository at this point in the history
Acquiring exclusive in native VM hook
  • Loading branch information
gacholio authored May 29, 2019
2 parents 28b5c30 + a8897bd commit 7d37c22
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions runtime/oti/j9vm.hdf
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,18 @@ typedef UDATA (* lookupNativeAddressCallback)(struct J9VMThread *currentThread,
<struct>J9VMReleaseVMAccessEvent</struct>
<data type="struct J9VMThread*" name="currentThread" description="current thread" />
</event>

<event>
<name>J9HOOK_VM_ACQUIRING_EXCLUSIVE_IN_NATIVE</name>
<description>
Triggered during acquire exclusive thread loop, when encountered a thread in native (which we did not count for exclusive).
This hook serves similar purpose as J9HOOK_VM_RELEASEVMACCESS, to ensure that required work for thread in native
is performed before exclusive access is obtained.
</description>
<struct>J9VMAcquringExclusiveInNativeEvent</struct>
<data type="struct J9VMThread*" name="currentThread" description="calling thread" />
<data type="struct J9VMThread*" name="targetThread" description="thread in native" />
</event>

<event>
<name>J9HOOK_VM_THREAD_CRASH</name>
Expand Down
2 changes: 2 additions & 0 deletions runtime/vm/VMAccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ acquireExclusiveVMAccess(J9VMThread * vmThread)
#endif /* !J9VM_INTERP_TWO_PASS_EXCLUSIVE */
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI)
if (currentThread->inNative) {
TRIGGER_J9HOOK_VM_ACQUIRING_EXCLUSIVE_IN_NATIVE(vm->hookInterface, vmThread, currentThread);
#if !defined(J9VM_INTERP_TWO_PASS_EXCLUSIVE)
VM_VMAccess::setPublicFlags(currentThread, J9_PUBLIC_FLAGS_NOT_COUNTED_BY_EXCLUSIVE);
#endif /* !J9VM_INTERP_TWO_PASS_EXCLUSIVE */
Expand Down Expand Up @@ -1135,6 +1136,7 @@ acquireSafePointVMAccess(J9VMThread * vmThread)
#endif /* !J9VM_INTERP_TWO_PASS_EXCLUSIVE */
#if defined(J9VM_INTERP_ATOMIC_FREE_JNI)
if (currentThread->inNative) {
TRIGGER_J9HOOK_VM_ACQUIRING_EXCLUSIVE_IN_NATIVE(vm->hookInterface, vmThread, currentThread);
Assert_VM_false(J9_ARE_ANY_BITS_SET(currentThread->publicFlags, J9_PUBLIC_FLAGS_NOT_AT_SAFE_POINT));
#if !defined(J9VM_INTERP_TWO_PASS_EXCLUSIVE)
VM_VMAccess::setPublicFlags(currentThread, J9_PUBLIC_FLAGS_NOT_COUNTED_BY_SAFE_POINT);
Expand Down

0 comments on commit 7d37c22

Please sign in to comment.