From 80b5c914bbd95345cc5085de4c3d240f02b14755 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sun, 22 Jul 2018 09:12:19 +0800 Subject: [PATCH] src: add proper MemoryInfoName to wrappers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use camel case names for memory retainers inherited from AsyncWrap instead of their provider names (which are all in upper case) - Assign class names to wraps so that they appear in the heap snapshot as nodes with class names as node names. Previously some nodes are named with reference names, which are supposed to be edge names instead. PR-URL: https://github.com/nodejs/node/pull/21939 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Gus Caplan Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- src/async_wrap.h | 2 +- src/base_object.h | 5 ++++ src/cares_wrap.cc | 33 ++++++++++++++++++++++- src/connect_wrap.h | 2 ++ src/fs_event_wrap.cc | 2 ++ src/inspector_js_api.cc | 2 ++ src/js_stream.h | 2 ++ src/module_wrap.h | 2 ++ src/node_contextify.cc | 2 ++ src/node_crypto.h | 14 ++++++++++ src/node_crypto_bio.h | 2 ++ src/node_file.h | 10 +++++++ src/node_http2.h | 8 ++++++ src/node_http_parser.cc | 1 + src/node_i18n.cc | 2 ++ src/node_messaging.h | 6 +++++ src/node_serdes.cc | 4 +++ src/node_stat_watcher.h | 2 ++ src/node_trace_events.cc | 2 ++ src/node_worker.h | 3 +++ src/node_zlib.cc | 3 +++ src/pipe_wrap.h | 2 ++ src/process_wrap.cc | 2 ++ src/sharedarraybuffer_metadata.cc | 2 ++ src/signal_wrap.cc | 2 ++ src/stream_base.h | 5 ++++ src/stream_pipe.h | 2 ++ src/tcp_wrap.h | 11 ++++++++ src/tls_wrap.h | 2 ++ src/tty_wrap.h | 2 ++ src/udp_wrap.cc | 2 ++ src/udp_wrap.h | 2 ++ test/parallel/test-heapdump-dns.js | 9 ++++--- test/parallel/test-heapdump-fs-promise.js | 4 +-- test/parallel/test-heapdump-http2.js | 22 +++++++++------ test/parallel/test-heapdump-inspector.js | 4 +-- test/parallel/test-heapdump-tls.js | 9 ++++--- test/parallel/test-heapdump-worker.js | 10 +++---- test/parallel/test-heapdump-zlib.js | 4 +-- 39 files changed, 176 insertions(+), 29 deletions(-) diff --git a/src/async_wrap.h b/src/async_wrap.h index e61837af61c242..4a483aaea5127f 100644 --- a/src/async_wrap.h +++ b/src/async_wrap.h @@ -175,7 +175,7 @@ class AsyncWrap : public BaseObject { v8::Local* argv); virtual std::string diagnostic_name() const; - std::string MemoryInfoName() const override; + virtual std::string MemoryInfoName() const; static void WeakCallback(const v8::WeakCallbackInfo &info); diff --git a/src/base_object.h b/src/base_object.h index e0f3f27950e7d0..64a237143386f2 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -33,6 +33,11 @@ namespace node { class Environment; +#define ADD_MEMORY_INFO_NAME(name) \ + std::string MemoryInfoName() const override { \ + return #name; \ + } + class BaseObject : public MemoryRetainer { public: // Associates this object with `object`. It uses the 0th internal field for diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 604213a2c65934..53d7a724426ae9 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -127,6 +127,7 @@ struct node_ares_task : public MemoryRetainer { uv_poll_t poll_watcher; void MemoryInfo(MemoryTracker* tracker) const override; + ADD_MEMORY_INFO_NAME(node_ares_task) }; struct TaskHash { @@ -173,9 +174,11 @@ class ChannelWrap : public AsyncWrap { tracker->TrackThis(this); if (timer_handle_ != nullptr) tracker->TrackFieldWithSize("timer handle", sizeof(*timer_handle_)); - tracker->TrackField("task list", task_list_); + tracker->TrackField("node_ares_task_list", task_list_); } + ADD_MEMORY_INFO_NAME(ChannelWrap) + static void AresTimeout(uv_timer_t* handle); private: @@ -225,6 +228,8 @@ class GetAddrInfoReqWrap : public ReqWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(GetAddrInfoReqWrap) + bool verbatim() const { return verbatim_; } private: @@ -246,6 +251,8 @@ class GetNameInfoReqWrap : public ReqWrap { void MemoryInfo(MemoryTracker* tracker) const override { tracker->TrackThis(this); } + + ADD_MEMORY_INFO_NAME(GetNameInfoReqWrap) }; GetNameInfoReqWrap::GetNameInfoReqWrap(Environment* env, @@ -1178,6 +1185,8 @@ class QueryAnyWrap: public QueryWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(QueryAnyWrap) + protected: void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); @@ -1357,6 +1366,8 @@ class QueryAWrap: public QueryWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(QueryAWrap) + protected: void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); @@ -1403,6 +1414,8 @@ class QueryAaaaWrap: public QueryWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(QueryAaaaWrap) + protected: void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); @@ -1449,6 +1462,8 @@ class QueryCnameWrap: public QueryWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(QueryCnameWrap) + protected: void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); @@ -1482,6 +1497,8 @@ class QueryMxWrap: public QueryWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(QueryMxWrap) + protected: void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); @@ -1515,6 +1532,8 @@ class QueryNsWrap: public QueryWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(QueryNsWrap) + protected: void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); @@ -1548,6 +1567,8 @@ class QueryTxtWrap: public QueryWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(QueryTxtWrap) + protected: void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); @@ -1580,6 +1601,8 @@ class QuerySrvWrap: public QueryWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(QuerySrvWrap) + protected: void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); @@ -1611,6 +1634,8 @@ class QueryPtrWrap: public QueryWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(QueryPtrWrap) + protected: void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); @@ -1644,6 +1669,8 @@ class QueryNaptrWrap: public QueryWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(QueryNaptrWrap) + protected: void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); @@ -1676,6 +1703,8 @@ class QuerySoaWrap: public QueryWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(QuerySoaWrap) + protected: void Parse(unsigned char* buf, int len) override { HandleScope handle_scope(env()->isolate()); @@ -1757,6 +1786,8 @@ class GetHostByAddrWrap: public QueryWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(GetHostByAddrWrap) + protected: void Parse(struct hostent* host) override { HandleScope handle_scope(env()->isolate()); diff --git a/src/connect_wrap.h b/src/connect_wrap.h index 587e4c6b0593e5..2370157eaa2a11 100644 --- a/src/connect_wrap.h +++ b/src/connect_wrap.h @@ -19,6 +19,8 @@ class ConnectWrap : public ReqWrap { void MemoryInfo(MemoryTracker* tracker) const override { tracker->TrackThis(this); } + + ADD_MEMORY_INFO_NAME(ConnectWrap) }; } // namespace node diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index 7587ace8e3ce70..e0cdab4d3e20f1 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -61,6 +61,8 @@ class FSEventWrap: public HandleWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(FSEventWrap) + private: static const encoding kDefaultEncoding = UTF8; diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index a8e2e8ecafeefe..4e95598d3a0580 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -109,6 +109,8 @@ class JSBindingsConnection : public AsyncWrap { tracker->TrackFieldWithSize("session", sizeof(*session_)); } + ADD_MEMORY_INFO_NAME(JSBindingsConnection) + private: std::unique_ptr session_; Persistent callback_; diff --git a/src/js_stream.h b/src/js_stream.h index f3406ae83ee560..05fb688f2f4115 100644 --- a/src/js_stream.h +++ b/src/js_stream.h @@ -31,6 +31,8 @@ class JSStream : public AsyncWrap, public StreamBase { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(JSStream) + protected: JSStream(Environment* env, v8::Local obj); diff --git a/src/module_wrap.h b/src/module_wrap.h index 2d6f5c49d88988..3e19b6c9eb3ebe 100644 --- a/src/module_wrap.h +++ b/src/module_wrap.h @@ -39,6 +39,8 @@ class ModuleWrap : public BaseObject { tracker->TrackField("resolve_cache", resolve_cache_); } + ADD_MEMORY_INFO_NAME(ModuleWrap) + private: ModuleWrap(Environment* env, v8::Local object, diff --git a/src/node_contextify.cc b/src/node_contextify.cc index b6ef5a37b2c47d..a36b99e1a970f7 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -591,6 +591,8 @@ class ContextifyScript : public BaseObject { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(ContextifyScript) + public: static void Init(Environment* env, Local target) { HandleScope scope(env->isolate()); diff --git a/src/node_crypto.h b/src/node_crypto.h index 7df2660c779760..ee069c9cf799b2 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -109,6 +109,8 @@ class SecureContext : public BaseObject { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(SecureContext) + SSLCtxPointer ctx_; X509Pointer cert_; X509Pointer issuer_; @@ -345,6 +347,8 @@ class CipherBase : public BaseObject { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(CipherBase) + protected: enum CipherKind { kCipher, @@ -419,6 +423,8 @@ class Hmac : public BaseObject { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(Hmac) + protected: void HmacInit(const char* hash_type, const char* key, int key_len); bool HmacUpdate(const char* data, int len); @@ -446,6 +452,8 @@ class Hash : public BaseObject { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(Hash) + bool HashInit(const char* hash_type); bool HashUpdate(const char* data, int len); @@ -489,6 +497,8 @@ class SignBase : public BaseObject { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(SignBase) + protected: void CheckThrow(Error error); @@ -605,6 +615,8 @@ class DiffieHellman : public BaseObject { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(DiffieHellman) + private: static void GetField(const v8::FunctionCallbackInfo& args, const BIGNUM* (*get_field)(const DH*), @@ -634,6 +646,8 @@ class ECDH : public BaseObject { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(ECDH) + protected: ECDH(Environment* env, v8::Local wrap, ECKeyPointer&& key) : BaseObject(env, wrap), diff --git a/src/node_crypto_bio.h b/src/node_crypto_bio.h index dea010fa0158b4..b4aa85f8fa36fa 100644 --- a/src/node_crypto_bio.h +++ b/src/node_crypto_bio.h @@ -115,6 +115,8 @@ class NodeBIO : public MemoryRetainer { tracker->TrackFieldWithSize("buffer", length_); } + ADD_MEMORY_INFO_NAME(NodeBIO) + private: static int New(BIO* bio); static int Free(BIO* bio); diff --git a/src/node_file.h b/src/node_file.h index 141d1d42d744a2..73202d9c4464b9 100644 --- a/src/node_file.h +++ b/src/node_file.h @@ -99,6 +99,8 @@ class FSReqWrap : public FSReqBase { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(FSReqWrap) + private: DISALLOW_COPY_AND_ASSIGN(FSReqWrap); }; @@ -162,6 +164,8 @@ class FSReqPromise : public FSReqBase { tracker->TrackField("stats_field_array", stats_field_array_); } + ADD_MEMORY_INFO_NAME(FSReqPromise) + private: bool finished_ = false; AliasedBuffer stats_field_array_; @@ -201,6 +205,8 @@ class FileHandleReadWrap : public ReqWrap { tracker->TrackField("buffer", buffer_); } + ADD_MEMORY_INFO_NAME(FileHandleReadWrap) + private: FileHandle* file_handle_; uv_buf_t buffer_; @@ -252,6 +258,8 @@ class FileHandle : public AsyncWrap, public StreamBase { tracker->TrackField("current_read", current_read_); } + ADD_MEMORY_INFO_NAME(FileHandle) + private: // Synchronous close that emits a warning void Close(); @@ -284,6 +292,8 @@ class FileHandle : public AsyncWrap, public StreamBase { tracker->TrackField("ref", ref_); } + ADD_MEMORY_INFO_NAME(CloseReq) + void Resolve(); void Reject(Local reason); diff --git a/src/node_http2.h b/src/node_http2.h index a30ee581751bb5..d7f8d9acae91cb 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -575,6 +575,8 @@ class Http2Stream : public AsyncWrap, tracker->TrackField("queue", queue_); } + ADD_MEMORY_INFO_NAME(Http2Stream) + std::string diagnostic_name() const override; // JavaScript API @@ -761,6 +763,8 @@ class Http2Session : public AsyncWrap, public StreamListener { pending_rst_streams_.size() * sizeof(int32_t)); } + ADD_MEMORY_INFO_NAME(Http2Session) + std::string diagnostic_name() const override; // Schedule an RstStream for after the current write finishes. @@ -1081,6 +1085,8 @@ class Http2Session::Http2Ping : public AsyncWrap { tracker->TrackField("session", session_); } + ADD_MEMORY_INFO_NAME(Http2Ping) + void Send(uint8_t* payload); void Done(bool ack, const uint8_t* payload = nullptr); @@ -1104,6 +1110,8 @@ class Http2Session::Http2Settings : public AsyncWrap { tracker->TrackField("session", session_); } + ADD_MEMORY_INFO_NAME(Http2Settings) + void Send(); void Done(bool ack); diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index e8fc1f22e4938a..318ad0b8e6bf73 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -160,6 +160,7 @@ class Parser : public AsyncWrap, public StreamListener { tracker->TrackField("current_buffer", current_buffer_); } + ADD_MEMORY_INFO_NAME(Parser) int on_message_begin() { num_fields_ = num_values_ = 0; diff --git a/src/node_i18n.cc b/src/node_i18n.cc index 288ad77f619188..45871f3d3ed43a 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -254,6 +254,8 @@ class ConverterObject : public BaseObject, Converter { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(ConverterObject) + protected: ConverterObject(Environment* env, v8::Local wrap, diff --git a/src/node_messaging.h b/src/node_messaging.h index da10300aedbd42..b7fd392ccc6fab 100644 --- a/src/node_messaging.h +++ b/src/node_messaging.h @@ -57,6 +57,8 @@ class Message : public MemoryRetainer { void MemoryInfo(MemoryTracker* tracker) const override; + ADD_MEMORY_INFO_NAME(Message) + private: MallocedBuffer main_message_buf_; std::vector> array_buffer_contents_; @@ -98,6 +100,8 @@ class MessagePortData : public MemoryRetainer { void MemoryInfo(MemoryTracker* tracker) const override; + ADD_MEMORY_INFO_NAME(MessagePortData) + private: // After disentangling this message port, the owner handle (if any) // is asynchronously triggered, so that it can close down naturally. @@ -187,6 +191,8 @@ class MessagePort : public HandleWrap { tracker->TrackField("data", data_); } + ADD_MEMORY_INFO_NAME(MessagePort) + private: void OnClose() override; void OnMessage(); diff --git a/src/node_serdes.cc b/src/node_serdes.cc index 4b2cc60b3f7584..5de0ddd81909b0 100644 --- a/src/node_serdes.cc +++ b/src/node_serdes.cc @@ -57,6 +57,8 @@ class SerializerContext : public BaseObject, tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(SerializerContext) + private: ValueSerializer serializer_; }; @@ -86,6 +88,8 @@ class DeserializerContext : public BaseObject, tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(DeserializerContext) + private: const uint8_t* data_; const size_t length_; diff --git a/src/node_stat_watcher.h b/src/node_stat_watcher.h index baf6bdc14ee317..33c90ad3cde737 100644 --- a/src/node_stat_watcher.h +++ b/src/node_stat_watcher.h @@ -48,6 +48,8 @@ class StatWatcher : public HandleWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(StatWatcher) + private: static void Callback(uv_fs_poll_t* handle, int status, diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc index a2f42249483cd7..684ea41a66cc58 100644 --- a/src/node_trace_events.cc +++ b/src/node_trace_events.cc @@ -32,6 +32,8 @@ class NodeCategorySet : public BaseObject { tracker->TrackField("categories", categories_); } + ADD_MEMORY_INFO_NAME(NodeCategorySet) + private: NodeCategorySet(Environment* env, Local wrap, diff --git a/src/node_worker.h b/src/node_worker.h index bd737d4800fd79..33df36e04ce670 100644 --- a/src/node_worker.h +++ b/src/node_worker.h @@ -33,6 +33,9 @@ class Worker : public AsyncWrap { tracker->TrackField("parent_port", parent_port_); } + + ADD_MEMORY_INFO_NAME(Worker) + bool is_stopped() const; static void New(const v8::FunctionCallbackInfo& args); diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 031666e19ad29c..774d319249ce63 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -653,6 +653,9 @@ class ZCtx : public AsyncWrap, public ThreadPoolWork { zlib_memory_ + unreported_allocations_); } + + ADD_MEMORY_INFO_NAME(ZCtx) + private: void Ref() { if (++refs_ == 1) { diff --git a/src/pipe_wrap.h b/src/pipe_wrap.h index 9ed4f153ae5c4c..7faf5145abdcfe 100644 --- a/src/pipe_wrap.h +++ b/src/pipe_wrap.h @@ -49,6 +49,8 @@ class PipeWrap : public ConnectionWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(PipeWrap) + private: PipeWrap(Environment* env, v8::Local object, diff --git a/src/process_wrap.cc b/src/process_wrap.cc index b9a20c34a770ba..b54e17f21192d8 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -70,6 +70,8 @@ class ProcessWrap : public HandleWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(ProcessWrap) + private: static void New(const FunctionCallbackInfo& args) { // This constructor should not be exposed to public javascript. diff --git a/src/sharedarraybuffer_metadata.cc b/src/sharedarraybuffer_metadata.cc index 95fed87c8d4ea0..3d5b96051ead6e 100644 --- a/src/sharedarraybuffer_metadata.cc +++ b/src/sharedarraybuffer_metadata.cc @@ -51,6 +51,8 @@ class SABLifetimePartner : public BaseObject { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(SABLifetimePartner) + SharedArrayBufferMetadataReference reference; }; diff --git a/src/signal_wrap.cc b/src/signal_wrap.cc index 5568d22e4c6228..463a8a50d5e772 100644 --- a/src/signal_wrap.cc +++ b/src/signal_wrap.cc @@ -64,6 +64,8 @@ class SignalWrap : public HandleWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(SignalWrap) + private: static void New(const FunctionCallbackInfo& args) { // This constructor should not be exposed to public javascript. diff --git a/src/stream_base.h b/src/stream_base.h index bbb20e52e1a8de..05c2a9623625d6 100644 --- a/src/stream_base.h +++ b/src/stream_base.h @@ -350,6 +350,8 @@ class SimpleShutdownWrap : public ShutdownWrap, public OtherBase { void MemoryInfo(MemoryTracker* tracker) const override { tracker->TrackThis(this); } + + ADD_MEMORY_INFO_NAME(SimpleShutdownWrap) }; template @@ -364,6 +366,9 @@ class SimpleWriteWrap : public WriteWrap, public OtherBase { tracker->TrackThis(this); tracker->TrackFieldWithSize("storage", StorageSize()); } + + + ADD_MEMORY_INFO_NAME(SimpleWriteWrap) }; } // namespace node diff --git a/src/stream_pipe.h b/src/stream_pipe.h index 36a0b1dc08106b..c76afac41689a6 100644 --- a/src/stream_pipe.h +++ b/src/stream_pipe.h @@ -22,6 +22,8 @@ class StreamPipe : public AsyncWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(StreamPipe) + private: inline StreamBase* source(); inline StreamBase* sink(); diff --git a/src/tcp_wrap.h b/src/tcp_wrap.h index d6ca9306099e37..829c1b22bf3aec 100644 --- a/src/tcp_wrap.h +++ b/src/tcp_wrap.h @@ -48,6 +48,17 @@ class TCPWrap : public ConnectionWrap { tracker->TrackThis(this); } + std::string MemoryInfoName() const override { + switch (provider_type()) { + case ProviderType::PROVIDER_TCPWRAP: + return "TCPSocketWrap"; + case ProviderType::PROVIDER_TCPSERVERWRAP: + return "TCPServerWrap"; + default: + UNREACHABLE(); + } + } + private: typedef uv_tcp_t HandleType; diff --git a/src/tls_wrap.h b/src/tls_wrap.h index 5f4fd3f7073305..aea8568b11b51c 100644 --- a/src/tls_wrap.h +++ b/src/tls_wrap.h @@ -78,6 +78,8 @@ class TLSWrap : public AsyncWrap, void MemoryInfo(MemoryTracker* tracker) const override; + ADD_MEMORY_INFO_NAME(TLSWrap) + protected: inline StreamBase* underlying_stream() { return static_cast(stream_); diff --git a/src/tty_wrap.h b/src/tty_wrap.h index cca5650ddb3964..45357cfa4637cf 100644 --- a/src/tty_wrap.h +++ b/src/tty_wrap.h @@ -42,6 +42,8 @@ class TTYWrap : public LibuvStreamWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(TTYWrap) + private: TTYWrap(Environment* env, v8::Local object, diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index e5243319a553e7..2ef5c61358744a 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -60,6 +60,8 @@ class SendWrap : public ReqWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(SendWrap) + private: const bool have_callback_; }; diff --git a/src/udp_wrap.h b/src/udp_wrap.h index 3792bcc459da23..ca048f5aef98af 100644 --- a/src/udp_wrap.h +++ b/src/udp_wrap.h @@ -68,6 +68,8 @@ class UDPWrap: public HandleWrap { tracker->TrackThis(this); } + ADD_MEMORY_INFO_NAME(UDPWrap) + private: typedef uv_udp_t HandleType; diff --git a/test/parallel/test-heapdump-dns.js b/test/parallel/test-heapdump-dns.js index 011503f5874d5a..00ca54917f5df5 100644 --- a/test/parallel/test-heapdump-dns.js +++ b/test/parallel/test-heapdump-dns.js @@ -3,14 +3,15 @@ require('../common'); const { validateSnapshotNodes } = require('../common/heap'); -validateSnapshotNodes('DNSCHANNEL', []); +validateSnapshotNodes('ChannelWrap', []); const dns = require('dns'); -validateSnapshotNodes('DNSCHANNEL', [{}]); +validateSnapshotNodes('ChannelWrap', [{}]); dns.resolve('localhost', () => {}); -validateSnapshotNodes('DNSCHANNEL', [ +validateSnapshotNodes('ChannelWrap', [ { children: [ - { name: 'task list' }, + { name: 'node_ares_task_list' }, + // `Node / ChannelWrap` (C++) -> `ChannelWrap` (JS) { name: 'ChannelWrap' } ] } diff --git a/test/parallel/test-heapdump-fs-promise.js b/test/parallel/test-heapdump-fs-promise.js index be44b3d8731bc1..855b135f6ae31b 100644 --- a/test/parallel/test-heapdump-fs-promise.js +++ b/test/parallel/test-heapdump-fs-promise.js @@ -4,9 +4,9 @@ require('../common'); const { validateSnapshotNodes } = require('../common/heap'); const fs = require('fs').promises; -validateSnapshotNodes('FSREQPROMISE', []); +validateSnapshotNodes('FSReqPromise', []); fs.stat(__filename); -validateSnapshotNodes('FSREQPROMISE', [ +validateSnapshotNodes('FSReqPromise', [ { children: [ { name: 'FSReqPromise' }, diff --git a/test/parallel/test-heapdump-http2.js b/test/parallel/test-heapdump-http2.js index 19a70d8c44b15d..cbc1209ab0557f 100644 --- a/test/parallel/test-heapdump-http2.js +++ b/test/parallel/test-heapdump-http2.js @@ -8,8 +8,8 @@ if (!common.hasCrypto) { const state = recordState(); - state.validateSnapshotNodes('HTTP2SESSION', []); - state.validateSnapshotNodes('HTTP2STREAM', []); + state.validateSnapshotNodes('Http2Session', []); + state.validateSnapshotNodes('Http2Stream', []); } const server = http2.createServer(); @@ -22,42 +22,48 @@ server.listen(0, () => { req.on('response', common.mustCall(() => { const state = recordState(); - state.validateSnapshotNodes('HTTP2STREAM', [ + + // `Node / Http2Stream` (C++) -> Http2Stream (JS) + state.validateSnapshotNodes('Http2Stream', [ { children: [ { name: 'Http2Stream' } ] }, ], { loose: true }); - state.validateSnapshotNodes('FILEHANDLE', [ + + // `Node / FileHandle` (C++) -> FileHandle (JS) + state.validateSnapshotNodes('FileHandle', [ { children: [ { name: 'FileHandle' } ] } ]); - state.validateSnapshotNodes('TCPWRAP', [ + state.validateSnapshotNodes('TCPSocketWrap', [ { children: [ { name: 'TCP' } ] } ], { loose: true }); - state.validateSnapshotNodes('TCPSERVERWRAP', [ + state.validateSnapshotNodes('TCPServerWrap', [ { children: [ { name: 'TCP' } ] } ], { loose: true }); - state.validateSnapshotNodes('STREAMPIPE', [ + // `Node / StreamPipe` (C++) -> StreamPipe (JS) + state.validateSnapshotNodes('StreamPipe', [ { children: [ { name: 'StreamPipe' } ] } ]); - state.validateSnapshotNodes('HTTP2SESSION', [ + // `Node / Http2Session` (C++) -> Http2Session (JS) + state.validateSnapshotNodes('Http2Session', [ { children: [ { name: 'Http2Session' }, diff --git a/test/parallel/test-heapdump-inspector.js b/test/parallel/test-heapdump-inspector.js index 355b8d0d0a1d51..08fc6703d87c5c 100644 --- a/test/parallel/test-heapdump-inspector.js +++ b/test/parallel/test-heapdump-inspector.js @@ -8,9 +8,9 @@ const { validateSnapshotNodes } = require('../common/heap'); const inspector = require('inspector'); const session = new inspector.Session(); -validateSnapshotNodes('INSPECTORJSBINDING', []); +validateSnapshotNodes('JSBindingsConnection', []); session.connect(); -validateSnapshotNodes('INSPECTORJSBINDING', [ +validateSnapshotNodes('JSBindingsConnection', [ { children: [ { name: 'session' }, diff --git a/test/parallel/test-heapdump-tls.js b/test/parallel/test-heapdump-tls.js index be14b7b5f7ca64..90b2d8dc952f56 100644 --- a/test/parallel/test-heapdump-tls.js +++ b/test/parallel/test-heapdump-tls.js @@ -9,7 +9,7 @@ const { validateSnapshotNodes } = require('../common/heap'); const net = require('net'); const tls = require('tls'); -validateSnapshotNodes('TLSWRAP', []); +validateSnapshotNodes('TLSWrap', []); const server = net.createServer(common.mustCall((c) => { c.end(); @@ -21,11 +21,12 @@ const server = net.createServer(common.mustCall((c) => { })); c.write('hello'); - validateSnapshotNodes('TLSWRAP', [ + validateSnapshotNodes('TLSWrap', [ { children: [ - { name: 'enc_out' }, - { name: 'enc_in' }, + { name: 'NodeBIO' }, + { name: 'NodeBIO' }, + // `Node / TLSWrap` (C++) -> `TLSWrap` (JS) { name: 'TLSWrap' } ] } diff --git a/test/parallel/test-heapdump-worker.js b/test/parallel/test-heapdump-worker.js index 68d2ccd1abbc29..b7b5c2f756717c 100644 --- a/test/parallel/test-heapdump-worker.js +++ b/test/parallel/test-heapdump-worker.js @@ -4,22 +4,22 @@ require('../common'); const { validateSnapshotNodes } = require('../common/heap'); const { Worker } = require('worker_threads'); -validateSnapshotNodes('WORKER', []); +validateSnapshotNodes('Worker', []); const worker = new Worker('setInterval(() => {}, 100);', { eval: true }); -validateSnapshotNodes('WORKER', [ +validateSnapshotNodes('Worker', [ { children: [ { name: 'thread_exit_async' }, { name: 'env' }, - { name: 'MESSAGEPORT' }, + { name: 'MessagePort' }, { name: 'Worker' } ] } ]); -validateSnapshotNodes('MESSAGEPORT', [ +validateSnapshotNodes('MessagePort', [ { children: [ - { name: 'data' }, + { name: 'MessagePortData' }, { name: 'MessagePort' } ] } diff --git a/test/parallel/test-heapdump-zlib.js b/test/parallel/test-heapdump-zlib.js index 7a749902f5aaf6..936e3a1a500b2d 100644 --- a/test/parallel/test-heapdump-zlib.js +++ b/test/parallel/test-heapdump-zlib.js @@ -4,10 +4,10 @@ require('../common'); const { validateSnapshotNodes } = require('../common/heap'); const zlib = require('zlib'); -validateSnapshotNodes('ZLIB', []); +validateSnapshotNodes('ZCtx', []); // eslint-disable-next-line no-unused-vars const gunzip = zlib.createGunzip(); -validateSnapshotNodes('ZLIB', [ +validateSnapshotNodes('ZCtx', [ { children: [ { name: 'Zlib' },