mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
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>
58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
#ifndef SRC_JS_STREAM_H_
|
|
#define SRC_JS_STREAM_H_
|
|
|
|
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
|
|
#include "async_wrap.h"
|
|
#include "env.h"
|
|
#include "stream_base.h"
|
|
#include "v8.h"
|
|
|
|
namespace node {
|
|
|
|
class JSStream : public AsyncWrap, public StreamBase {
|
|
public:
|
|
static void Initialize(v8::Local<v8::Object> target,
|
|
v8::Local<v8::Value> unused,
|
|
v8::Local<v8::Context> context);
|
|
|
|
bool IsAlive() override;
|
|
bool IsClosing() override;
|
|
int ReadStart() override;
|
|
int ReadStop() override;
|
|
|
|
int DoShutdown(ShutdownWrap* req_wrap) override;
|
|
int DoWrite(WriteWrap* w,
|
|
uv_buf_t* bufs,
|
|
size_t count,
|
|
uv_stream_t* send_handle) override;
|
|
|
|
SET_NO_MEMORY_INFO()
|
|
SET_MEMORY_INFO_NAME(JSStream)
|
|
SET_SELF_SIZE(JSStream)
|
|
|
|
protected:
|
|
JSStream(Environment* env, v8::Local<v8::Object> obj);
|
|
|
|
AsyncWrap* GetAsyncWrap() override;
|
|
|
|
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
static void ReadBuffer(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
static void EmitEOF(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void OnAllocImpl(size_t size, uv_buf_t* buf, void* ctx);
|
|
static void OnReadImpl(ssize_t nread,
|
|
const uv_buf_t* buf,
|
|
uv_handle_type pending,
|
|
void* ctx);
|
|
|
|
template <class Wrap>
|
|
static void Finish(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
};
|
|
|
|
} // namespace node
|
|
|
|
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
|
|
#endif // SRC_JS_STREAM_H_
|