@encharm/cws 4.3.0 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -7
- package/dist/bindings/cws_darwin_arm64_node108.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node83.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node93.node +0 -0
- package/dist/bindings/cws_darwin_x64_node108.node +0 -0
- package/dist/bindings/cws_darwin_x64_node115.node +0 -0
- package/dist/bindings/cws_darwin_x64_node83.node +0 -0
- package/dist/bindings/cws_darwin_x64_node93.node +0 -0
- package/dist/bindings/cws_linux_arm64_node108.node +0 -0
- package/dist/bindings/cws_linux_arm64_node115.node +0 -0
- package/dist/bindings/cws_linux_arm64_node83.node +0 -0
- package/dist/bindings/cws_linux_arm64_node93.node +0 -0
- package/dist/bindings/cws_linux_x64_node108.node +0 -0
- package/dist/bindings/cws_linux_x64_node115.node +0 -0
- package/dist/bindings/cws_linux_x64_node83.node +0 -0
- package/dist/bindings/cws_linux_x64_node93.node +0 -0
- package/dist/bindings/cws_win32_x64_node108.node +0 -0
- package/dist/bindings/cws_win32_x64_node115.node +0 -0
- package/dist/bindings/cws_win32_x64_node83.node +0 -0
- package/dist/bindings/cws_win32_x64_node93.node +0 -0
- package/dist/shared.js +1 -1
- package/package.json +5 -5
- package/src/Addon.cpp +4 -12
- package/src/Addon.h +67 -91
- package/src/Socket.h +1 -0
- package/src/cSNode.cpp +3 -8
- package/src/headers/20/acorn_version.h +6 -0
- package/src/headers/20/aliased_buffer-inl.h +243 -0
- package/src/headers/20/aliased_buffer.h +206 -0
- package/src/headers/20/aliased_struct-inl.h +54 -0
- package/src/headers/20/aliased_struct.h +63 -0
- package/src/headers/20/async_wrap-inl.h +93 -0
- package/src/headers/20/async_wrap.h +252 -0
- package/src/headers/20/base64-inl.h +193 -0
- package/src/headers/20/base64.h +53 -0
- package/src/headers/20/base64_version.h +6 -0
- package/src/headers/20/base_object-inl.h +316 -0
- package/src/headers/20/base_object.h +320 -0
- package/src/headers/20/base_object_types.h +73 -0
- package/src/headers/20/blob_serializer_deserializer-inl.h +361 -0
- package/src/headers/20/blob_serializer_deserializer.h +132 -0
- package/src/headers/20/callback_queue-inl.h +97 -0
- package/src/headers/20/callback_queue.h +79 -0
- package/src/headers/20/cares_wrap.h +524 -0
- package/src/headers/20/cjs_module_lexer_version.h +6 -0
- package/src/headers/20/cleanup_queue-inl.h +62 -0
- package/src/headers/20/cleanup_queue.h +85 -0
- package/src/headers/20/connect_wrap.h +26 -0
- package/src/headers/20/connection_wrap.h +30 -0
- package/src/headers/20/cppgc/DEPS +8 -0
- package/src/headers/20/cppgc/OWNERS +2 -0
- package/src/headers/20/cppgc/README.md +135 -0
- package/src/headers/20/cppgc/allocation.h +310 -0
- package/src/headers/20/cppgc/common.h +28 -0
- package/src/headers/20/cppgc/cross-thread-persistent.h +466 -0
- package/src/headers/20/cppgc/custom-space.h +97 -0
- package/src/headers/20/cppgc/default-platform.h +67 -0
- package/src/headers/20/cppgc/ephemeron-pair.h +30 -0
- package/src/headers/20/cppgc/explicit-management.h +100 -0
- package/src/headers/20/cppgc/garbage-collected.h +106 -0
- package/src/headers/20/cppgc/heap-consistency.h +309 -0
- package/src/headers/20/cppgc/heap-handle.h +48 -0
- package/src/headers/20/cppgc/heap-state.h +82 -0
- package/src/headers/20/cppgc/heap-statistics.h +120 -0
- package/src/headers/20/cppgc/heap.h +202 -0
- package/src/headers/20/cppgc/internal/api-constants.h +68 -0
- package/src/headers/20/cppgc/internal/atomic-entry-flag.h +48 -0
- package/src/headers/20/cppgc/internal/base-page-handle.h +45 -0
- package/src/headers/20/cppgc/internal/caged-heap-local-data.h +111 -0
- package/src/headers/20/cppgc/internal/caged-heap.h +61 -0
- package/src/headers/20/cppgc/internal/compiler-specific.h +38 -0
- package/src/headers/20/cppgc/internal/finalizer-trait.h +93 -0
- package/src/headers/20/cppgc/internal/gc-info.h +157 -0
- package/src/headers/20/cppgc/internal/logging.h +50 -0
- package/src/headers/20/cppgc/internal/member-storage.h +248 -0
- package/src/headers/20/cppgc/internal/name-trait.h +137 -0
- package/src/headers/20/cppgc/internal/persistent-node.h +214 -0
- package/src/headers/20/cppgc/internal/pointer-policies.h +243 -0
- package/src/headers/20/cppgc/internal/write-barrier.h +487 -0
- package/src/headers/20/cppgc/liveness-broker.h +78 -0
- package/src/headers/20/cppgc/macros.h +35 -0
- package/src/headers/20/cppgc/member.h +604 -0
- package/src/headers/20/cppgc/name-provider.h +65 -0
- package/src/headers/20/cppgc/object-size-trait.h +58 -0
- package/src/headers/20/cppgc/persistent.h +373 -0
- package/src/headers/20/cppgc/platform.h +158 -0
- package/src/headers/20/cppgc/prefinalizer.h +75 -0
- package/src/headers/20/cppgc/process-heap-statistics.h +36 -0
- package/src/headers/20/cppgc/sentinel-pointer.h +32 -0
- package/src/headers/20/cppgc/source-location.h +92 -0
- package/src/headers/20/cppgc/testing.h +106 -0
- package/src/headers/20/cppgc/trace-trait.h +120 -0
- package/src/headers/20/cppgc/type-traits.h +250 -0
- package/src/headers/20/cppgc/visitor.h +426 -0
- package/src/headers/20/crypto/crypto_clienthello.h +131 -0
- package/src/headers/20/crypto/crypto_context.h +160 -0
- package/src/headers/20/crypto/crypto_keys.h +419 -0
- package/src/headers/20/crypto/crypto_tls.h +304 -0
- package/src/headers/20/crypto/crypto_util.h +806 -0
- package/src/headers/20/crypto_clienthello.h +131 -0
- package/src/headers/20/debug_utils-inl.h +226 -0
- package/src/headers/20/debug_utils.h +188 -0
- package/src/headers/20/diagnosticfilename-inl.h +33 -0
- package/src/headers/20/encoding_binding.h +59 -0
- package/src/headers/20/env-inl.h +923 -0
- package/src/headers/20/env.h +1193 -0
- package/src/headers/20/env_properties.h +446 -0
- package/src/headers/20/handle_wrap.h +123 -0
- package/src/headers/20/histogram-inl.h +107 -0
- package/src/headers/20/histogram.h +240 -0
- package/src/headers/20/inspector_agent.h +144 -0
- package/src/headers/20/inspector_io.h +78 -0
- package/src/headers/20/inspector_profiler.h +149 -0
- package/src/headers/20/inspector_socket.h +60 -0
- package/src/headers/20/inspector_socket_server.h +110 -0
- package/src/headers/20/js_native_api.h +601 -0
- package/src/headers/20/js_native_api_types.h +168 -0
- package/src/headers/20/js_native_api_v8.h +463 -0
- package/src/headers/20/js_native_api_v8_internals.h +45 -0
- package/src/headers/20/js_stream.h +52 -0
- package/src/headers/20/json_parser.h +38 -0
- package/src/headers/20/json_utils.h +172 -0
- package/src/headers/20/memory_tracker-inl.h +356 -0
- package/src/headers/20/memory_tracker.h +289 -0
- package/src/headers/20/module_wrap.h +117 -0
- package/src/headers/20/node.h +1516 -0
- package/src/headers/20/node_api.h +261 -0
- package/src/headers/20/node_api_internals.h +42 -0
- package/src/headers/20/node_api_types.h +52 -0
- package/src/headers/20/node_binding.h +142 -0
- package/src/headers/20/node_blob.h +159 -0
- package/src/headers/20/node_bob-inl.h +36 -0
- package/src/headers/20/node_bob.h +107 -0
- package/src/headers/20/node_buffer.h +92 -0
- package/src/headers/20/node_builtins.h +197 -0
- package/src/headers/20/node_constants.h +82 -0
- package/src/headers/20/node_context_data.h +98 -0
- package/src/headers/20/node_contextify.h +206 -0
- package/src/headers/20/node_crypto.h +56 -0
- package/src/headers/20/node_dir.h +52 -0
- package/src/headers/20/node_dotenv.h +37 -0
- package/src/headers/20/node_errors.h +313 -0
- package/src/headers/20/node_exit_code.h +54 -0
- package/src/headers/20/node_external_reference.h +172 -0
- package/src/headers/20/node_file-inl.h +389 -0
- package/src/headers/20/node_file.h +537 -0
- package/src/headers/20/node_http2.h +1146 -0
- package/src/headers/20/node_http2_state.h +147 -0
- package/src/headers/20/node_http_common-inl.h +201 -0
- package/src/headers/20/node_http_common.h +532 -0
- package/src/headers/20/node_i18n.h +145 -0
- package/src/headers/20/node_internals.h +443 -0
- package/src/headers/20/node_main_instance.h +67 -0
- package/src/headers/20/node_mem-inl.h +112 -0
- package/src/headers/20/node_mem.h +45 -0
- package/src/headers/20/node_messaging.h +377 -0
- package/src/headers/20/node_metadata.h +138 -0
- package/src/headers/20/node_mutex.h +323 -0
- package/src/headers/20/node_object_wrap.h +132 -0
- package/src/headers/20/node_options-inl.h +478 -0
- package/src/headers/20/node_options.h +538 -0
- package/src/headers/20/node_perf.h +166 -0
- package/src/headers/20/node_perf_common.h +98 -0
- package/src/headers/20/node_platform.h +195 -0
- package/src/headers/20/node_process-inl.h +26 -0
- package/src/headers/20/node_process.h +99 -0
- package/src/headers/20/node_realm-inl.h +139 -0
- package/src/headers/20/node_realm.h +184 -0
- package/src/headers/20/node_report.h +42 -0
- package/src/headers/20/node_revert.h +82 -0
- package/src/headers/20/node_root_certs.h +3443 -0
- package/src/headers/20/node_sea.h +56 -0
- package/src/headers/20/node_shadow_realm.h +46 -0
- package/src/headers/20/node_snapshot_builder.h +54 -0
- package/src/headers/20/node_snapshotable.h +164 -0
- package/src/headers/20/node_sockaddr-inl.h +266 -0
- package/src/headers/20/node_sockaddr.h +405 -0
- package/src/headers/20/node_stat_watcher.h +73 -0
- package/src/headers/20/node_threadsafe_cow-inl.h +54 -0
- package/src/headers/20/node_threadsafe_cow.h +105 -0
- package/src/headers/20/node_union_bytes.h +81 -0
- package/src/headers/20/node_url.h +92 -0
- package/src/headers/20/node_v8.h +77 -0
- package/src/headers/20/node_v8_platform-inl.h +205 -0
- package/src/headers/20/node_version.h +109 -0
- package/src/headers/20/node_wasi.h +184 -0
- package/src/headers/20/node_wasm_web_api.h +55 -0
- package/src/headers/20/node_watchdog.h +154 -0
- package/src/headers/20/node_worker.h +151 -0
- package/src/headers/20/permission/child_process_permission.h +29 -0
- package/src/headers/20/permission/fs_permission.h +154 -0
- package/src/headers/20/permission/inspector_permission.h +29 -0
- package/src/headers/20/permission/permission.h +74 -0
- package/src/headers/20/permission/permission_base.h +53 -0
- package/src/headers/20/permission/worker_permission.h +29 -0
- package/src/headers/20/pipe_wrap.h +80 -0
- package/src/headers/20/req_wrap-inl.h +171 -0
- package/src/headers/20/req_wrap.h +77 -0
- package/src/headers/20/spawn_sync.h +242 -0
- package/src/headers/20/stream_base-inl.h +173 -0
- package/src/headers/20/stream_base.h +469 -0
- package/src/headers/20/stream_pipe.h +76 -0
- package/src/headers/20/stream_wrap.h +131 -0
- package/src/headers/20/string_bytes.h +120 -0
- package/src/headers/20/string_decoder-inl.h +37 -0
- package/src/headers/20/string_decoder.h +50 -0
- package/src/headers/20/string_search.h +638 -0
- package/src/headers/20/tcp_wrap.h +105 -0
- package/src/headers/20/threadpoolwork-inl.h +70 -0
- package/src/headers/20/timer_wrap-inl.h +32 -0
- package/src/headers/20/timer_wrap.h +85 -0
- package/src/headers/20/timers.h +70 -0
- package/src/headers/20/tracing/agent.h +195 -0
- package/src/headers/20/tracing/node_trace_buffer.h +83 -0
- package/src/headers/20/tracing/node_trace_writer.h +75 -0
- package/src/headers/20/tracing/trace_event.h +720 -0
- package/src/headers/20/tracing/trace_event_common.h +1109 -0
- package/src/headers/20/tracing/traced_value.h +70 -0
- package/src/headers/20/tty_wrap.h +65 -0
- package/src/headers/20/udp_wrap.h +227 -0
- package/src/headers/20/undici_version.h +6 -0
- package/src/headers/20/util-inl.h +623 -0
- package/src/headers/20/util.h +988 -0
- package/src/headers/20/v8-cppgc.h +245 -0
- package/src/headers/20/v8-fast-api-calls.h +957 -0
- package/dist/bindings/cws_darwin_arm64_node64.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node72.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node79.node +0 -0
- package/dist/bindings/cws_darwin_x64_node64.node +0 -0
- package/dist/bindings/cws_darwin_x64_node72.node +0 -0
- package/dist/bindings/cws_darwin_x64_node79.node +0 -0
- package/dist/bindings/cws_linux_x64_node64.node +0 -0
- package/dist/bindings/cws_linux_x64_node72.node +0 -0
- package/dist/bindings/cws_linux_x64_node79.node +0 -0
- package/dist/bindings/cws_win32_x64_node64.node +0 -0
- package/dist/bindings/cws_win32_x64_node72.node +0 -0
- package/dist/bindings/cws_win32_x64_node79.node +0 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
4
|
+
|
|
5
|
+
#include "v8-profiler.h"
|
|
6
|
+
|
|
7
|
+
#include <uv.h>
|
|
8
|
+
|
|
9
|
+
#include <limits>
|
|
10
|
+
#include <queue>
|
|
11
|
+
#include <stack>
|
|
12
|
+
#include <string>
|
|
13
|
+
#include <unordered_map>
|
|
14
|
+
|
|
15
|
+
namespace v8 {
|
|
16
|
+
class BackingStore;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
namespace node {
|
|
20
|
+
|
|
21
|
+
template <typename T>
|
|
22
|
+
struct MallocedBuffer;
|
|
23
|
+
|
|
24
|
+
// Set the node name of a MemoryRetainer to klass
|
|
25
|
+
#define SET_MEMORY_INFO_NAME(Klass) \
|
|
26
|
+
inline const char* MemoryInfoName() const override { return #Klass; }
|
|
27
|
+
|
|
28
|
+
// Set the self size of a MemoryRetainer to the stack-allocated size of a
|
|
29
|
+
// certain class
|
|
30
|
+
#define SET_SELF_SIZE(Klass) \
|
|
31
|
+
inline size_t SelfSize() const override { return sizeof(Klass); }
|
|
32
|
+
|
|
33
|
+
// Used when there is no additional fields to track
|
|
34
|
+
#define SET_NO_MEMORY_INFO() \
|
|
35
|
+
inline void MemoryInfo(node::MemoryTracker* tracker) const override {}
|
|
36
|
+
|
|
37
|
+
class MemoryTracker;
|
|
38
|
+
class MemoryRetainerNode;
|
|
39
|
+
template <typename T, bool kIsWeak>
|
|
40
|
+
class BaseObjectPtrImpl;
|
|
41
|
+
|
|
42
|
+
namespace crypto {
|
|
43
|
+
class NodeBIO;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
class CleanupHookCallback;
|
|
47
|
+
|
|
48
|
+
/* Example:
|
|
49
|
+
*
|
|
50
|
+
* class ExampleRetainer : public MemoryRetainer {
|
|
51
|
+
* public:
|
|
52
|
+
* // Or use SET_NO_MEMORY_INFO() when there is no additional fields
|
|
53
|
+
* // to track.
|
|
54
|
+
* void MemoryInfo(MemoryTracker* tracker) const override {
|
|
55
|
+
* // Node name and size comes from the MemoryInfoName and SelfSize of
|
|
56
|
+
* // AnotherRetainerClass
|
|
57
|
+
* tracker->TrackField("another_retainer", another_retainer_);
|
|
58
|
+
*
|
|
59
|
+
* // Add non_pointer_retainer as a separate node into the graph
|
|
60
|
+
* // and track its memory information recursively.
|
|
61
|
+
* // Note that we need to make sure its size is not accounted in
|
|
62
|
+
* // ExampleRetainer::SelfSize().
|
|
63
|
+
* tracker->TrackField("non_pointer_retainer", &non_pointer_retainer_);
|
|
64
|
+
*
|
|
65
|
+
* // Specify node name and size explicitly
|
|
66
|
+
* tracker->TrackFieldWithSize("internal_member",
|
|
67
|
+
* internal_member_.size(),
|
|
68
|
+
* "InternalClass");
|
|
69
|
+
* // Node name falls back to the edge name,
|
|
70
|
+
* // elements in the container appear as grandchildren nodes
|
|
71
|
+
* tracker->TrackField("vector", vector_);
|
|
72
|
+
* // Node name and size come from the JS object
|
|
73
|
+
* tracker->TrackField("target", target_);
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* // Or use SET_MEMORY_INFO_NAME(ExampleRetainer)
|
|
77
|
+
* const char* MemoryInfoName() const override {
|
|
78
|
+
* return "ExampleRetainer";
|
|
79
|
+
* }
|
|
80
|
+
*
|
|
81
|
+
* // Classes that only want to return its sizeof() value can use the
|
|
82
|
+
* // SET_SELF_SIZE(Class) macro instead.
|
|
83
|
+
* size_t SelfSize() const override {
|
|
84
|
+
* // We need to exclude the size of non_pointer_retainer so that
|
|
85
|
+
* // we can track it separately in ExampleRetainer::MemoryInfo().
|
|
86
|
+
* return sizeof(ExampleRetainer) - sizeof(NonPointerRetainerClass);
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* // Note: no need to implement these two methods when implementing
|
|
90
|
+
* // a BaseObject or an AsyncWrap class
|
|
91
|
+
* bool IsRootNode() const override { return !wrapped_.IsWeak(); }
|
|
92
|
+
* v8::Local<v8::Object> WrappedObject() const override {
|
|
93
|
+
* return node::PersistentToLocal::Default(wrapped_);
|
|
94
|
+
* }
|
|
95
|
+
*
|
|
96
|
+
* private:
|
|
97
|
+
* AnotherRetainerClass* another_retainer_;
|
|
98
|
+
* NonPointerRetainerClass non_pointer_retainer;
|
|
99
|
+
* InternalClass internal_member_;
|
|
100
|
+
* std::vector<uv_async_t> vector_;
|
|
101
|
+
* v8::Global<Object> target_;
|
|
102
|
+
*
|
|
103
|
+
* v8::Global<Object> wrapped_;
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* This creates the following graph:
|
|
107
|
+
* Node / ExampleRetainer
|
|
108
|
+
* |> another_retainer :: Node / AnotherRetainerClass
|
|
109
|
+
* |> internal_member :: Node / InternalClass
|
|
110
|
+
* |> vector :: Node / vector (elements will be grandchildren)
|
|
111
|
+
* |> [1] :: Node / uv_async_t (uv_async_t has predefined names)
|
|
112
|
+
* |> [2] :: Node / uv_async_t
|
|
113
|
+
* |> ...
|
|
114
|
+
* |> target :: TargetClass (JS class name of the target object)
|
|
115
|
+
* |> wrapped :: WrappedClass (JS class name of the wrapped object)
|
|
116
|
+
* |> wrapper :: Node / ExampleRetainer (back reference)
|
|
117
|
+
*/
|
|
118
|
+
class MemoryRetainer {
|
|
119
|
+
public:
|
|
120
|
+
virtual ~MemoryRetainer() = default;
|
|
121
|
+
|
|
122
|
+
// Subclasses should implement these methods to provide information
|
|
123
|
+
// for the V8 heap snapshot generator.
|
|
124
|
+
// The MemoryInfo() method is assumed to be called within a context
|
|
125
|
+
// where all the edges start from the node of the current retainer,
|
|
126
|
+
// and point to the nodes as specified by tracker->Track* calls.
|
|
127
|
+
virtual void MemoryInfo(MemoryTracker* tracker) const = 0;
|
|
128
|
+
virtual const char* MemoryInfoName() const = 0;
|
|
129
|
+
virtual size_t SelfSize() const = 0;
|
|
130
|
+
|
|
131
|
+
virtual v8::Local<v8::Object> WrappedObject() const {
|
|
132
|
+
return v8::Local<v8::Object>();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
virtual bool IsRootNode() const { return false; }
|
|
136
|
+
virtual v8::EmbedderGraph::Node::Detachedness GetDetachedness() const {
|
|
137
|
+
return v8::EmbedderGraph::Node::Detachedness::kUnknown;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
class MemoryTracker {
|
|
142
|
+
public:
|
|
143
|
+
// Used to specify node name and size explicitly
|
|
144
|
+
inline void TrackFieldWithSize(const char* edge_name,
|
|
145
|
+
size_t size,
|
|
146
|
+
const char* node_name = nullptr);
|
|
147
|
+
inline void TrackInlineFieldWithSize(const char* edge_name,
|
|
148
|
+
size_t size,
|
|
149
|
+
const char* node_name = nullptr);
|
|
150
|
+
|
|
151
|
+
// Shortcut to extract the underlying object out of the smart pointer
|
|
152
|
+
template <typename T, typename D>
|
|
153
|
+
inline void TrackField(const char* edge_name,
|
|
154
|
+
const std::unique_ptr<T, D>& value,
|
|
155
|
+
const char* node_name = nullptr);
|
|
156
|
+
|
|
157
|
+
template <typename T>
|
|
158
|
+
inline void TrackField(const char* edge_name,
|
|
159
|
+
const std::shared_ptr<T>& value,
|
|
160
|
+
const char* node_name = nullptr);
|
|
161
|
+
|
|
162
|
+
template <typename T, bool kIsWeak>
|
|
163
|
+
void TrackField(const char* edge_name,
|
|
164
|
+
const BaseObjectPtrImpl<T, kIsWeak>& value,
|
|
165
|
+
const char* node_name = nullptr);
|
|
166
|
+
|
|
167
|
+
// For containers, the elements will be graphed as grandchildren nodes
|
|
168
|
+
// if the container is not empty.
|
|
169
|
+
// By default, we assume the parent count the stack size of the container
|
|
170
|
+
// into its SelfSize so that will be subtracted from the parent size when we
|
|
171
|
+
// spin off a new node for the container.
|
|
172
|
+
// TODO(joyeecheung): use RTTI to retrieve the class name at runtime?
|
|
173
|
+
template <typename T, typename Iterator = typename T::const_iterator>
|
|
174
|
+
inline void TrackField(const char* edge_name,
|
|
175
|
+
const T& value,
|
|
176
|
+
const char* node_name = nullptr,
|
|
177
|
+
const char* element_name = nullptr,
|
|
178
|
+
bool subtract_from_self = true);
|
|
179
|
+
template <typename T>
|
|
180
|
+
inline void TrackField(const char* edge_name,
|
|
181
|
+
const std::queue<T>& value,
|
|
182
|
+
const char* node_name = nullptr,
|
|
183
|
+
const char* element_name = nullptr);
|
|
184
|
+
template <typename T, typename U>
|
|
185
|
+
inline void TrackField(const char* edge_name,
|
|
186
|
+
const std::pair<T, U>& value,
|
|
187
|
+
const char* node_name = nullptr);
|
|
188
|
+
|
|
189
|
+
// For the following types, node_name will be ignored and predefined names
|
|
190
|
+
// will be used instead. They are only in the signature for template
|
|
191
|
+
// expansion.
|
|
192
|
+
inline void TrackField(const char* edge_name,
|
|
193
|
+
const MemoryRetainer& value,
|
|
194
|
+
const char* node_name = nullptr);
|
|
195
|
+
inline void TrackField(const char* edge_name,
|
|
196
|
+
const MemoryRetainer* value,
|
|
197
|
+
const char* node_name = nullptr);
|
|
198
|
+
template <typename T>
|
|
199
|
+
inline void TrackField(const char* edge_name,
|
|
200
|
+
const std::basic_string<T>& value,
|
|
201
|
+
const char* node_name = nullptr);
|
|
202
|
+
template <typename T,
|
|
203
|
+
typename test_for_number = typename std::
|
|
204
|
+
enable_if<std::numeric_limits<T>::is_specialized, bool>::type,
|
|
205
|
+
typename dummy = bool>
|
|
206
|
+
inline void TrackField(const char* edge_name,
|
|
207
|
+
const T& value,
|
|
208
|
+
const char* node_name = nullptr);
|
|
209
|
+
template <typename T>
|
|
210
|
+
void TrackField(const char* edge_name,
|
|
211
|
+
const v8::Eternal<T>& value,
|
|
212
|
+
const char* node_name);
|
|
213
|
+
template <typename T>
|
|
214
|
+
inline void TrackField(const char* edge_name,
|
|
215
|
+
const v8::PersistentBase<T>& value,
|
|
216
|
+
const char* node_name = nullptr);
|
|
217
|
+
template <typename T>
|
|
218
|
+
inline void TrackField(const char* edge_name,
|
|
219
|
+
const v8::Local<T>& value,
|
|
220
|
+
const char* node_name = nullptr);
|
|
221
|
+
template <typename T>
|
|
222
|
+
inline void TrackField(const char* edge_name,
|
|
223
|
+
const MallocedBuffer<T>& value,
|
|
224
|
+
const char* node_name = nullptr);
|
|
225
|
+
inline void TrackField(const char* edge_name,
|
|
226
|
+
const v8::BackingStore* value,
|
|
227
|
+
const char* node_name = nullptr);
|
|
228
|
+
inline void TrackField(const char* edge_name,
|
|
229
|
+
const uv_buf_t& value,
|
|
230
|
+
const char* node_name = nullptr);
|
|
231
|
+
inline void TrackField(const char* edge_name,
|
|
232
|
+
const uv_timer_t& value,
|
|
233
|
+
const char* node_name = nullptr);
|
|
234
|
+
inline void TrackField(const char* edge_name,
|
|
235
|
+
const uv_async_t& value,
|
|
236
|
+
const char* node_name = nullptr);
|
|
237
|
+
inline void TrackInlineField(const char* edge_name,
|
|
238
|
+
const uv_async_t& value,
|
|
239
|
+
const char* node_name = nullptr);
|
|
240
|
+
|
|
241
|
+
// Put a memory container into the graph, create an edge from
|
|
242
|
+
// the current node if there is one on the stack.
|
|
243
|
+
inline void Track(const MemoryRetainer* retainer,
|
|
244
|
+
const char* edge_name = nullptr);
|
|
245
|
+
|
|
246
|
+
// Useful for parents that do not wish to perform manual
|
|
247
|
+
// adjustments to its `SelfSize()` when embedding retainer
|
|
248
|
+
// objects inline.
|
|
249
|
+
// Put a memory container into the graph, create an edge from
|
|
250
|
+
// the current node if there is one on the stack - there should
|
|
251
|
+
// be one, of the container object which the current field is part of.
|
|
252
|
+
// Reduce the size of memory from the container so as to avoid
|
|
253
|
+
// duplication in accounting.
|
|
254
|
+
inline void TrackInlineField(const MemoryRetainer* retainer,
|
|
255
|
+
const char* edge_name = nullptr);
|
|
256
|
+
|
|
257
|
+
inline v8::EmbedderGraph* graph() { return graph_; }
|
|
258
|
+
inline v8::Isolate* isolate() { return isolate_; }
|
|
259
|
+
|
|
260
|
+
inline explicit MemoryTracker(v8::Isolate* isolate,
|
|
261
|
+
v8::EmbedderGraph* graph)
|
|
262
|
+
: isolate_(isolate), graph_(graph) {}
|
|
263
|
+
|
|
264
|
+
private:
|
|
265
|
+
typedef std::unordered_map<const MemoryRetainer*, MemoryRetainerNode*>
|
|
266
|
+
NodeMap;
|
|
267
|
+
|
|
268
|
+
inline MemoryRetainerNode* CurrentNode() const;
|
|
269
|
+
inline MemoryRetainerNode* AddNode(const MemoryRetainer* retainer,
|
|
270
|
+
const char* edge_name = nullptr);
|
|
271
|
+
inline MemoryRetainerNode* PushNode(const MemoryRetainer* retainer,
|
|
272
|
+
const char* edge_name = nullptr);
|
|
273
|
+
inline MemoryRetainerNode* AddNode(const char* node_name,
|
|
274
|
+
size_t size,
|
|
275
|
+
const char* edge_name = nullptr);
|
|
276
|
+
inline MemoryRetainerNode* PushNode(const char* node_name,
|
|
277
|
+
size_t size,
|
|
278
|
+
const char* edge_name = nullptr);
|
|
279
|
+
inline void PopNode();
|
|
280
|
+
|
|
281
|
+
v8::Isolate* isolate_;
|
|
282
|
+
v8::EmbedderGraph* graph_;
|
|
283
|
+
std::stack<MemoryRetainerNode*> node_stack_;
|
|
284
|
+
NodeMap seen_;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
} // namespace node
|
|
288
|
+
|
|
289
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#ifndef SRC_MODULE_WRAP_H_
|
|
2
|
+
#define SRC_MODULE_WRAP_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include <unordered_map>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <vector>
|
|
9
|
+
#include "base_object.h"
|
|
10
|
+
|
|
11
|
+
namespace node {
|
|
12
|
+
|
|
13
|
+
class Environment;
|
|
14
|
+
class ExternalReferenceRegistry;
|
|
15
|
+
|
|
16
|
+
namespace contextify {
|
|
17
|
+
class ContextifyContext;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
namespace loader {
|
|
21
|
+
|
|
22
|
+
enum ScriptType : int {
|
|
23
|
+
kScript,
|
|
24
|
+
kModule,
|
|
25
|
+
kFunction,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
enum HostDefinedOptions : int {
|
|
29
|
+
kID = 8,
|
|
30
|
+
kLength = 9,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
class ModuleWrap : public BaseObject {
|
|
34
|
+
public:
|
|
35
|
+
enum InternalFields {
|
|
36
|
+
kModuleSlot = BaseObject::kInternalFieldCount,
|
|
37
|
+
kURLSlot,
|
|
38
|
+
kSyntheticEvaluationStepsSlot,
|
|
39
|
+
kContextObjectSlot, // Object whose creation context is the target Context
|
|
40
|
+
kInternalFieldCount
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
static void Initialize(v8::Local<v8::Object> target,
|
|
44
|
+
v8::Local<v8::Value> unused,
|
|
45
|
+
v8::Local<v8::Context> context,
|
|
46
|
+
void* priv);
|
|
47
|
+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
48
|
+
static void HostInitializeImportMetaObjectCallback(
|
|
49
|
+
v8::Local<v8::Context> context,
|
|
50
|
+
v8::Local<v8::Module> module,
|
|
51
|
+
v8::Local<v8::Object> meta);
|
|
52
|
+
|
|
53
|
+
void MemoryInfo(MemoryTracker* tracker) const override {
|
|
54
|
+
tracker->TrackField("resolve_cache", resolve_cache_);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
v8::Local<v8::Context> context() const;
|
|
58
|
+
|
|
59
|
+
SET_MEMORY_INFO_NAME(ModuleWrap)
|
|
60
|
+
SET_SELF_SIZE(ModuleWrap)
|
|
61
|
+
|
|
62
|
+
bool IsNotIndicativeOfMemoryLeakAtExit() const override {
|
|
63
|
+
// XXX: The garbage collection rules for ModuleWrap are *super* unclear.
|
|
64
|
+
// Do these objects ever get GC'd? Are we just okay with leaking them?
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private:
|
|
69
|
+
ModuleWrap(Environment* env,
|
|
70
|
+
v8::Local<v8::Object> object,
|
|
71
|
+
v8::Local<v8::Module> module,
|
|
72
|
+
v8::Local<v8::String> url,
|
|
73
|
+
v8::Local<v8::Object> context_object,
|
|
74
|
+
v8::Local<v8::Value> synthetic_evaluation_step);
|
|
75
|
+
~ModuleWrap() override;
|
|
76
|
+
|
|
77
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
78
|
+
static void Link(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
79
|
+
static void Instantiate(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
80
|
+
static void Evaluate(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
81
|
+
static void GetNamespace(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
82
|
+
static void GetStatus(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
83
|
+
static void GetError(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
84
|
+
static void GetStaticDependencySpecifiers(
|
|
85
|
+
const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
86
|
+
|
|
87
|
+
static void SetImportModuleDynamicallyCallback(
|
|
88
|
+
const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
89
|
+
static void SetInitializeImportMetaObjectCallback(
|
|
90
|
+
const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
91
|
+
static v8::MaybeLocal<v8::Value> SyntheticModuleEvaluationStepsCallback(
|
|
92
|
+
v8::Local<v8::Context> context, v8::Local<v8::Module> module);
|
|
93
|
+
static void SetSyntheticExport(
|
|
94
|
+
const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
95
|
+
static void CreateCachedData(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
96
|
+
|
|
97
|
+
static v8::MaybeLocal<v8::Module> ResolveModuleCallback(
|
|
98
|
+
v8::Local<v8::Context> context,
|
|
99
|
+
v8::Local<v8::String> specifier,
|
|
100
|
+
v8::Local<v8::FixedArray> import_attributes,
|
|
101
|
+
v8::Local<v8::Module> referrer);
|
|
102
|
+
static ModuleWrap* GetFromModule(node::Environment*, v8::Local<v8::Module>);
|
|
103
|
+
|
|
104
|
+
v8::Global<v8::Module> module_;
|
|
105
|
+
std::unordered_map<std::string, v8::Global<v8::Promise>> resolve_cache_;
|
|
106
|
+
contextify::ContextifyContext* contextify_context_ = nullptr;
|
|
107
|
+
bool synthetic_ = false;
|
|
108
|
+
bool linked_ = false;
|
|
109
|
+
int module_hash_;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
} // namespace loader
|
|
113
|
+
} // namespace node
|
|
114
|
+
|
|
115
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
116
|
+
|
|
117
|
+
#endif // SRC_MODULE_WRAP_H_
|