diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-09-24 00:52:09 +0300 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-10-04 16:32:30 +0300 |
commit | 92fa0fcdb76e2b6cb0040eede97fe3c167c31897 (patch) | |
tree | 5016ac6cbf7e5873421788387a5b2e011c31ac56 /src/node_crypto.h | |
parent | c0c58d5660aeea93c492877894f66dd55771be2e (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_crypto.h')
-rw-r--r-- | src/node_crypto.h | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/src/node_crypto.h b/src/node_crypto.h index 714afd0d3bb..acb61885f28 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -107,11 +107,10 @@ class SecureContext : public BaseObject { static void Initialize(Environment* env, v8::Local<v8::Object> target); - void MemoryInfo(MemoryTracker* tracker) const override { - tracker->TrackThis(this); - } - - ADD_MEMORY_INFO_NAME(SecureContext) + // TODO(joyeecheung): track the memory used by OpenSSL types + SET_NO_MEMORY_INFO() + SET_MEMORY_INFO_NAME(SecureContext) + SET_SELF_SIZE(SecureContext) SSLCtxPointer ctx_; X509Pointer cert_; @@ -347,11 +346,10 @@ class CipherBase : public BaseObject { public: static void Initialize(Environment* env, v8::Local<v8::Object> target); - void MemoryInfo(MemoryTracker* tracker) const override { - tracker->TrackThis(this); - } - - ADD_MEMORY_INFO_NAME(CipherBase) + // TODO(joyeecheung): track the memory used by OpenSSL types + SET_NO_MEMORY_INFO() + SET_MEMORY_INFO_NAME(CipherBase) + SET_SELF_SIZE(CipherBase) protected: enum CipherKind { @@ -436,11 +434,10 @@ class Hmac : public BaseObject { public: static void Initialize(Environment* env, v8::Local<v8::Object> target); - void MemoryInfo(MemoryTracker* tracker) const override { - tracker->TrackThis(this); - } - - ADD_MEMORY_INFO_NAME(Hmac) + // TODO(joyeecheung): track the memory used by OpenSSL types + SET_NO_MEMORY_INFO() + SET_MEMORY_INFO_NAME(Hmac) + SET_SELF_SIZE(Hmac) protected: void HmacInit(const char* hash_type, const char* key, int key_len); @@ -465,11 +462,10 @@ class Hash : public BaseObject { public: static void Initialize(Environment* env, v8::Local<v8::Object> target); - void MemoryInfo(MemoryTracker* tracker) const override { - tracker->TrackThis(this); - } - - ADD_MEMORY_INFO_NAME(Hash) + // TODO(joyeecheung): track the memory used by OpenSSL types + SET_NO_MEMORY_INFO() + SET_MEMORY_INFO_NAME(Hash) + SET_SELF_SIZE(Hash) bool HashInit(const char* hash_type); bool HashUpdate(const char* data, int len); @@ -510,11 +506,10 @@ class SignBase : public BaseObject { Error Init(const char* sign_type); Error Update(const char* data, int len); - void MemoryInfo(MemoryTracker* tracker) const override { - tracker->TrackThis(this); - } - - ADD_MEMORY_INFO_NAME(SignBase) + // TODO(joyeecheung): track the memory used by OpenSSL types + SET_NO_MEMORY_INFO() + SET_MEMORY_INFO_NAME(SignBase) + SET_SELF_SIZE(SignBase) protected: void CheckThrow(Error error); @@ -628,11 +623,10 @@ class DiffieHellman : public BaseObject { MakeWeak(); } - void MemoryInfo(MemoryTracker* tracker) const override { - tracker->TrackThis(this); - } - - ADD_MEMORY_INFO_NAME(DiffieHellman) + // TODO(joyeecheung): track the memory used by OpenSSL types + SET_NO_MEMORY_INFO() + SET_MEMORY_INFO_NAME(DiffieHellman) + SET_SELF_SIZE(DiffieHellman) private: static void GetField(const v8::FunctionCallbackInfo<v8::Value>& args, @@ -659,11 +653,10 @@ class ECDH : public BaseObject { char* data, size_t len); - void MemoryInfo(MemoryTracker* tracker) const override { - tracker->TrackThis(this); - } - - ADD_MEMORY_INFO_NAME(ECDH) + // TODO(joyeecheung): track the memory used by OpenSSL types + SET_NO_MEMORY_INFO() + SET_MEMORY_INFO_NAME(ECDH) + SET_SELF_SIZE(ECDH) protected: ECDH(Environment* env, v8::Local<v8::Object> wrap, ECKeyPointer&& key) |