Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: add proper MemoryInfoName to wrappers #21939

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/async_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class AsyncWrap : public BaseObject {
v8::Local<v8::Value>* argv);

virtual std::string diagnostic_name() const;
std::string MemoryInfoName() const override;
virtual std::string MemoryInfoName() const;

static void WeakCallback(const v8::WeakCallbackInfo<DestroyParam> &info);

Expand Down
5 changes: 5 additions & 0 deletions src/base_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 32 additions & 1 deletion src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -225,6 +228,8 @@ class GetAddrInfoReqWrap : public ReqWrap<uv_getaddrinfo_t> {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(GetAddrInfoReqWrap)

bool verbatim() const { return verbatim_; }

private:
Expand All @@ -246,6 +251,8 @@ class GetNameInfoReqWrap : public ReqWrap<uv_getnameinfo_t> {
void MemoryInfo(MemoryTracker* tracker) const override {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(GetNameInfoReqWrap)
};

GetNameInfoReqWrap::GetNameInfoReqWrap(Environment* env,
Expand Down Expand Up @@ -1193,6 +1200,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());
Expand Down Expand Up @@ -1372,6 +1381,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());
Expand Down Expand Up @@ -1418,6 +1429,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());
Expand Down Expand Up @@ -1464,6 +1477,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());
Expand Down Expand Up @@ -1497,6 +1512,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());
Expand Down Expand Up @@ -1530,6 +1547,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());
Expand Down Expand Up @@ -1563,6 +1582,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());
Expand Down Expand Up @@ -1595,6 +1616,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());
Expand Down Expand Up @@ -1626,6 +1649,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());
Expand Down Expand Up @@ -1659,6 +1684,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());
Expand Down Expand Up @@ -1691,6 +1718,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());
Expand Down Expand Up @@ -1772,6 +1801,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());
Expand Down
2 changes: 2 additions & 0 deletions src/connect_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class ConnectWrap : public ReqWrap<uv_connect_t> {
void MemoryInfo(MemoryTracker* tracker) const override {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(ConnectWrap)
};

} // namespace node
Expand Down
2 changes: 2 additions & 0 deletions src/fs_event_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class FSEventWrap: public HandleWrap {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(FSEventWrap)

private:
static const encoding kDefaultEncoding = UTF8;

Expand Down
2 changes: 2 additions & 0 deletions src/inspector_js_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class JSBindingsConnection : public AsyncWrap {
tracker->TrackFieldWithSize("session", sizeof(*session_));
}

ADD_MEMORY_INFO_NAME(JSBindingsConnection)

private:
std::unique_ptr<InspectorSession> session_;
Persistent<Function> callback_;
Expand Down
2 changes: 2 additions & 0 deletions src/js_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class JSStream : public AsyncWrap, public StreamBase {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(JSStream)

protected:
JSStream(Environment* env, v8::Local<v8::Object> obj);

Expand Down
2 changes: 2 additions & 0 deletions src/module_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<v8::Object> object,
Expand Down
2 changes: 2 additions & 0 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ class ContextifyScript : public BaseObject {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(ContextifyScript)

public:
static void Init(Environment* env, Local<Object> target) {
HandleScope scope(env->isolate());
Expand Down
14 changes: 14 additions & 0 deletions src/node_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class SecureContext : public BaseObject {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(SecureContext)

SSLCtxPointer ctx_;
X509Pointer cert_;
X509Pointer issuer_;
Expand Down Expand Up @@ -345,6 +347,8 @@ class CipherBase : public BaseObject {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(CipherBase)

protected:
enum CipherKind {
kCipher,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -489,6 +497,8 @@ class SignBase : public BaseObject {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(SignBase)

protected:
void CheckThrow(Error error);

Expand Down Expand Up @@ -605,6 +615,8 @@ class DiffieHellman : public BaseObject {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(DiffieHellman)

private:
static void GetField(const v8::FunctionCallbackInfo<v8::Value>& args,
const BIGNUM* (*get_field)(const DH*),
Expand Down Expand Up @@ -634,6 +646,8 @@ class ECDH : public BaseObject {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(ECDH)

protected:
ECDH(Environment* env, v8::Local<v8::Object> wrap, ECKeyPointer&& key)
: BaseObject(env, wrap),
Expand Down
2 changes: 2 additions & 0 deletions src/node_crypto_bio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/node_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class FSReqWrap : public FSReqBase {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(FSReqWrap)

private:
DISALLOW_COPY_AND_ASSIGN(FSReqWrap);
};
Expand Down Expand Up @@ -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<NativeT, V8T> stats_field_array_;
Expand Down Expand Up @@ -201,6 +205,8 @@ class FileHandleReadWrap : public ReqWrap<uv_fs_t> {
tracker->TrackField("buffer", buffer_);
}

ADD_MEMORY_INFO_NAME(FileHandleReadWrap)

private:
FileHandle* file_handle_;
uv_buf_t buffer_;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -284,6 +292,8 @@ class FileHandle : public AsyncWrap, public StreamBase {
tracker->TrackField("ref", ref_);
}

ADD_MEMORY_INFO_NAME(CloseReq)

void Resolve();

void Reject(Local<Value> reason);
Expand Down
8 changes: 8 additions & 0 deletions src/node_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);

Expand All @@ -1104,6 +1110,8 @@ class Http2Session::Http2Settings : public AsyncWrap {
tracker->TrackField("session", session_);
}

ADD_MEMORY_INFO_NAME(Http2Settings)

void Send();
void Done(bool ack);

Expand Down
1 change: 1 addition & 0 deletions src/node_http_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/node_i18n.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ class ConverterObject : public BaseObject, Converter {
tracker->TrackThis(this);
}

ADD_MEMORY_INFO_NAME(ConverterObject)

protected:
ConverterObject(Environment* env,
v8::Local<v8::Object> wrap,
Expand Down
Loading