Skip to content

Commit

Permalink
Support tracing reference on continuation java frames for jvmti
Browse files Browse the repository at this point in the history
Jvmti trace live heap objects via j9gc_ext_reachable_objects_do
 (MM_ReferenceChainWalker), update MM_ReferenceChainWalker to support
 to trace the references on the java frames of continuation.

 - only unmounted continuations would be scanned via
  scanContinuationObject(), the mounted continuation would be scanned
  via scanThread (thread->currentContinuation).

Signed-off-by: Lin Hu <[email protected]>
  • Loading branch information
LinHu2016 committed Sep 28, 2023
1 parent 32a6198 commit 56a0a9c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
42 changes: 41 additions & 1 deletion runtime/gc_base/ReferenceChainWalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,13 @@ MM_ReferenceChainWalker::scanObject(J9Object *objectPtr)
case GC_ObjectModel::SCAN_ATOMIC_MARKABLE_REFERENCE_OBJECT:
case GC_ObjectModel::SCAN_MIXED_OBJECT:
case GC_ObjectModel::SCAN_OWNABLESYNCHRONIZER_OBJECT:
case GC_ObjectModel::SCAN_CONTINUATION_OBJECT:
case GC_ObjectModel::SCAN_CLASS_OBJECT:
case GC_ObjectModel::SCAN_CLASSLOADER_OBJECT:
scanMixedObject(objectPtr);
break;
case GC_ObjectModel::SCAN_CONTINUATION_OBJECT:
scanContinuationObject(objectPtr);
break;
case GC_ObjectModel::SCAN_POINTER_ARRAY_OBJECT:
scanPointerArrayObject((J9IndexableObject *)objectPtr);
break;
Expand All @@ -375,6 +377,44 @@ MM_ReferenceChainWalker::scanObject(J9Object *objectPtr)
}
}

/**
* @todo Provide function documentation
*/
void
stackSlotIteratorForReferenceChainWalker(J9JavaVM *javaVM, J9Object **slot, void *localData, J9StackWalkState *walkState, const void *stackLocation)
{
StackIteratorData *data = (StackIteratorData *)localData;
data->rootScanner->doStackSlot(slot, walkState, stackLocation);
}

/**
* @todo Provide function documentation
*/
MMINLINE void
MM_ReferenceChainWalker::scanContinuationNativeSlots(J9Object *objectPtr)
{
J9VMThread *currentThread = (J9VMThread *)_env->getLanguageVMThread();
const bool isConcurrentGC = false;
const bool isGlobalGC = false;
const bool beingMounted = false;
if (MM_GCExtensions::needScanStacksForContinuationObject(currentThread, objectPtr, isConcurrentGC, isGlobalGC, beingMounted)) {
StackIteratorData localData;
localData.rootScanner = this;

GC_VMThreadStackSlotIterator::scanContinuationSlots(currentThread, objectPtr, (void *)&localData, stackSlotIteratorForReferenceChainWalker, false, false);
}
}

/**
* @todo Provide function documentation
*/
void
MM_ReferenceChainWalker::scanContinuationObject(J9Object *objectPtr)
{
scanContinuationNativeSlots(objectPtr);
scanMixedObject(objectPtr);
}

/**
* @todo Provide function documentation
*/
Expand Down
3 changes: 3 additions & 0 deletions runtime/gc_base/ReferenceChainWalker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class MM_ReferenceChainWalker : public MM_RootScanner
virtual void scanMixedObject(J9Object *objectPtr);
virtual void scanPointerArrayObject(J9IndexableObject *objectPtr);
virtual void scanReferenceMixedObject(J9Object *objectPtr);

MMINLINE void scanContinuationNativeSlots(J9Object *objectPtr);
MMINLINE void scanContinuationObject(J9Object *objectPtr);

virtual void doClassLoader(J9ClassLoader *classLoader);

Expand Down

0 comments on commit 56a0a9c

Please sign in to comment.