@kungfu-tech/libnode-win32-x64 22.22.3-kf.0 → 22.22.3-kf.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/dist/node/include/acorn_version.h +6 -0
- package/dist/node/include/aliased_buffer-inl.h +244 -0
- package/dist/node/include/aliased_buffer.h +206 -0
- package/dist/node/include/aliased_struct-inl.h +54 -0
- package/dist/node/include/aliased_struct.h +63 -0
- package/dist/node/include/amaro_version.h +6 -0
- package/dist/node/include/async_context_frame.h +33 -0
- package/dist/node/include/async_wrap-inl.h +96 -0
- package/dist/node/include/async_wrap.h +243 -0
- package/dist/node/include/base_object-inl.h +335 -0
- package/dist/node/include/base_object.h +342 -0
- package/dist/node/include/base_object_types.h +74 -0
- package/dist/node/include/blob_serializer_deserializer-inl.h +385 -0
- package/dist/node/include/blob_serializer_deserializer.h +132 -0
- package/dist/node/include/callback_queue-inl.h +97 -0
- package/dist/node/include/callback_queue.h +79 -0
- package/dist/node/include/cares_wrap.h +447 -0
- package/dist/node/include/cjs_module_lexer_version.h +6 -0
- package/dist/node/include/cleanup_queue-inl.h +36 -0
- package/dist/node/include/cleanup_queue.h +79 -0
- package/dist/node/include/compile_cache.h +104 -0
- package/dist/node/include/connect_wrap.h +26 -0
- package/dist/node/include/connection_wrap.h +30 -0
- package/dist/node/include/cppgc/allocation.h +310 -0
- package/dist/node/include/cppgc/common.h +28 -0
- package/dist/node/include/cppgc/cross-thread-persistent.h +466 -0
- package/dist/node/include/cppgc/custom-space.h +97 -0
- package/dist/node/include/cppgc/default-platform.h +67 -0
- package/dist/node/include/cppgc/ephemeron-pair.h +30 -0
- package/dist/node/include/cppgc/explicit-management.h +100 -0
- package/dist/node/include/cppgc/garbage-collected.h +106 -0
- package/dist/node/include/cppgc/heap-consistency.h +309 -0
- package/dist/node/include/cppgc/heap-handle.h +48 -0
- package/dist/node/include/cppgc/heap-state.h +82 -0
- package/dist/node/include/cppgc/heap-statistics.h +120 -0
- package/dist/node/include/cppgc/heap.h +202 -0
- package/dist/node/include/cppgc/internal/api-constants.h +87 -0
- package/dist/node/include/cppgc/internal/atomic-entry-flag.h +48 -0
- package/dist/node/include/cppgc/internal/base-page-handle.h +45 -0
- package/dist/node/include/cppgc/internal/caged-heap-local-data.h +121 -0
- package/dist/node/include/cppgc/internal/caged-heap.h +68 -0
- package/dist/node/include/cppgc/internal/compiler-specific.h +38 -0
- package/dist/node/include/cppgc/internal/finalizer-trait.h +93 -0
- package/dist/node/include/cppgc/internal/gc-info.h +148 -0
- package/dist/node/include/cppgc/internal/logging.h +50 -0
- package/dist/node/include/cppgc/internal/member-storage.h +256 -0
- package/dist/node/include/cppgc/internal/name-trait.h +137 -0
- package/dist/node/include/cppgc/internal/persistent-node.h +214 -0
- package/dist/node/include/cppgc/internal/pointer-policies.h +243 -0
- package/dist/node/include/cppgc/internal/write-barrier.h +487 -0
- package/dist/node/include/cppgc/liveness-broker.h +78 -0
- package/dist/node/include/cppgc/macros.h +35 -0
- package/dist/node/include/cppgc/member.h +629 -0
- package/dist/node/include/cppgc/name-provider.h +65 -0
- package/dist/node/include/cppgc/object-size-trait.h +58 -0
- package/dist/node/include/cppgc/persistent.h +377 -0
- package/dist/node/include/cppgc/platform.h +163 -0
- package/dist/node/include/cppgc/prefinalizer.h +75 -0
- package/dist/node/include/cppgc/process-heap-statistics.h +36 -0
- package/dist/node/include/cppgc/sentinel-pointer.h +39 -0
- package/dist/node/include/cppgc/source-location.h +16 -0
- package/dist/node/include/cppgc/testing.h +106 -0
- package/dist/node/include/cppgc/trace-trait.h +128 -0
- package/dist/node/include/cppgc/type-traits.h +271 -0
- package/dist/node/include/cppgc/visitor.h +504 -0
- package/dist/node/include/crypto/crypto_aes.h +88 -0
- package/dist/node/include/crypto/crypto_bio.h +193 -0
- package/dist/node/include/crypto/crypto_cipher.h +293 -0
- package/dist/node/include/crypto/crypto_clienthello-inl.h +90 -0
- package/dist/node/include/crypto/crypto_clienthello.h +131 -0
- package/dist/node/include/crypto/crypto_common.h +64 -0
- package/dist/node/include/crypto/crypto_context.h +171 -0
- package/dist/node/include/crypto/crypto_dh.h +126 -0
- package/dist/node/include/crypto/crypto_dsa.h +52 -0
- package/dist/node/include/crypto/crypto_ec.h +164 -0
- package/dist/node/include/crypto/crypto_hash.h +91 -0
- package/dist/node/include/crypto/crypto_hkdf.h +61 -0
- package/dist/node/include/crypto/crypto_hmac.h +92 -0
- package/dist/node/include/crypto/crypto_keygen.h +299 -0
- package/dist/node/include/crypto/crypto_keys.h +392 -0
- package/dist/node/include/crypto/crypto_pbkdf2.h +74 -0
- package/dist/node/include/crypto/crypto_random.h +124 -0
- package/dist/node/include/crypto/crypto_rsa.h +136 -0
- package/dist/node/include/crypto/crypto_scrypt.h +85 -0
- package/dist/node/include/crypto/crypto_sig.h +165 -0
- package/dist/node/include/crypto/crypto_spkac.h +21 -0
- package/dist/node/include/crypto/crypto_timing.h +20 -0
- package/dist/node/include/crypto/crypto_tls.h +305 -0
- package/dist/node/include/crypto/crypto_util.h +725 -0
- package/dist/node/include/crypto/crypto_x509.h +140 -0
- package/dist/node/include/dataqueue/queue.h +306 -0
- package/dist/node/include/debug_utils-inl.h +278 -0
- package/dist/node/include/debug_utils.h +196 -0
- package/dist/node/include/diagnosticfilename-inl.h +33 -0
- package/dist/node/include/embedded_data.h +17 -0
- package/dist/node/include/encoding_binding.h +61 -0
- package/dist/node/include/env-inl.h +984 -0
- package/dist/node/include/env.h +1287 -0
- package/dist/node/include/env_properties.h +540 -0
- package/dist/node/include/handle_wrap.h +123 -0
- package/dist/node/include/histogram-inl.h +107 -0
- package/dist/node/include/histogram.h +279 -0
- package/dist/node/include/inspector/io_agent.h +30 -0
- package/dist/node/include/inspector/main_thread_interface.h +116 -0
- package/dist/node/include/inspector/network_agent.h +94 -0
- package/dist/node/include/inspector/network_inspector.h +45 -0
- package/dist/node/include/inspector/network_requests_buffer.h +195 -0
- package/dist/node/include/inspector/network_resource_manager.h +29 -0
- package/dist/node/include/inspector/node_json.h +24 -0
- package/dist/node/include/inspector/node_string.h +101 -0
- package/dist/node/include/inspector/protocol_helper.h +27 -0
- package/dist/node/include/inspector/runtime_agent.h +41 -0
- package/dist/node/include/inspector/target_agent.h +75 -0
- package/dist/node/include/inspector/tracing_agent.h +43 -0
- package/dist/node/include/inspector/worker_agent.h +40 -0
- package/dist/node/include/inspector/worker_inspector.h +124 -0
- package/dist/node/include/inspector_agent.h +165 -0
- package/dist/node/include/inspector_io.h +78 -0
- package/dist/node/include/inspector_profiler.h +149 -0
- package/dist/node/include/inspector_socket.h +60 -0
- package/dist/node/include/inspector_socket_server.h +110 -0
- package/dist/node/include/js_native_api.h +607 -0
- package/dist/node/include/js_native_api_types.h +226 -0
- package/dist/node/include/js_native_api_v8.h +485 -0
- package/dist/node/include/js_native_api_v8_internals.h +45 -0
- package/dist/node/include/js_stream.h +52 -0
- package/dist/node/include/json_utils.h +172 -0
- package/dist/node/include/large_pages/node_large_page.h +34 -0
- package/dist/node/include/libplatform/libplatform-export.h +29 -0
- package/dist/node/include/libplatform/libplatform.h +112 -0
- package/dist/node/include/libplatform/v8-tracing.h +333 -0
- package/dist/node/include/memory_tracker-inl.h +359 -0
- package/dist/node/include/memory_tracker.h +289 -0
- package/dist/node/include/module_wrap.h +216 -0
- package/dist/node/include/node.h +1593 -0
- package/dist/node/include/node_api.h +265 -0
- package/dist/node/include/node_api_internals.h +48 -0
- package/dist/node/include/node_api_types.h +56 -0
- package/dist/node/include/node_binding.h +161 -0
- package/dist/node/include/node_blob.h +159 -0
- package/dist/node/include/node_bob-inl.h +36 -0
- package/dist/node/include/node_bob.h +107 -0
- package/dist/node/include/node_buffer.h +92 -0
- package/dist/node/include/node_builtins.h +220 -0
- package/dist/node/include/node_config_file.h +46 -0
- package/dist/node/include/node_constants.h +82 -0
- package/dist/node/include/node_context_data.h +168 -0
- package/dist/node/include/node_contextify.h +204 -0
- package/dist/node/include/node_crypto.h +56 -0
- package/dist/node/include/node_debug.h +30 -0
- package/dist/node/include/node_dir.h +52 -0
- package/dist/node/include/node_dotenv.h +45 -0
- package/dist/node/include/node_errors.h +380 -0
- package/dist/node/include/node_exit_code.h +54 -0
- package/dist/node/include/node_external_reference.h +165 -0
- package/dist/node/include/node_file-inl.h +406 -0
- package/dist/node/include/node_file.h +537 -0
- package/dist/node/include/node_http2.h +1177 -0
- package/dist/node/include/node_http2_state.h +159 -0
- package/dist/node/include/node_http_common-inl.h +202 -0
- package/dist/node/include/node_http_common.h +535 -0
- package/dist/node/include/node_i18n.h +132 -0
- package/dist/node/include/node_internals.h +483 -0
- package/dist/node/include/node_main_instance.h +67 -0
- package/dist/node/include/node_mem-inl.h +113 -0
- package/dist/node/include/node_mem.h +45 -0
- package/dist/node/include/node_messaging.h +389 -0
- package/dist/node/include/node_metadata.h +164 -0
- package/dist/node/include/node_modules.h +91 -0
- package/dist/node/include/node_mutex.h +323 -0
- package/dist/node/include/node_object_wrap.h +132 -0
- package/dist/node/include/node_options-inl.h +490 -0
- package/dist/node/include/node_options.h +615 -0
- package/dist/node/include/node_perf.h +166 -0
- package/dist/node/include/node_perf_common.h +102 -0
- package/dist/node/include/node_platform.h +238 -0
- package/dist/node/include/node_process-inl.h +26 -0
- package/dist/node/include/node_process.h +112 -0
- package/dist/node/include/node_realm-inl.h +151 -0
- package/dist/node/include/node_realm.h +183 -0
- package/dist/node/include/node_report.h +43 -0
- package/dist/node/include/node_revert.h +82 -0
- package/dist/node/include/node_root_certs.h +3520 -0
- package/dist/node/include/node_sea.h +74 -0
- package/dist/node/include/node_shadow_realm.h +46 -0
- package/dist/node/include/node_snapshot_builder.h +57 -0
- package/dist/node/include/node_snapshotable.h +174 -0
- package/dist/node/include/node_sockaddr-inl.h +257 -0
- package/dist/node/include/node_sockaddr.h +394 -0
- package/dist/node/include/node_sqlite.h +270 -0
- package/dist/node/include/node_stat_watcher.h +73 -0
- package/dist/node/include/node_task_runner.h +92 -0
- package/dist/node/include/node_threadsafe_cow-inl.h +54 -0
- package/dist/node/include/node_threadsafe_cow.h +105 -0
- package/dist/node/include/node_union_bytes.h +81 -0
- package/dist/node/include/node_url.h +96 -0
- package/dist/node/include/node_v8.h +77 -0
- package/dist/node/include/node_v8_platform-inl.h +185 -0
- package/dist/node/include/node_version.h +110 -0
- package/dist/node/include/node_wasi.h +184 -0
- package/dist/node/include/node_wasm_web_api.h +55 -0
- package/dist/node/include/node_watchdog.h +154 -0
- package/dist/node/include/node_webstorage.h +60 -0
- package/dist/node/include/node_worker.h +158 -0
- package/dist/node/include/path.h +33 -0
- package/dist/node/include/permission/addon_permission.h +31 -0
- package/dist/node/include/permission/child_process_permission.h +31 -0
- package/dist/node/include/permission/fs_permission.h +167 -0
- package/dist/node/include/permission/inspector_permission.h +31 -0
- package/dist/node/include/permission/permission.h +138 -0
- package/dist/node/include/permission/permission_base.h +65 -0
- package/dist/node/include/permission/wasi_permission.h +31 -0
- package/dist/node/include/permission/worker_permission.h +31 -0
- package/dist/node/include/pipe_wrap.h +80 -0
- package/dist/node/include/quic/application.h +159 -0
- package/dist/node/include/quic/bindingdata.h +272 -0
- package/dist/node/include/quic/cid.h +127 -0
- package/dist/node/include/quic/data.h +148 -0
- package/dist/node/include/quic/defs.h +245 -0
- package/dist/node/include/quic/endpoint.h +458 -0
- package/dist/node/include/quic/http3.h +15 -0
- package/dist/node/include/quic/logstream.h +81 -0
- package/dist/node/include/quic/packet.h +152 -0
- package/dist/node/include/quic/preferredaddress.h +72 -0
- package/dist/node/include/quic/session.h +443 -0
- package/dist/node/include/quic/sessionticket.h +108 -0
- package/dist/node/include/quic/streams.h +232 -0
- package/dist/node/include/quic/tlscontext.h +227 -0
- package/dist/node/include/quic/tokens.h +256 -0
- package/dist/node/include/quic/transportparams.h +165 -0
- package/dist/node/include/req_wrap-inl.h +171 -0
- package/dist/node/include/req_wrap.h +77 -0
- package/dist/node/include/spawn_sync.h +243 -0
- package/dist/node/include/stream_base-inl.h +173 -0
- package/dist/node/include/stream_base.h +478 -0
- package/dist/node/include/stream_pipe.h +76 -0
- package/dist/node/include/stream_wrap.h +132 -0
- package/dist/node/include/string_bytes.h +113 -0
- package/dist/node/include/string_decoder-inl.h +31 -0
- package/dist/node/include/string_decoder.h +49 -0
- package/dist/node/include/tcp_wrap.h +105 -0
- package/dist/node/include/threadpoolwork-inl.h +70 -0
- package/dist/node/include/timer_wrap-inl.h +32 -0
- package/dist/node/include/timer_wrap.h +85 -0
- package/dist/node/include/timers.h +70 -0
- package/dist/node/include/tracing/agent.h +195 -0
- package/dist/node/include/tracing/node_trace_buffer.h +83 -0
- package/dist/node/include/tracing/node_trace_writer.h +75 -0
- package/dist/node/include/tracing/trace_event.h +722 -0
- package/dist/node/include/tracing/trace_event_common.h +1109 -0
- package/dist/node/include/tracing/traced_value.h +129 -0
- package/dist/node/include/tty_wrap.h +65 -0
- package/dist/node/include/udp_wrap.h +230 -0
- package/dist/node/include/undici_version.h +6 -0
- package/dist/node/include/util-inl.h +700 -0
- package/dist/node/include/util.h +1021 -0
- package/dist/node/include/uv/aix.h +32 -0
- package/dist/node/include/uv/bsd.h +34 -0
- package/dist/node/include/uv/darwin.h +61 -0
- package/dist/node/include/uv/errno.h +483 -0
- package/dist/node/include/uv/linux.h +34 -0
- package/dist/node/include/uv/os390.h +33 -0
- package/dist/node/include/uv/posix.h +31 -0
- package/dist/node/include/uv/sunos.h +44 -0
- package/dist/node/include/uv/threadpool.h +37 -0
- package/dist/node/include/uv/tree.h +521 -0
- package/dist/node/include/uv/unix.h +512 -0
- package/dist/node/include/uv/version.h +43 -0
- package/dist/node/include/uv/win.h +698 -0
- package/dist/node/include/uv.h +1990 -0
- package/dist/node/include/v8-array-buffer.h +525 -0
- package/dist/node/include/v8-callbacks.h +462 -0
- package/dist/node/include/v8-container.h +183 -0
- package/dist/node/include/v8-context.h +485 -0
- package/dist/node/include/v8-cppgc.h +245 -0
- package/dist/node/include/v8-data.h +80 -0
- package/dist/node/include/v8-date.h +48 -0
- package/dist/node/include/v8-debug.h +168 -0
- package/dist/node/include/v8-embedder-heap.h +82 -0
- package/dist/node/include/v8-embedder-state-scope.h +52 -0
- package/dist/node/include/v8-exception.h +223 -0
- package/dist/node/include/v8-extension.h +62 -0
- package/dist/node/include/v8-external.h +37 -0
- package/dist/node/include/v8-fast-api-calls.h +984 -0
- package/dist/node/include/v8-forward.h +82 -0
- package/dist/node/include/v8-function-callback.h +607 -0
- package/dist/node/include/v8-function.h +140 -0
- package/dist/node/include/v8-handle-base.h +137 -0
- package/dist/node/include/v8-initialization.h +289 -0
- package/dist/node/include/v8-inspector-protocol.h +13 -0
- package/dist/node/include/v8-inspector.h +419 -0
- package/dist/node/include/v8-internal.h +1397 -0
- package/dist/node/include/v8-isolate.h +1767 -0
- package/dist/node/include/v8-json.h +47 -0
- package/dist/node/include/v8-local-handle.h +758 -0
- package/dist/node/include/v8-locker.h +138 -0
- package/dist/node/include/v8-maybe.h +160 -0
- package/dist/node/include/v8-memory-span.h +198 -0
- package/dist/node/include/v8-message.h +233 -0
- package/dist/node/include/v8-metrics.h +264 -0
- package/dist/node/include/v8-microtask-queue.h +157 -0
- package/dist/node/include/v8-microtask.h +28 -0
- package/dist/node/include/v8-object.h +824 -0
- package/dist/node/include/v8-persistent-handle.h +582 -0
- package/dist/node/include/v8-platform.h +1358 -0
- package/dist/node/include/v8-primitive-object.h +118 -0
- package/dist/node/include/v8-primitive.h +877 -0
- package/dist/node/include/v8-profiler.h +1302 -0
- package/dist/node/include/v8-promise.h +174 -0
- package/dist/node/include/v8-proxy.h +50 -0
- package/dist/node/include/v8-regexp.h +106 -0
- package/dist/node/include/v8-script.h +904 -0
- package/dist/node/include/v8-snapshot.h +266 -0
- package/dist/node/include/v8-source-location.h +92 -0
- package/dist/node/include/v8-statistics.h +238 -0
- package/dist/node/include/v8-template.h +1297 -0
- package/dist/node/include/v8-traced-handle.h +432 -0
- package/dist/node/include/v8-typed-array.h +390 -0
- package/dist/node/include/v8-unwinder-state.h +31 -0
- package/dist/node/include/v8-unwinder.h +132 -0
- package/dist/node/include/v8-util.h +665 -0
- package/dist/node/include/v8-value-serializer-version.h +24 -0
- package/dist/node/include/v8-value-serializer.h +316 -0
- package/dist/node/include/v8-value.h +655 -0
- package/dist/node/include/v8-version-string.h +38 -0
- package/dist/node/include/v8-version.h +20 -0
- package/dist/node/include/v8-wasm-trap-handler-posix.h +31 -0
- package/dist/node/include/v8-wasm-trap-handler-win.h +28 -0
- package/dist/node/include/v8-wasm.h +201 -0
- package/dist/node/include/v8-weak-callback-info.h +80 -0
- package/dist/node/include/v8.h +88 -0
- package/dist/node/include/v8config.h +981 -0
- package/dist/node/include/zlib_version.h +6 -0
- package/dist/node/libnode.dll +0 -0
- package/dist/node/libnode.lib +0 -0
- package/dist/node/libnodebuildinfo.json +10 -0
- package/dist/node/link_node.lib +0 -0
- package/dist/node/link_node.node +0 -0
- package/libnode.release.json +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
#ifndef SRC_MEMORY_TRACKER_INL_H_
|
|
2
|
+
#define SRC_MEMORY_TRACKER_INL_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "memory_tracker.h"
|
|
7
|
+
#include "util-inl.h"
|
|
8
|
+
|
|
9
|
+
namespace node {
|
|
10
|
+
|
|
11
|
+
// Fallback edge_name if node_name is not available, or "" if edge_name
|
|
12
|
+
// is not available either.
|
|
13
|
+
inline const char* GetNodeName(const char* node_name, const char* edge_name) {
|
|
14
|
+
if (node_name != nullptr) {
|
|
15
|
+
return node_name;
|
|
16
|
+
}
|
|
17
|
+
if (edge_name != nullptr) {
|
|
18
|
+
return edge_name;
|
|
19
|
+
}
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class MemoryRetainerNode : public v8::EmbedderGraph::Node {
|
|
24
|
+
public:
|
|
25
|
+
inline MemoryRetainerNode(MemoryTracker* tracker,
|
|
26
|
+
const MemoryRetainer* retainer)
|
|
27
|
+
: retainer_(retainer) {
|
|
28
|
+
CHECK_NOT_NULL(retainer_);
|
|
29
|
+
v8::HandleScope handle_scope(tracker->isolate());
|
|
30
|
+
v8::Local<v8::Object> obj = retainer_->WrappedObject();
|
|
31
|
+
if (!obj.IsEmpty())
|
|
32
|
+
wrapper_node_ = tracker->graph()->V8Node(obj.As<v8::Value>());
|
|
33
|
+
|
|
34
|
+
name_ = retainer_->MemoryInfoName();
|
|
35
|
+
size_ = retainer_->SelfSize();
|
|
36
|
+
detachedness_ = retainer_->GetDetachedness();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
inline MemoryRetainerNode(MemoryTracker* tracker,
|
|
40
|
+
const char* name,
|
|
41
|
+
size_t size,
|
|
42
|
+
bool is_root_node = false)
|
|
43
|
+
: retainer_(nullptr) {
|
|
44
|
+
name_ = name;
|
|
45
|
+
size_ = size;
|
|
46
|
+
is_root_node_ = is_root_node;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const char* Name() override { return name_; }
|
|
50
|
+
const char* NamePrefix() override { return "Node /"; }
|
|
51
|
+
size_t SizeInBytes() override { return size_; }
|
|
52
|
+
// TODO(addaleax): Merging this with the "official" WrapperNode() method
|
|
53
|
+
// seems to lose accuracy, e.g. SizeInBytes() is disregarded.
|
|
54
|
+
// Figure out whether to do anything about that.
|
|
55
|
+
Node* JSWrapperNode() { return wrapper_node_; }
|
|
56
|
+
|
|
57
|
+
bool IsRootNode() override {
|
|
58
|
+
if (retainer_ != nullptr) {
|
|
59
|
+
return retainer_->IsRootNode();
|
|
60
|
+
}
|
|
61
|
+
return is_root_node_;
|
|
62
|
+
}
|
|
63
|
+
v8::EmbedderGraph::Node::Detachedness GetDetachedness() override {
|
|
64
|
+
return detachedness_;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private:
|
|
68
|
+
friend class MemoryTracker;
|
|
69
|
+
|
|
70
|
+
// If retainer_ is not nullptr, then it must have a wrapper_node_,
|
|
71
|
+
// and we have
|
|
72
|
+
// name_ == retainer_->MemoryInfoName()
|
|
73
|
+
// size_ == retainer_->SelfSize()
|
|
74
|
+
// is_root_node_ == retainer_->IsRootNode()
|
|
75
|
+
const MemoryRetainer* retainer_;
|
|
76
|
+
Node* wrapper_node_ = nullptr;
|
|
77
|
+
|
|
78
|
+
// Otherwise (retainer == nullptr), we set these fields in an ad-hoc way
|
|
79
|
+
bool is_root_node_ = false;
|
|
80
|
+
const char* name_;
|
|
81
|
+
size_t size_ = 0;
|
|
82
|
+
v8::EmbedderGraph::Node::Detachedness detachedness_ =
|
|
83
|
+
v8::EmbedderGraph::Node::Detachedness::kUnknown;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
void MemoryTracker::TrackFieldWithSize(const char* edge_name,
|
|
87
|
+
size_t size,
|
|
88
|
+
const char* node_name) {
|
|
89
|
+
if (size > 0) AddNode(GetNodeName(node_name, edge_name), size, edge_name);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
void MemoryTracker::TrackInlineFieldWithSize(const char* edge_name,
|
|
93
|
+
size_t size,
|
|
94
|
+
const char* node_name) {
|
|
95
|
+
if (size > 0) AddNode(GetNodeName(node_name, edge_name), size, edge_name);
|
|
96
|
+
CHECK(CurrentNode());
|
|
97
|
+
CurrentNode()->size_ -= size;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
101
|
+
const MemoryRetainer& value,
|
|
102
|
+
const char* node_name) {
|
|
103
|
+
TrackField(edge_name, &value);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
107
|
+
const MemoryRetainer* value,
|
|
108
|
+
const char* node_name) {
|
|
109
|
+
if (value == nullptr) return;
|
|
110
|
+
auto it = seen_.find(value);
|
|
111
|
+
if (it != seen_.end()) {
|
|
112
|
+
graph_->AddEdge(CurrentNode(), it->second, edge_name);
|
|
113
|
+
} else {
|
|
114
|
+
Track(value, edge_name);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
template <typename T, typename D>
|
|
119
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
120
|
+
const std::unique_ptr<T, D>& value,
|
|
121
|
+
const char* node_name) {
|
|
122
|
+
if (value.get() == nullptr) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
TrackField(edge_name, value.get(), node_name);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
template <typename T>
|
|
129
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
130
|
+
const std::shared_ptr<T>& value,
|
|
131
|
+
const char* node_name) {
|
|
132
|
+
if (value.get() == nullptr) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
TrackField(edge_name, value.get(), node_name);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
template <typename T, bool kIsWeak>
|
|
139
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
140
|
+
const BaseObjectPtrImpl<T, kIsWeak>& value,
|
|
141
|
+
const char* node_name) {
|
|
142
|
+
if (value.get() == nullptr || kIsWeak) return;
|
|
143
|
+
TrackField(edge_name, value.get(), node_name);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
template <typename T, typename Iterator>
|
|
147
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
148
|
+
const T& value,
|
|
149
|
+
const char* node_name,
|
|
150
|
+
const char* element_name,
|
|
151
|
+
bool subtract_from_self) {
|
|
152
|
+
// If the container is empty, the size has been accounted into the parent's
|
|
153
|
+
// self size
|
|
154
|
+
if (value.begin() == value.end()) return;
|
|
155
|
+
// Fall back to edge name if node names are not provided
|
|
156
|
+
if (CurrentNode() != nullptr && subtract_from_self) {
|
|
157
|
+
// Shift the self size of this container out to a separate node
|
|
158
|
+
CurrentNode()->size_ -= sizeof(T);
|
|
159
|
+
}
|
|
160
|
+
PushNode(GetNodeName(node_name, edge_name), sizeof(T), edge_name);
|
|
161
|
+
for (Iterator it = value.begin(); it != value.end(); ++it) {
|
|
162
|
+
// Use nullptr as edge names so the elements appear as indexed properties
|
|
163
|
+
TrackField(nullptr, *it, element_name);
|
|
164
|
+
}
|
|
165
|
+
PopNode();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
template <typename T>
|
|
169
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
170
|
+
const std::queue<T>& value,
|
|
171
|
+
const char* node_name,
|
|
172
|
+
const char* element_name) {
|
|
173
|
+
struct ContainerGetter : public std::queue<T> {
|
|
174
|
+
static const typename std::queue<T>::container_type& Get(
|
|
175
|
+
const std::queue<T>& value) {
|
|
176
|
+
return value.*&ContainerGetter::c;
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const auto& container = ContainerGetter::Get(value);
|
|
181
|
+
TrackField(edge_name, container, node_name, element_name);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
template <typename T, typename test_for_number, typename dummy>
|
|
185
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
186
|
+
const T& value,
|
|
187
|
+
const char* node_name) {
|
|
188
|
+
// For numbers, creating new nodes is not worth the overhead.
|
|
189
|
+
CurrentNode()->size_ += sizeof(T);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
template <typename T, typename U>
|
|
193
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
194
|
+
const std::pair<T, U>& value,
|
|
195
|
+
const char* node_name) {
|
|
196
|
+
PushNode(node_name == nullptr ? "pair" : node_name,
|
|
197
|
+
sizeof(const std::pair<T, U>),
|
|
198
|
+
edge_name);
|
|
199
|
+
// TODO(joyeecheung): special case if one of these is a number type
|
|
200
|
+
// that meets the test_for_number trait so that their sizes don't get
|
|
201
|
+
// merged into the pair node
|
|
202
|
+
TrackField("first", value.first);
|
|
203
|
+
TrackField("second", value.second);
|
|
204
|
+
PopNode();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
template <typename T>
|
|
208
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
209
|
+
const std::basic_string<T>& value,
|
|
210
|
+
const char* node_name) {
|
|
211
|
+
TrackFieldWithSize(edge_name, value.size() * sizeof(T), "std::basic_string");
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
template <typename T>
|
|
215
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
216
|
+
const v8::Eternal<T>& value,
|
|
217
|
+
const char* node_name) {
|
|
218
|
+
TrackField(edge_name, value.Get(isolate_));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
template <typename T>
|
|
222
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
223
|
+
const v8::PersistentBase<T>& value,
|
|
224
|
+
const char* node_name) {
|
|
225
|
+
if (value.IsWeak()) return;
|
|
226
|
+
TrackField(edge_name, value.Get(isolate_));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
template <typename T>
|
|
230
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
231
|
+
const v8::Local<T>& value,
|
|
232
|
+
const char* node_name) {
|
|
233
|
+
if (!value.IsEmpty())
|
|
234
|
+
graph_->AddEdge(CurrentNode(),
|
|
235
|
+
graph_->V8Node(value.template As<v8::Value>()),
|
|
236
|
+
edge_name);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
template <typename T>
|
|
240
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
241
|
+
const MallocedBuffer<T>& value,
|
|
242
|
+
const char* node_name) {
|
|
243
|
+
TrackFieldWithSize(edge_name, value.size, "MallocedBuffer");
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
void MemoryTracker::TrackField(const char* edge_name,
|
|
247
|
+
const v8::BackingStore* value,
|
|
248
|
+
const char* node_name) {
|
|
249
|
+
TrackFieldWithSize(edge_name, value->ByteLength(), "BackingStore");
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
void MemoryTracker::TrackField(const char* name,
|
|
253
|
+
const uv_buf_t& value,
|
|
254
|
+
const char* node_name) {
|
|
255
|
+
TrackFieldWithSize(name, value.len, "uv_buf_t");
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
void MemoryTracker::TrackField(const char* name,
|
|
259
|
+
const uv_timer_t& value,
|
|
260
|
+
const char* node_name) {
|
|
261
|
+
TrackFieldWithSize(name, sizeof(value), "uv_timer_t");
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
void MemoryTracker::TrackField(const char* name,
|
|
265
|
+
const uv_async_t& value,
|
|
266
|
+
const char* node_name) {
|
|
267
|
+
TrackFieldWithSize(name, sizeof(value), "uv_async_t");
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
void MemoryTracker::TrackInlineField(const char* name,
|
|
271
|
+
const uv_async_t& value,
|
|
272
|
+
const char* node_name) {
|
|
273
|
+
TrackInlineFieldWithSize(name, sizeof(value), "uv_async_t");
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
void MemoryTracker::Track(const MemoryRetainer* retainer,
|
|
277
|
+
const char* edge_name) {
|
|
278
|
+
v8::HandleScope handle_scope(isolate_);
|
|
279
|
+
auto it = seen_.find(retainer);
|
|
280
|
+
if (it != seen_.end()) {
|
|
281
|
+
if (CurrentNode() != nullptr) {
|
|
282
|
+
graph_->AddEdge(CurrentNode(), it->second, edge_name);
|
|
283
|
+
}
|
|
284
|
+
return; // It has already been tracked, no need to call MemoryInfo again
|
|
285
|
+
}
|
|
286
|
+
MemoryRetainerNode* n = PushNode(retainer, edge_name);
|
|
287
|
+
retainer->MemoryInfo(this);
|
|
288
|
+
CHECK_EQ(CurrentNode(), n);
|
|
289
|
+
CHECK_NE(n->size_, 0);
|
|
290
|
+
PopNode();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
void MemoryTracker::TrackInlineField(const MemoryRetainer* retainer,
|
|
294
|
+
const char* edge_name) {
|
|
295
|
+
Track(retainer, edge_name);
|
|
296
|
+
CHECK(CurrentNode());
|
|
297
|
+
CurrentNode()->size_ -= retainer->SelfSize();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
MemoryRetainerNode* MemoryTracker::CurrentNode() const {
|
|
301
|
+
if (node_stack_.empty()) return nullptr;
|
|
302
|
+
return node_stack_.top();
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
MemoryRetainerNode* MemoryTracker::AddNode(const MemoryRetainer* retainer,
|
|
306
|
+
const char* edge_name) {
|
|
307
|
+
auto it = seen_.find(retainer);
|
|
308
|
+
if (it != seen_.end()) {
|
|
309
|
+
return it->second;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
MemoryRetainerNode* n = new MemoryRetainerNode(this, retainer);
|
|
313
|
+
graph_->AddNode(std::unique_ptr<v8::EmbedderGraph::Node>(n));
|
|
314
|
+
seen_[retainer] = n;
|
|
315
|
+
if (CurrentNode() != nullptr) graph_->AddEdge(CurrentNode(), n, edge_name);
|
|
316
|
+
|
|
317
|
+
if (n->JSWrapperNode() != nullptr) {
|
|
318
|
+
graph_->AddEdge(n, n->JSWrapperNode(), "native_to_javascript");
|
|
319
|
+
graph_->AddEdge(n->JSWrapperNode(), n, "javascript_to_native");
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return n;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
MemoryRetainerNode* MemoryTracker::AddNode(const char* node_name,
|
|
326
|
+
size_t size,
|
|
327
|
+
const char* edge_name) {
|
|
328
|
+
MemoryRetainerNode* n = new MemoryRetainerNode(this, node_name, size);
|
|
329
|
+
graph_->AddNode(std::unique_ptr<v8::EmbedderGraph::Node>(n));
|
|
330
|
+
|
|
331
|
+
if (CurrentNode() != nullptr) graph_->AddEdge(CurrentNode(), n, edge_name);
|
|
332
|
+
|
|
333
|
+
return n;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
MemoryRetainerNode* MemoryTracker::PushNode(const MemoryRetainer* retainer,
|
|
337
|
+
const char* edge_name) {
|
|
338
|
+
MemoryRetainerNode* n = AddNode(retainer, edge_name);
|
|
339
|
+
node_stack_.push(n);
|
|
340
|
+
return n;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
MemoryRetainerNode* MemoryTracker::PushNode(const char* node_name,
|
|
344
|
+
size_t size,
|
|
345
|
+
const char* edge_name) {
|
|
346
|
+
MemoryRetainerNode* n = AddNode(node_name, size, edge_name);
|
|
347
|
+
node_stack_.push(n);
|
|
348
|
+
return n;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
void MemoryTracker::PopNode() {
|
|
352
|
+
node_stack_.pop();
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
} // namespace node
|
|
356
|
+
|
|
357
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
358
|
+
|
|
359
|
+
#endif // SRC_MEMORY_TRACKER_INL_H_
|
|
@@ -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
|