Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-09-24 00:52:09 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2018-10-04 16:32:30 +0300
commit92fa0fcdb76e2b6cb0040eede97fe3c167c31897 (patch)
tree5016ac6cbf7e5873421788387a5b2e011c31ac56 /src/node_file.h
parentc0c58d5660aeea93c492877894f66dd55771be2e (diff)
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>
Diffstat (limited to 'src/node_file.h')
-rw-r--r--src/node_file.h29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/node_file.h b/src/node_file.h
index af62be0feca..31242e1a1b1 100644
--- a/src/node_file.h
+++ b/src/node_file.h
@@ -53,10 +53,12 @@ class FSContinuationData : public MemoryRetainer {
}
void MemoryInfo(MemoryTracker* tracker) const override {
- tracker->TrackThis(this);
tracker->TrackField("paths", paths);
}
+ SET_MEMORY_INFO_NAME(FSContinuationData)
+ SET_SELF_SIZE(FSContinuationData)
+
private:
uv_fs_cb done_cb;
};
@@ -136,11 +138,11 @@ class FSReqCallback : public FSReqBase {
void SetReturnValue(const FunctionCallbackInfo<Value>& args) override;
void MemoryInfo(MemoryTracker* tracker) const override {
- tracker->TrackThis(this);
tracker->TrackField("continuation_data", continuation_data);
}
- ADD_MEMORY_INFO_NAME(FSReqCallback)
+ SET_MEMORY_INFO_NAME(FSReqCallback)
+ SET_SELF_SIZE(FSReqCallback)
private:
DISALLOW_COPY_AND_ASSIGN(FSReqCallback);
@@ -201,12 +203,12 @@ class FSReqPromise : public FSReqBase {
}
void MemoryInfo(MemoryTracker* tracker) const override {
- tracker->TrackThis(this);
tracker->TrackField("stats_field_array", stats_field_array_);
tracker->TrackField("continuation_data", continuation_data);
}
- ADD_MEMORY_INFO_NAME(FSReqPromise)
+ SET_MEMORY_INFO_NAME(FSReqPromise)
+ SET_SELF_SIZE(FSReqPromise)
private:
bool finished_ = false;
@@ -242,12 +244,9 @@ class FileHandleReadWrap : public ReqWrap<uv_fs_t> {
return static_cast<FileHandleReadWrap*>(ReqWrap::from_req(req));
}
- void MemoryInfo(MemoryTracker* tracker) const override {
- tracker->TrackThis(this);
- tracker->TrackField("buffer", buffer_);
- }
-
- ADD_MEMORY_INFO_NAME(FileHandleReadWrap)
+ void MemoryInfo(MemoryTracker* tracker) const override;
+ SET_MEMORY_INFO_NAME(FileHandleReadWrap)
+ SET_SELF_SIZE(FileHandleReadWrap)
private:
FileHandle* file_handle_;
@@ -296,11 +295,11 @@ class FileHandle : public AsyncWrap, public StreamBase {
}
void MemoryInfo(MemoryTracker* tracker) const override {
- tracker->TrackThis(this);
tracker->TrackField("current_read", current_read_);
}
- ADD_MEMORY_INFO_NAME(FileHandle)
+ SET_MEMORY_INFO_NAME(FileHandle)
+ SET_SELF_SIZE(FileHandle)
private:
// Synchronous close that emits a warning
@@ -329,12 +328,12 @@ class FileHandle : public AsyncWrap, public StreamBase {
FileHandle* file_handle();
void MemoryInfo(MemoryTracker* tracker) const override {
- tracker->TrackThis(this);
tracker->TrackField("promise", promise_);
tracker->TrackField("ref", ref_);
}
- ADD_MEMORY_INFO_NAME(CloseReq)
+ SET_MEMORY_INFO_NAME(CloseReq)
+ SET_SELF_SIZE(CloseReq)
void Resolve();