diff --git a/src/memory_tracker-inl.h b/src/memory_tracker-inl.h index 65bcbccdc02aa4..95d623c2b459f8 100644 --- a/src/memory_tracker-inl.h +++ b/src/memory_tracker-inl.h @@ -241,6 +241,13 @@ void MemoryTracker::Track(const MemoryRetainer* retainer, PopNode(); } +void MemoryTracker::TrackInlineField(const MemoryRetainer* retainer, + const char* edge_name) { + Track(retainer, edge_name); + CHECK(CurrentNode()); + CurrentNode()->size_ -= retainer->SelfSize(); +} + MemoryRetainerNode* MemoryTracker::CurrentNode() const { if (node_stack_.empty()) return nullptr; return node_stack_.top(); diff --git a/src/memory_tracker.h b/src/memory_tracker.h index 11dd2be7af35c9..673cd811c3ea03 100644 --- a/src/memory_tracker.h +++ b/src/memory_tracker.h @@ -197,6 +197,17 @@ class MemoryTracker { inline void Track(const MemoryRetainer* retainer, const char* edge_name = nullptr); + // Useful for parents that do not wish to perform manual + // adjustments to its `SelfSize()` when embedding retainer + // objects inline. + // Put a memory container into the graph, create an edge from + // the current node if there is one on the stack - there should + // be one, of the container object which the current field is part of. + // Reduce the size of memory from the container so as to avoid + // duplication in accounting. + inline void TrackInlineField(const MemoryRetainer* retainer, + const char* edge_name = nullptr); + inline v8::EmbedderGraph* graph() { return graph_; } inline v8::Isolate* isolate() { return isolate_; }