/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
staticbool LessThan(const NodeAndRetainedSize& aLhs, const NodeAndRetainedSize& aRhs) { // Use > because we want to sort from greatest to least retained size. return aLhs.mSize > aRhs.mSize;
}
};
};
JS::ubi::Node::Id id(aNodeId);
Maybe<JS::ubi::Node> node = mHeapSnapshot->getNodeById(id); if (node.isNothing()) return;
// Get all immediately dominated nodes and their retained sizes.
MallocSizeOf mallocSizeOf = GetCurrentThreadDebuggerMallocSizeOf();
Maybe<JS::ubi::DominatorTree::DominatedSetRange> range =
mDominatorTree.getDominatedSet(*node);
MOZ_ASSERT(
range.isSome(), "The node should be known, since we got it from the heap snapshot.");
size_t length = range->length();
nsTArray<NodeAndRetainedSize> dominatedNodes(length); for (const JS::ubi::Node& dominatedNode : *range) {
JS::ubi::Node::Size retainedSize = 0; if (NS_WARN_IF(!mDominatorTree.getRetainedSize(dominatedNode, mallocSizeOf,
retainedSize))) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY); return;
}
MOZ_ASSERT(retainedSize != 0, "retainedSize should not be zero since we know the node is in " "the dominator tree.");
// Sort them by retained size.
NodeAndRetainedSize::Comparator comparator;
dominatedNodes.Sort(comparator);
// Fill the result with the nodes' ids.
JS::ubi::Node root = mDominatorTree.root();
aOutResult.SetValue(nsTArray<uint64_t>(length)); for (const NodeAndRetainedSize& entry : dominatedNodes) { // The root dominates itself, but we don't want to expose that to JS. if (entry.mNode == root) continue;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.