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

Use GC continuation list in walkAllStackFrames #16884

Merged
merged 1 commit into from
Mar 14, 2023
Merged
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
60 changes: 22 additions & 38 deletions runtime/vm/ContinuationHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "vm_api.h"
#include "AtomicSupport.hpp"
#include "ContinuationHelpers.hpp"
#include "HeapIteratorAPI.h"
#include "OutOfLineINL.hpp"
#include "VMHelpers.hpp"

Expand Down Expand Up @@ -292,6 +293,19 @@ walkContinuationStackFrames(J9VMThread *currentThread, J9VMContinuation *continu
return rc;
}


jvmtiIterationControl
walkContinuationCallBack(J9VMThread *vmThread, J9MM_IterateObjectDescriptor *object, void *userData)
{
J9VMContinuation *continuation = J9VMJDKINTERNALVMCONTINUATION_VMREF(vmThread, object->object);
if (NULL != continuation) {
J9StackWalkState localWalkState = *(J9StackWalkState*)userData;
/* Walk non-null continuation's stack */
walkContinuationStackFrames(vmThread, continuation, &localWalkState);
}
return JVMTI_ITERATION_CONTINUE;
}

UDATA
walkAllStackFrames(J9VMThread *currentThread, J9StackWalkState *walkState)
{
Expand All @@ -309,47 +323,17 @@ walkAllStackFrames(J9VMThread *currentThread, J9StackWalkState *walkState)
localWalkState.walkThread = targetThread;
rc = vm->walkStackFrames(currentThread, &localWalkState);

if (NULL != targetThread->currentContinuation) {
localWalkState = *walkState;
walkContinuationStackFrames(currentThread, targetThread->currentContinuation, &localWalkState);
}
targetThread = targetThread->linkNext;
} while (targetThread != vm->mainThread);

/* Walk all contination stacks */
if (NULL != vm->liveVirtualThreadList) {
j9object_t rootNode = J9_JNI_UNWRAP_REFERENCE(vm->liveVirtualThreadList);
j9object_t nextVThread = J9OBJECT_OBJECT_LOAD(currentThread, rootNode, vm->virtualThreadLinkNextOffset);
J9VMContinuation *continuation = NULL;
while (nextVThread != rootNode) {
j9object_t cont = J9VMJAVALANGVIRTUALTHREAD_CONT(currentThread, nextVThread);
continuation = J9VMJDKINTERNALVMCONTINUATION_VMREF(currentThread, cont);
if (NULL != continuation) {
/* Reset localWalkState */
localWalkState = *walkState;
/* walk live continuation's stack */
rc = walkContinuationStackFrames(currentThread, continuation, &localWalkState);
}
nextVThread = J9OBJECT_OBJECT_LOAD(currentThread, nextVThread, vm->virtualThreadLinkNextOffset);
}
}
/* Alternate approach to rely on GC Continuation object iterator
GC_ContinuationIterator iter = getContinuationIterator();
J9VMContinuation *continuation = NULL;
while(NULL != iter) {
continuation = J9VMJDKINTERNALVMCONTINUATION_VMREF(currentThread, nextCont);
if (NULL != continuation) {
// Reset localWalkState
localWalkState = *walkState;
// walk live continuation's stack
rc = walkContinuationStackFrames(currentThread, continuation, &localWalkState);
if (J9_STACKWALK_RC_NONE != rc) {
goto exit;
}
}
iter = iter.next();
}
*/
/* Walk all live continuation stacks using the GC Continuation object iterator */
PORT_ACCESS_FROM_VMC(currentThread);
vm->memoryManagerFunctions->j9mm_iterate_all_continuation_objects(
currentThread,
privatePortLibrary,
babsingh marked this conversation as resolved.
Show resolved Hide resolved
0,
walkContinuationCallBack,
(void*)walkState);
return rc;
}
} /* extern "C" */