jvmtiError RetainedSizeByObjectsAction::tagHeap()

in src/sizes/retained_size_by_objects.cpp [69:89]


jvmtiError RetainedSizeByObjectsAction::tagHeap(const std::vector<jobject> &objects) {
    jvmtiError err = FollowReferences(0, nullptr, nullptr, getTagsWithNewInfo, nullptr, "find objects with new info");
    if (!isOk(err)) return err;
    if (shouldStopExecution()) return MEMORY_AGENT_INTERRUPTED_ERROR;

    std::vector<jobject> taggedObjects;
    logger::debug("collect objects with new info");
    err = getObjectsByTags(jvmti, std::vector<jlong>{pointerToTag(&Tag::TagWithNewInfo)}, taggedObjects);
    if (!isOk(err)) return err;
    if (shouldStopExecution()) return MEMORY_AGENT_INTERRUPTED_ERROR;

    err = retagStartObjects(objects);
    if (!isOk(err)) return err;
    if (shouldStopExecution()) return MEMORY_AGENT_INTERRUPTED_ERROR;

    err = FollowReferences(0, nullptr, nullptr, visitReference, nullptr, "tag heap");
    if (!isOk(err)) return err;
    if (shouldStopExecution()) return MEMORY_AGENT_INTERRUPTED_ERROR;

    return walkHeapFromObjects(jvmti, taggedObjects, *dynamic_cast<CancellationChecker *>(this));
}