-
Notifications
You must be signed in to change notification settings - Fork 721
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
Loom: GC Thread scanning #15612
Loom: GC Thread scanning #15612
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,42 @@ vmThreadStackFrameIterator(J9VMThread * currentThread, J9StackWalkState * walkSt | |
|
||
} /* extern "C" */ | ||
|
||
void | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either make this is a static method or make the name of the method more specific for GC purposes. In theory there could be a same/similar method somewhere in core VM code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as I said in hpp comment, make this method a class member and remove 'forGC' |
||
GC_VMThreadStackSlotIterator::initializeStackWalkState( | ||
J9StackWalkState *stackWalkState, | ||
J9VMThread *vmThread, | ||
void *userData, | ||
J9MODRON_OSLOTITERATOR *oSlotIterator, | ||
bool includeStackFrameClassReferences, | ||
bool trackVisibleFrameDepth | ||
) | ||
{ | ||
J9JavaVM *vm = vmThread->javaVM; | ||
|
||
stackWalkState->objectSlotWalkFunction = vmThreadStackDoOSlotIterator; | ||
stackWalkState->userData1 = (void *)oSlotIterator; | ||
stackWalkState->userData2 = (void *)vm; | ||
stackWalkState->userData3 = userData; | ||
|
||
stackWalkState->flags = J9_STACKWALK_ITERATE_O_SLOTS | J9_STACKWALK_DO_NOT_SNIFF_AND_WHACK; | ||
stackWalkState->walkThread = NULL; | ||
|
||
if (trackVisibleFrameDepth) { | ||
stackWalkState->skipCount = 0; | ||
stackWalkState->flags |= J9_STACKWALK_VISIBLE_ONLY; | ||
} else { | ||
if (NULL != vm->collectJitPrivateThreadData) { | ||
stackWalkState->frameWalkFunction = vmThreadStackFrameIterator; | ||
stackWalkState->flags |= J9_STACKWALK_ITERATE_FRAMES; | ||
} | ||
stackWalkState->flags |= J9_STACKWALK_SKIP_INLINES; | ||
} | ||
|
||
if (includeStackFrameClassReferences) { | ||
stackWalkState->flags |= J9_STACKWALK_ITERATE_METHOD_CLASS_SLOTS; | ||
} | ||
|
||
} | ||
/** | ||
* Walk all slots of the walk thread which contain object references. | ||
* For every object slot found in <code>walkThread</code> call the <code>oSlotIterator</code> function. | ||
|
@@ -87,32 +123,10 @@ GC_VMThreadStackSlotIterator::scanSlots( | |
) | ||
{ | ||
J9StackWalkState stackWalkState; | ||
J9JavaVM *vm = vmThread->javaVM; | ||
|
||
stackWalkState.objectSlotWalkFunction = vmThreadStackDoOSlotIterator; | ||
stackWalkState.userData1 = (void *)oSlotIterator; | ||
stackWalkState.userData2 = (void *)vm; | ||
stackWalkState.userData3 = userData; | ||
|
||
stackWalkState.flags = J9_STACKWALK_ITERATE_O_SLOTS | J9_STACKWALK_DO_NOT_SNIFF_AND_WHACK; | ||
initializeStackWalkState(&stackWalkState, vmThread, userData, oSlotIterator, includeStackFrameClassReferences, trackVisibleFrameDepth); | ||
stackWalkState.walkThread = walkThread; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we set this explicitely to NULL in other cases? |
||
|
||
if (trackVisibleFrameDepth) { | ||
stackWalkState.skipCount = 0; | ||
stackWalkState.flags |= J9_STACKWALK_VISIBLE_ONLY; | ||
} else { | ||
if (NULL != vm->collectJitPrivateThreadData) { | ||
stackWalkState.frameWalkFunction = vmThreadStackFrameIterator; | ||
stackWalkState.flags |= J9_STACKWALK_ITERATE_FRAMES; | ||
} | ||
stackWalkState.flags |= J9_STACKWALK_SKIP_INLINES; | ||
} | ||
|
||
if (includeStackFrameClassReferences) { | ||
stackWalkState.flags |= J9_STACKWALK_ITERATE_METHOD_CLASS_SLOTS; | ||
} | ||
|
||
vm->walkStackFrames(vmThread, &stackWalkState); | ||
vmThread->javaVM->walkStackFrames(vmThread, &stackWalkState); | ||
} | ||
|
||
void | ||
|
@@ -126,29 +140,25 @@ GC_VMThreadStackSlotIterator::scanSlots( | |
) | ||
{ | ||
J9StackWalkState stackWalkState; | ||
J9JavaVM *vm = vmThread->javaVM; | ||
initializeStackWalkState(&stackWalkState, vmThread, userData, oSlotIterator, includeStackFrameClassReferences, trackVisibleFrameDepth); | ||
|
||
stackWalkState.objectSlotWalkFunction = vmThreadStackDoOSlotIterator; | ||
stackWalkState.userData1 = (void *)oSlotIterator; | ||
stackWalkState.userData2 = (void *)vm; | ||
stackWalkState.userData3 = userData; | ||
|
||
stackWalkState.flags = J9_STACKWALK_ITERATE_O_SLOTS | J9_STACKWALK_DO_NOT_SNIFF_AND_WHACK; | ||
|
||
if (trackVisibleFrameDepth) { | ||
stackWalkState.skipCount = 0; | ||
stackWalkState.flags |= J9_STACKWALK_VISIBLE_ONLY; | ||
} else { | ||
if (NULL != vm->collectJitPrivateThreadData) { | ||
stackWalkState.frameWalkFunction = vmThreadStackFrameIterator; | ||
stackWalkState.flags |= J9_STACKWALK_ITERATE_FRAMES; | ||
} | ||
stackWalkState.flags |= J9_STACKWALK_SKIP_INLINES; | ||
} | ||
VM_VMHelpers::walkContinuationStackFramesWrapper(vmThread, continuationObjectPtr, &stackWalkState); | ||
} | ||
|
||
if (includeStackFrameClassReferences) { | ||
stackWalkState.flags |= J9_STACKWALK_ITERATE_METHOD_CLASS_SLOTS; | ||
} | ||
#if JAVA_SPEC_VERSION >= 19 | ||
void | ||
GC_VMThreadStackSlotIterator::scanSlots( | ||
J9VMThread *vmThread, | ||
J9VMContinuation *continuation, | ||
void *userData, | ||
J9MODRON_OSLOTITERATOR *oSlotIterator, | ||
bool includeStackFrameClassReferences, | ||
bool trackVisibleFrameDepth | ||
) | ||
{ | ||
J9StackWalkState stackWalkState; | ||
initializeStackWalkState(&stackWalkState, vmThread, userData, oSlotIterator, includeStackFrameClassReferences, trackVisibleFrameDepth); | ||
|
||
VM_VMHelpers::walkContinuationStackFramesWrapper(vmThread, continuationObjectPtr, &stackWalkState); | ||
vmThread->javaVM->internalVMFunctions->walkContinuationStackFrames(vmThread, continuation, &stackWalkState); | ||
} | ||
#endif /* JAVA_SPEC_VERSION >= 19 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably put a comment above, something like this:
In a case this thread is a carrier thread, and a virtual thread is mounted, we will scan virtual thread's stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can append this comment by another sentence.
... If virtual thread is not mounted, or this is just a regular thread, this will scan its own stack.