Java_jdk_internal_misc_ScopedMemoryAccess_closeScope0 can be updated to only walk threads that can run java code. currently it walks all vmthreads.
J9VMThread *walkThread = J9_LINKED_LIST_START_DO(vm->mainThread);
while (NULL != walkThread) {
J9StackWalkState walkState;
walkState.walkThread = walkThread;
walkState.flags = J9_STACKWALK_ITERATE_FRAMES | J9_STACKWALK_ITERATE_O_SLOTS;
walkState.skipCount = 0;
walkState.userData1 = (void *)scope;
walkState.userData2 = (void *)&scopeNotFound;
walkState.frameWalkFunction = closeScope0FrameWalkFunction;
walkState.objectSlotWalkFunction = closeScope0OSlotWalkFunction;
vm->walkStackFrames(walkThread, &walkState);
if (JNI_FALSE == *(jboolean *)walkState.userData2) {
/* scope found */
break;
}
walkThread = J9_LINKED_LIST_NEXT_DO(vm->mainThread, walkThread);
}
vmFuncs->releaseExclusiveVMAccess(currentThread);
The use of VM_VMHelpers::threadCanRunJavaCode(walkThread) can identify the threads that need to be walked.
Java_jdk_internal_misc_ScopedMemoryAccess_closeScope0 can be updated to only walk threads that can run java code. currently it walks all vmthreads.
The use of
VM_VMHelpers::threadCanRunJavaCode(walkThread)can identify the threads that need to be walked.