src: name EmbededderGraph edges and use class names for nodes

This patch:

- Refactors the `MemoryRetainer` API so that the impementer no longer
  calls `TrackThis()` that sets the size of node on the top of the
  stack, which may be hard to understand. Instead now they implements
  `SelfSize()` to provide their self sizes. Also documents
  the API in the header.
- Refactors `MemoryTracker` so it calls `MemoryInfoName()` and
  `SelfSize()` of `MemoryRetainer` to retrieve info about them, and
  separate `node_names` and `edge_names` so the edges can be properly
  named with reference names and the nodes can be named with class
  names. (Previously the nodes are named with reference names while the
  edges are all indexed and appear as array elements).
- Adds `SET_MEMORY_INFO_NAME()`, `SET_SELF_SIZE()` and
  `SET_NO_MEMORY_INFO()` convenience macros
- Fixes a few `MemoryInfo` calls in some `MemoryRetainers` to track
  their references properly.
- Refactors the heapdump tests to check both node names and edge names,
  distinguishing between wrapped JS nodes (without prefixes)
  and embedder wrappers (prefixed with `Node / `).

PR-URL: https://github.com/nodejs/node/pull/23072
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Joyee Cheung committed 2018-10-04 15:32:30 +02:00
1 parent c0c58d5660
commit 92fa0fcdb7
50 files changed
+717 -507

No files matched your search

+3 -5
View File
@@ -47,11 +47,9 @@ class SABLifetimePartner : public BaseObject {
MakeWeak();
}
void MemoryInfo(MemoryTracker* tracker) const override {
tracker->TrackThis(this);
}
ADD_MEMORY_INFO_NAME(SABLifetimePartner)
SET_NO_MEMORY_INFO()
SET_MEMORY_INFO_NAME(SABLifetimePartner)
SET_SELF_SIZE(SABLifetimePartner)
SharedArrayBufferMetadataReference reference;
};