From 56a0a9c46721a368bcde26268784dd185a53ef22 Mon Sep 17 00:00:00 2001 From: Lin Hu Date: Wed, 27 Sep 2023 10:55:04 -0400 Subject: [PATCH] Support tracing reference on continuation java frames for jvmti 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 --- runtime/gc_base/ReferenceChainWalker.cpp | 42 +++++++++++++++++++++++- runtime/gc_base/ReferenceChainWalker.hpp | 3 ++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/runtime/gc_base/ReferenceChainWalker.cpp b/runtime/gc_base/ReferenceChainWalker.cpp index 227b2d77d42..9367ed2d8eb 100644 --- a/runtime/gc_base/ReferenceChainWalker.cpp +++ b/runtime/gc_base/ReferenceChainWalker.cpp @@ -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; @@ -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 */ diff --git a/runtime/gc_base/ReferenceChainWalker.hpp b/runtime/gc_base/ReferenceChainWalker.hpp index e2bbe64a1f8..6a9e2fece0f 100644 --- a/runtime/gc_base/ReferenceChainWalker.hpp +++ b/runtime/gc_base/ReferenceChainWalker.hpp @@ -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);