/* -*- 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/. */
// `Deserialized{Node,Edge}` translate protobuf messages from our core dump // format into structures we can rely upon for implementing `JS::ubi::Node` // specializations on top of. All of the properties of the protobuf messages are // optional for future compatibility, and this is the layer where we validate // that the properties that do actually exist in any given message fulfill our // semantic requirements. // // Both `DeserializedNode` and `DeserializedEdge` are always owned by a // `HeapSnapshot` instance, and their lifetimes must not extend after that of // their owning `HeapSnapshot`.
namespace mozilla { namespace devtools {
class HeapSnapshot;
using NodeId = uint64_t; using StackFrameId = uint64_t;
// A `DeserializedEdge` represents an edge in the heap graph pointing to the // node with id equal to `DeserializedEdge::referent` that we deserialized from // a core dump. struct DeserializedEdge {
NodeId referent; // A borrowed reference to a string owned by this node's owning HeapSnapshot. const char16_t* name;
// A `DeserializedNode` is a node in the heap graph that we deserialized from a // core dump. struct DeserializedNode { using EdgeVector = Vector<DeserializedEdge>; using UniqueStringPtr = UniquePtr<char16_t[]>;
NodeId id;
JS::ubi::CoarseType coarseType; // A borrowed reference to a string owned by this node's owning HeapSnapshot. const char16_t* typeName;
uint64_t size;
EdgeVector edges;
Maybe<StackFrameId> allocationStack; // A borrowed reference to a string owned by this node's owning HeapSnapshot. constchar* jsObjectClassName; // A borrowed reference to a string owned by this node's owning HeapSnapshot. constchar* scriptFilename; // A borrowed reference to a string owned by this node's owning HeapSnapshot. const char16_t* descriptiveTypeName; // A weak pointer to this node's owning `HeapSnapshot`. Safe without // AddRef'ing because this node's lifetime is equal to that of its owner.
HeapSnapshot* owner;
// Get a borrowed reference to the given edge's referent. This method is // virtual to provide a hook for gmock and gtest. virtual JS::ubi::Node getEdgeReferent(const DeserializedEdge& edge);
struct HashPolicy;
protected: // This is only for use with `MockDeserializedNode` in testing.
DeserializedNode(NodeId id, const char16_t* typeName, uint64_t size)
: id(id),
coarseType(JS::ubi::CoarseType::Other), typeName(typeName),
size(size),
edges(),
allocationStack(Nothing()),
jsObjectClassName(nullptr),
scriptFilename(nullptr),
descriptiveTypeName(nullptr),
owner(nullptr) {}
// A `DeserializedStackFrame` is a stack frame referred to by a thing in the // heap graph that we deserialized from a core dump. struct DeserializedStackFrame {
StackFrameId id;
Maybe<StackFrameId> parent;
uint32_t line;
JS::TaggedColumnNumberOneOrigin column; // Borrowed references to strings owned by this DeserializedStackFrame's // owning HeapSnapshot. const char16_t* source; const char16_t* functionDisplayName; bool isSystem; bool isSelfHosted; // A weak pointer to this frame's owning `HeapSnapshot`. Safe without // AddRef'ing because this frame's lifetime is equal to that of its owner.
HeapSnapshot* owner;
protected: // This is exposed only for MockDeserializedStackFrame in the gtests. explicit DeserializedStackFrame()
: id(0),
parent(Nothing()),
line(0),
source(nullptr),
functionDisplayName(nullptr),
isSystem(false),
isSelfHosted(false),
owner(nullptr) {};
};
struct DeserializedStackFrame::HashPolicy { using Lookup = StackFrameId;
// We ignore the `bool wantNames` parameter because we can't control whether // the core dump was serialized with edge names or not.
js::UniquePtr<EdgeRange> edges(JSContext* cx, bool) const override;
staticconst char16_t concreteTypeName[];
};
template <> class ConcreteStackFrame<DeserializedStackFrame> : public BaseStackFrame { protected: explicit ConcreteStackFrame(DeserializedStackFrame* ptr)
: BaseStackFrame(ptr) {}
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.