Skip to content

closeScope0 should not walk all threads #15450

Description

@tajila

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions