@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,538 @@
|
|
|
1
|
+
#ifndef SRC_NODE_OPTIONS_H_
|
|
2
|
+
#define SRC_NODE_OPTIONS_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <unordered_map>
|
|
9
|
+
#include <vector>
|
|
10
|
+
#include "node_constants.h"
|
|
11
|
+
#include "node_mutex.h"
|
|
12
|
+
#include "util.h"
|
|
13
|
+
|
|
14
|
+
#if HAVE_OPENSSL
|
|
15
|
+
#include "openssl/opensslv.h"
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
namespace node {
|
|
19
|
+
|
|
20
|
+
class HostPort {
|
|
21
|
+
public:
|
|
22
|
+
HostPort(const std::string& host_name, int port)
|
|
23
|
+
: host_name_(host_name), port_(port) {}
|
|
24
|
+
HostPort(const HostPort&) = default;
|
|
25
|
+
HostPort& operator=(const HostPort&) = default;
|
|
26
|
+
HostPort(HostPort&&) = default;
|
|
27
|
+
HostPort& operator=(HostPort&&) = default;
|
|
28
|
+
|
|
29
|
+
void set_host(const std::string& host) { host_name_ = host; }
|
|
30
|
+
|
|
31
|
+
void set_port(uint16_t port) { port_ = port; }
|
|
32
|
+
|
|
33
|
+
const std::string& host() const { return host_name_; }
|
|
34
|
+
|
|
35
|
+
uint16_t port() const { return port_; }
|
|
36
|
+
|
|
37
|
+
void Update(const HostPort& other) {
|
|
38
|
+
if (!other.host_name_.empty()) host_name_ = other.host_name_;
|
|
39
|
+
port_ = other.port_;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private:
|
|
43
|
+
std::string host_name_;
|
|
44
|
+
uint16_t port_;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
class Options {
|
|
48
|
+
public:
|
|
49
|
+
virtual void CheckOptions(std::vector<std::string>* errors,
|
|
50
|
+
std::vector<std::string>* argv) {}
|
|
51
|
+
virtual ~Options() = default;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
struct InspectPublishUid {
|
|
55
|
+
bool console;
|
|
56
|
+
bool http;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// These options are currently essentially per-Environment, but it can be nice
|
|
60
|
+
// to keep them separate since they are a group of options applying to a very
|
|
61
|
+
// specific part of Node. It might also make more sense for them to be
|
|
62
|
+
// per-Isolate, rather than per-Environment.
|
|
63
|
+
class DebugOptions : public Options {
|
|
64
|
+
public:
|
|
65
|
+
DebugOptions() = default;
|
|
66
|
+
DebugOptions(const DebugOptions&) = default;
|
|
67
|
+
DebugOptions& operator=(const DebugOptions&) = default;
|
|
68
|
+
DebugOptions(DebugOptions&&) = default;
|
|
69
|
+
DebugOptions& operator=(DebugOptions&&) = default;
|
|
70
|
+
|
|
71
|
+
bool allow_attaching_debugger = true;
|
|
72
|
+
// --inspect
|
|
73
|
+
bool inspector_enabled = false;
|
|
74
|
+
// --debug
|
|
75
|
+
bool deprecated_debug = false;
|
|
76
|
+
// --inspect-brk
|
|
77
|
+
bool break_first_line = false;
|
|
78
|
+
// --inspect-brk-node
|
|
79
|
+
bool break_node_first_line = false;
|
|
80
|
+
// --inspect-publish-uid
|
|
81
|
+
std::string inspect_publish_uid_string = "stderr,http";
|
|
82
|
+
|
|
83
|
+
InspectPublishUid inspect_publish_uid;
|
|
84
|
+
|
|
85
|
+
enum { kDefaultInspectorPort = 9229 };
|
|
86
|
+
|
|
87
|
+
HostPort host_port{"127.0.0.1", kDefaultInspectorPort};
|
|
88
|
+
|
|
89
|
+
// Used to patch the options as if --inspect-brk is passed.
|
|
90
|
+
void EnableBreakFirstLine() {
|
|
91
|
+
inspector_enabled = true;
|
|
92
|
+
break_first_line = true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
bool wait_for_connect() const {
|
|
96
|
+
return break_first_line || break_node_first_line;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
void CheckOptions(std::vector<std::string>* errors,
|
|
100
|
+
std::vector<std::string>* argv) override;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
class EnvironmentOptions : public Options {
|
|
104
|
+
public:
|
|
105
|
+
bool abort_on_uncaught_exception = false;
|
|
106
|
+
std::vector<std::string> conditions;
|
|
107
|
+
bool detect_module = false;
|
|
108
|
+
std::string dns_result_order;
|
|
109
|
+
bool enable_source_maps = false;
|
|
110
|
+
bool experimental_fetch = true;
|
|
111
|
+
bool experimental_websocket = false;
|
|
112
|
+
bool experimental_global_customevent = true;
|
|
113
|
+
bool experimental_global_web_crypto = true;
|
|
114
|
+
bool experimental_https_modules = false;
|
|
115
|
+
bool experimental_wasm_modules = false;
|
|
116
|
+
bool experimental_import_meta_resolve = false;
|
|
117
|
+
std::string input_type; // Value of --input-type
|
|
118
|
+
std::string type; // Value of --experimental-default-type
|
|
119
|
+
std::string experimental_policy;
|
|
120
|
+
std::string experimental_policy_integrity;
|
|
121
|
+
bool has_policy_integrity_string = false;
|
|
122
|
+
bool experimental_permission = false;
|
|
123
|
+
std::vector<std::string> allow_fs_read;
|
|
124
|
+
std::vector<std::string> allow_fs_write;
|
|
125
|
+
bool allow_child_process = false;
|
|
126
|
+
bool allow_worker_threads = false;
|
|
127
|
+
bool experimental_repl_await = true;
|
|
128
|
+
bool experimental_vm_modules = false;
|
|
129
|
+
bool expose_internals = false;
|
|
130
|
+
bool force_node_api_uncaught_exceptions_policy = false;
|
|
131
|
+
bool frozen_intrinsics = false;
|
|
132
|
+
int64_t heap_snapshot_near_heap_limit = 0;
|
|
133
|
+
std::string heap_snapshot_signal;
|
|
134
|
+
bool network_family_autoselection = true;
|
|
135
|
+
uint64_t max_http_header_size = 16 * 1024;
|
|
136
|
+
bool deprecation = true;
|
|
137
|
+
bool force_async_hooks_checks = true;
|
|
138
|
+
bool allow_native_addons = true;
|
|
139
|
+
bool global_search_paths = true;
|
|
140
|
+
bool warnings = true;
|
|
141
|
+
bool force_context_aware = false;
|
|
142
|
+
bool pending_deprecation = false;
|
|
143
|
+
bool preserve_symlinks = false;
|
|
144
|
+
bool preserve_symlinks_main = false;
|
|
145
|
+
bool prof_process = false;
|
|
146
|
+
#if HAVE_INSPECTOR
|
|
147
|
+
std::string cpu_prof_dir;
|
|
148
|
+
static const uint64_t kDefaultCpuProfInterval = 1000;
|
|
149
|
+
uint64_t cpu_prof_interval = kDefaultCpuProfInterval;
|
|
150
|
+
std::string cpu_prof_name;
|
|
151
|
+
bool cpu_prof = false;
|
|
152
|
+
std::string heap_prof_dir;
|
|
153
|
+
std::string heap_prof_name;
|
|
154
|
+
static const uint64_t kDefaultHeapProfInterval = 512 * 1024;
|
|
155
|
+
uint64_t heap_prof_interval = kDefaultHeapProfInterval;
|
|
156
|
+
bool heap_prof = false;
|
|
157
|
+
#endif // HAVE_INSPECTOR
|
|
158
|
+
std::string redirect_warnings;
|
|
159
|
+
std::string diagnostic_dir;
|
|
160
|
+
std::string env_file;
|
|
161
|
+
bool has_env_file_string = false;
|
|
162
|
+
bool test_runner = false;
|
|
163
|
+
uint64_t test_runner_concurrency = 0;
|
|
164
|
+
bool test_runner_coverage = false;
|
|
165
|
+
std::vector<std::string> test_name_pattern;
|
|
166
|
+
std::vector<std::string> test_reporter;
|
|
167
|
+
std::vector<std::string> test_reporter_destination;
|
|
168
|
+
bool test_only = false;
|
|
169
|
+
bool test_udp_no_try_send = false;
|
|
170
|
+
std::string test_shard;
|
|
171
|
+
bool throw_deprecation = false;
|
|
172
|
+
bool trace_atomics_wait = false;
|
|
173
|
+
bool trace_deprecation = false;
|
|
174
|
+
bool trace_exit = false;
|
|
175
|
+
bool trace_sync_io = false;
|
|
176
|
+
bool trace_tls = false;
|
|
177
|
+
bool trace_uncaught = false;
|
|
178
|
+
bool trace_warnings = false;
|
|
179
|
+
bool extra_info_on_fatal_exception = true;
|
|
180
|
+
std::string unhandled_rejections;
|
|
181
|
+
std::vector<std::string> userland_loaders;
|
|
182
|
+
bool verify_base_objects =
|
|
183
|
+
#ifdef DEBUG
|
|
184
|
+
true;
|
|
185
|
+
#else
|
|
186
|
+
false;
|
|
187
|
+
#endif // DEBUG
|
|
188
|
+
|
|
189
|
+
bool watch_mode = false;
|
|
190
|
+
bool watch_mode_report_to_parent = false;
|
|
191
|
+
bool watch_mode_preserve_output = false;
|
|
192
|
+
std::vector<std::string> watch_mode_paths;
|
|
193
|
+
|
|
194
|
+
bool syntax_check_only = false;
|
|
195
|
+
bool has_eval_string = false;
|
|
196
|
+
std::string eval_string;
|
|
197
|
+
bool print_eval = false;
|
|
198
|
+
bool force_repl = false;
|
|
199
|
+
|
|
200
|
+
bool insecure_http_parser = false;
|
|
201
|
+
|
|
202
|
+
bool tls_min_v1_0 = false;
|
|
203
|
+
bool tls_min_v1_1 = false;
|
|
204
|
+
bool tls_min_v1_2 = false;
|
|
205
|
+
bool tls_min_v1_3 = false;
|
|
206
|
+
bool tls_max_v1_2 = false;
|
|
207
|
+
bool tls_max_v1_3 = false;
|
|
208
|
+
std::string tls_keylog;
|
|
209
|
+
|
|
210
|
+
std::vector<std::string> preload_cjs_modules;
|
|
211
|
+
|
|
212
|
+
std::vector<std::string> preload_esm_modules;
|
|
213
|
+
|
|
214
|
+
std::vector<std::string> user_argv;
|
|
215
|
+
|
|
216
|
+
inline DebugOptions* get_debug_options() { return &debug_options_; }
|
|
217
|
+
inline const DebugOptions& debug_options() const { return debug_options_; }
|
|
218
|
+
|
|
219
|
+
void CheckOptions(std::vector<std::string>* errors,
|
|
220
|
+
std::vector<std::string>* argv) override;
|
|
221
|
+
|
|
222
|
+
private:
|
|
223
|
+
DebugOptions debug_options_;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
class PerIsolateOptions : public Options {
|
|
227
|
+
public:
|
|
228
|
+
std::shared_ptr<EnvironmentOptions> per_env { new EnvironmentOptions() };
|
|
229
|
+
bool track_heap_objects = false;
|
|
230
|
+
bool report_uncaught_exception = false;
|
|
231
|
+
bool report_on_signal = false;
|
|
232
|
+
bool experimental_shadow_realm = false;
|
|
233
|
+
std::string report_signal = "SIGUSR2";
|
|
234
|
+
bool build_snapshot = false;
|
|
235
|
+
inline EnvironmentOptions* get_per_env_options();
|
|
236
|
+
void CheckOptions(std::vector<std::string>* errors,
|
|
237
|
+
std::vector<std::string>* argv) override;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
class PerProcessOptions : public Options {
|
|
241
|
+
public:
|
|
242
|
+
// Options shouldn't be here unless they affect the entire process scope, and
|
|
243
|
+
// that should avoided when possible.
|
|
244
|
+
//
|
|
245
|
+
// When an option is used during process initialization, it does not need
|
|
246
|
+
// protection, but any use after that will likely require synchronization
|
|
247
|
+
// using the node::per_process::cli_options_mutex, typically:
|
|
248
|
+
//
|
|
249
|
+
// Mutex::ScopedLock lock(node::per_process::cli_options_mutex);
|
|
250
|
+
std::shared_ptr<PerIsolateOptions> per_isolate { new PerIsolateOptions() };
|
|
251
|
+
|
|
252
|
+
std::string title;
|
|
253
|
+
std::string trace_event_categories;
|
|
254
|
+
std::string trace_event_file_pattern = "node_trace.${rotation}.log";
|
|
255
|
+
int64_t v8_thread_pool_size = 4;
|
|
256
|
+
bool zero_fill_all_buffers = false;
|
|
257
|
+
bool debug_arraybuffer_allocations = false;
|
|
258
|
+
std::string disable_proto;
|
|
259
|
+
// We enable the shared read-only heap which currently requires that the
|
|
260
|
+
// snapshot used in different isolates in the same process to be the same.
|
|
261
|
+
// Therefore --node-snapshot is a per-process option.
|
|
262
|
+
bool node_snapshot = true;
|
|
263
|
+
std::string snapshot_blob;
|
|
264
|
+
|
|
265
|
+
std::vector<std::string> security_reverts;
|
|
266
|
+
bool print_bash_completion = false;
|
|
267
|
+
bool print_help = false;
|
|
268
|
+
bool print_v8_help = false;
|
|
269
|
+
bool print_version = false;
|
|
270
|
+
std::string experimental_sea_config;
|
|
271
|
+
|
|
272
|
+
#ifdef NODE_HAVE_I18N_SUPPORT
|
|
273
|
+
std::string icu_data_dir;
|
|
274
|
+
#endif
|
|
275
|
+
|
|
276
|
+
// Per-process because they affect singleton OpenSSL shared library state,
|
|
277
|
+
// or are used once during process initialization.
|
|
278
|
+
#if HAVE_OPENSSL
|
|
279
|
+
std::string openssl_config;
|
|
280
|
+
std::string tls_cipher_list = DEFAULT_CIPHER_LIST_CORE;
|
|
281
|
+
int64_t secure_heap = 0;
|
|
282
|
+
int64_t secure_heap_min = 2;
|
|
283
|
+
#ifdef NODE_OPENSSL_CERT_STORE
|
|
284
|
+
bool ssl_openssl_cert_store = true;
|
|
285
|
+
#else
|
|
286
|
+
bool ssl_openssl_cert_store = false;
|
|
287
|
+
#endif
|
|
288
|
+
bool use_openssl_ca = false;
|
|
289
|
+
bool use_bundled_ca = false;
|
|
290
|
+
bool enable_fips_crypto = false;
|
|
291
|
+
bool force_fips_crypto = false;
|
|
292
|
+
#endif
|
|
293
|
+
#if OPENSSL_VERSION_MAJOR >= 3
|
|
294
|
+
bool openssl_legacy_provider = false;
|
|
295
|
+
bool openssl_shared_config = false;
|
|
296
|
+
#endif
|
|
297
|
+
|
|
298
|
+
// Per-process because reports can be triggered outside a known V8 context.
|
|
299
|
+
bool report_on_fatalerror = false;
|
|
300
|
+
bool report_compact = false;
|
|
301
|
+
std::string report_directory;
|
|
302
|
+
std::string report_filename;
|
|
303
|
+
|
|
304
|
+
// TODO(addaleax): Some of these could probably be per-Environment.
|
|
305
|
+
std::string use_largepages = "off";
|
|
306
|
+
bool trace_sigint = false;
|
|
307
|
+
std::vector<std::string> cmdline;
|
|
308
|
+
|
|
309
|
+
inline PerIsolateOptions* get_per_isolate_options();
|
|
310
|
+
void CheckOptions(std::vector<std::string>* errors,
|
|
311
|
+
std::vector<std::string>* argv) override;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// The actual options parser, as opposed to the structs containing them:
|
|
315
|
+
|
|
316
|
+
namespace options_parser {
|
|
317
|
+
|
|
318
|
+
HostPort SplitHostPort(const std::string& arg,
|
|
319
|
+
std::vector<std::string>* errors);
|
|
320
|
+
void GetOptions(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
321
|
+
std::string GetBashCompletion();
|
|
322
|
+
|
|
323
|
+
enum OptionType {
|
|
324
|
+
kNoOp,
|
|
325
|
+
kV8Option,
|
|
326
|
+
kBoolean,
|
|
327
|
+
kInteger,
|
|
328
|
+
kUInteger,
|
|
329
|
+
kString,
|
|
330
|
+
kHostPort,
|
|
331
|
+
kStringList,
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
template <typename Options>
|
|
335
|
+
class OptionsParser {
|
|
336
|
+
public:
|
|
337
|
+
virtual ~OptionsParser() = default;
|
|
338
|
+
|
|
339
|
+
typedef Options TargetType;
|
|
340
|
+
|
|
341
|
+
struct NoOp {};
|
|
342
|
+
struct V8Option {};
|
|
343
|
+
|
|
344
|
+
// These methods add a single option to the parser. Optionally, it can be
|
|
345
|
+
// specified whether the option should be allowed from environment variable
|
|
346
|
+
// sources (i.e. NODE_OPTIONS).
|
|
347
|
+
void AddOption(const char* name,
|
|
348
|
+
const char* help_text,
|
|
349
|
+
bool Options::*field,
|
|
350
|
+
OptionEnvvarSettings env_setting = kDisallowedInEnvvar,
|
|
351
|
+
bool default_is_true = false);
|
|
352
|
+
void AddOption(const char* name,
|
|
353
|
+
const char* help_text,
|
|
354
|
+
uint64_t Options::*field,
|
|
355
|
+
OptionEnvvarSettings env_setting = kDisallowedInEnvvar);
|
|
356
|
+
void AddOption(const char* name,
|
|
357
|
+
const char* help_text,
|
|
358
|
+
int64_t Options::*field,
|
|
359
|
+
OptionEnvvarSettings env_setting = kDisallowedInEnvvar);
|
|
360
|
+
void AddOption(const char* name,
|
|
361
|
+
const char* help_text,
|
|
362
|
+
std::string Options::*field,
|
|
363
|
+
OptionEnvvarSettings env_setting = kDisallowedInEnvvar);
|
|
364
|
+
void AddOption(const char* name,
|
|
365
|
+
const char* help_text,
|
|
366
|
+
std::vector<std::string> Options::*field,
|
|
367
|
+
OptionEnvvarSettings env_setting = kDisallowedInEnvvar);
|
|
368
|
+
void AddOption(const char* name,
|
|
369
|
+
const char* help_text,
|
|
370
|
+
HostPort Options::*field,
|
|
371
|
+
OptionEnvvarSettings env_setting = kDisallowedInEnvvar);
|
|
372
|
+
void AddOption(const char* name,
|
|
373
|
+
const char* help_text,
|
|
374
|
+
NoOp no_op_tag,
|
|
375
|
+
OptionEnvvarSettings env_setting = kDisallowedInEnvvar);
|
|
376
|
+
void AddOption(const char* name,
|
|
377
|
+
const char* help_text,
|
|
378
|
+
V8Option v8_option_tag,
|
|
379
|
+
OptionEnvvarSettings env_setting = kDisallowedInEnvvar);
|
|
380
|
+
|
|
381
|
+
// Adds aliases. An alias can be of the form "--option-a" -> "--option-b",
|
|
382
|
+
// or have a more complex group expansion, like
|
|
383
|
+
// "--option-a" -> { "--option-b", "--harmony-foobar", "--eval", "42" }
|
|
384
|
+
// If `from` has the form "--option-a=", the alias will only be expanded if
|
|
385
|
+
// the option is presented in that form (i.e. with a '=').
|
|
386
|
+
// If `from` has the form "--option-a <arg>", the alias will only be expanded
|
|
387
|
+
// if the option has a non-option argument (not starting with -) following it.
|
|
388
|
+
void AddAlias(const char* from, const char* to);
|
|
389
|
+
void AddAlias(const char* from, const std::vector<std::string>& to);
|
|
390
|
+
void AddAlias(const char* from,
|
|
391
|
+
const std::initializer_list<std::string>& to);
|
|
392
|
+
|
|
393
|
+
// Add implications from some arbitrary option to a boolean one, either
|
|
394
|
+
// in a way that makes `from` set `to` to true or to false.
|
|
395
|
+
void Implies(const char* from, const char* to);
|
|
396
|
+
void ImpliesNot(const char* from, const char* to);
|
|
397
|
+
|
|
398
|
+
// Insert options from another options parser into this one, along with
|
|
399
|
+
// a method that yields the target options type from this parser's options
|
|
400
|
+
// type.
|
|
401
|
+
template <typename ChildOptions>
|
|
402
|
+
void Insert(const OptionsParser<ChildOptions>& child_options_parser,
|
|
403
|
+
ChildOptions* (Options::* get_child)());
|
|
404
|
+
|
|
405
|
+
// Parse a sequence of options into an options struct, a list of
|
|
406
|
+
// arguments that were parsed as options, a list of unknown/JS engine options,
|
|
407
|
+
// and leave the remainder in the input `args` vector.
|
|
408
|
+
//
|
|
409
|
+
// For example, an `args` input of
|
|
410
|
+
//
|
|
411
|
+
// node --foo --harmony-bar --fizzle=42 -- /path/to/cow moo
|
|
412
|
+
//
|
|
413
|
+
// expands as
|
|
414
|
+
//
|
|
415
|
+
// - `args` -> { "node", "/path/to/cow", "moo" }
|
|
416
|
+
// - `exec_args` -> { "--foo", "--harmony-bar", "--fizzle=42" }
|
|
417
|
+
// - `v8_args` -> `{ "node", "--harmony-bar" }
|
|
418
|
+
// - `options->foo == true`, `options->fizzle == 42`.
|
|
419
|
+
//
|
|
420
|
+
// If `*error` is set, the result of the parsing should be discarded and the
|
|
421
|
+
// contents of any of the argument vectors should be considered undefined.
|
|
422
|
+
void Parse(std::vector<std::string>* const args,
|
|
423
|
+
std::vector<std::string>* const exec_args,
|
|
424
|
+
std::vector<std::string>* const v8_args,
|
|
425
|
+
Options* const options,
|
|
426
|
+
OptionEnvvarSettings required_env_settings,
|
|
427
|
+
std::vector<std::string>* const errors) const;
|
|
428
|
+
|
|
429
|
+
private:
|
|
430
|
+
// We support the wide variety of different option types by remembering
|
|
431
|
+
// how to access them, given a certain `Options` struct.
|
|
432
|
+
|
|
433
|
+
// Represents a field within `Options`.
|
|
434
|
+
class BaseOptionField {
|
|
435
|
+
public:
|
|
436
|
+
virtual ~BaseOptionField() = default;
|
|
437
|
+
virtual void* LookupImpl(Options* options) const = 0;
|
|
438
|
+
|
|
439
|
+
template <typename T>
|
|
440
|
+
inline T* Lookup(Options* options) const {
|
|
441
|
+
return static_cast<T*>(LookupImpl(options));
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
// Represents a field of type T within `Options` that can be looked up
|
|
446
|
+
// as a C++ member field.
|
|
447
|
+
template <typename T>
|
|
448
|
+
class SimpleOptionField : public BaseOptionField {
|
|
449
|
+
public:
|
|
450
|
+
explicit SimpleOptionField(T Options::* field) : field_(field) {}
|
|
451
|
+
void* LookupImpl(Options* options) const override {
|
|
452
|
+
return static_cast<void*>(&(options->*field_));
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
private:
|
|
456
|
+
T Options::* field_;
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
template <typename T>
|
|
460
|
+
inline T* Lookup(std::shared_ptr<BaseOptionField> field,
|
|
461
|
+
Options* options) const {
|
|
462
|
+
return field->template Lookup<T>(options);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// An option consists of:
|
|
466
|
+
// - A type.
|
|
467
|
+
// - A way to store/access the property value.
|
|
468
|
+
// - The information of whether it may occur in an env var or not.
|
|
469
|
+
struct OptionInfo {
|
|
470
|
+
OptionType type;
|
|
471
|
+
std::shared_ptr<BaseOptionField> field;
|
|
472
|
+
OptionEnvvarSettings env_setting;
|
|
473
|
+
std::string help_text;
|
|
474
|
+
bool default_is_true = false;
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
// An implied option is composed of the information on where to store a
|
|
478
|
+
// specific boolean value (if another specific option is encountered).
|
|
479
|
+
struct Implication {
|
|
480
|
+
OptionType type;
|
|
481
|
+
std::string name;
|
|
482
|
+
std::shared_ptr<BaseOptionField> target_field;
|
|
483
|
+
bool target_value;
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
// These are helpers that make `Insert()` support properties of other
|
|
487
|
+
// options structs, if we know how to access them.
|
|
488
|
+
template <typename OriginalField, typename ChildOptions>
|
|
489
|
+
static auto Convert(
|
|
490
|
+
std::shared_ptr<OriginalField> original,
|
|
491
|
+
ChildOptions* (Options::* get_child)());
|
|
492
|
+
template <typename ChildOptions>
|
|
493
|
+
static auto Convert(
|
|
494
|
+
typename OptionsParser<ChildOptions>::OptionInfo original,
|
|
495
|
+
ChildOptions* (Options::* get_child)());
|
|
496
|
+
template <typename ChildOptions>
|
|
497
|
+
static auto Convert(
|
|
498
|
+
typename OptionsParser<ChildOptions>::Implication original,
|
|
499
|
+
ChildOptions* (Options::* get_child)());
|
|
500
|
+
|
|
501
|
+
std::unordered_map<std::string, OptionInfo> options_;
|
|
502
|
+
std::unordered_map<std::string, std::vector<std::string>> aliases_;
|
|
503
|
+
std::unordered_multimap<std::string, Implication> implications_;
|
|
504
|
+
|
|
505
|
+
template <typename OtherOptions>
|
|
506
|
+
friend class OptionsParser;
|
|
507
|
+
|
|
508
|
+
friend void GetCLIOptions(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
509
|
+
friend std::string GetBashCompletion();
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
using StringVector = std::vector<std::string>;
|
|
513
|
+
template <class OptionsType, class = Options>
|
|
514
|
+
void Parse(
|
|
515
|
+
StringVector* const args, StringVector* const exec_args,
|
|
516
|
+
StringVector* const v8_args, OptionsType* const options,
|
|
517
|
+
OptionEnvvarSettings required_env_settings, StringVector* const errors);
|
|
518
|
+
|
|
519
|
+
} // namespace options_parser
|
|
520
|
+
|
|
521
|
+
namespace per_process {
|
|
522
|
+
|
|
523
|
+
extern Mutex cli_options_mutex;
|
|
524
|
+
extern NODE_EXTERN_PRIVATE std::shared_ptr<PerProcessOptions> cli_options;
|
|
525
|
+
|
|
526
|
+
} // namespace per_process
|
|
527
|
+
|
|
528
|
+
void HandleEnvOptions(std::shared_ptr<EnvironmentOptions> env_options);
|
|
529
|
+
void HandleEnvOptions(std::shared_ptr<EnvironmentOptions> env_options,
|
|
530
|
+
std::function<std::string(const char*)> opt_getter);
|
|
531
|
+
|
|
532
|
+
std::vector<std::string> ParseNodeOptionsEnvVar(
|
|
533
|
+
const std::string& node_options, std::vector<std::string>* errors);
|
|
534
|
+
} // namespace node
|
|
535
|
+
|
|
536
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
537
|
+
|
|
538
|
+
#endif // SRC_NODE_OPTIONS_H_
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
#ifndef SRC_NODE_PERF_H_
|
|
2
|
+
#define SRC_NODE_PERF_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "base_object-inl.h"
|
|
7
|
+
#include "histogram.h"
|
|
8
|
+
#include "node.h"
|
|
9
|
+
#include "node_internals.h"
|
|
10
|
+
#include "node_perf_common.h"
|
|
11
|
+
|
|
12
|
+
#include "v8.h"
|
|
13
|
+
#include "uv.h"
|
|
14
|
+
|
|
15
|
+
#include <string>
|
|
16
|
+
|
|
17
|
+
namespace node {
|
|
18
|
+
|
|
19
|
+
class Environment;
|
|
20
|
+
class ExternalReferenceRegistry;
|
|
21
|
+
|
|
22
|
+
namespace performance {
|
|
23
|
+
|
|
24
|
+
inline const char* GetPerformanceMilestoneName(
|
|
25
|
+
PerformanceMilestone milestone) {
|
|
26
|
+
switch (milestone) {
|
|
27
|
+
#define V(name, label) case NODE_PERFORMANCE_MILESTONE_##name: return label;
|
|
28
|
+
NODE_PERFORMANCE_MILESTONES(V)
|
|
29
|
+
#undef V
|
|
30
|
+
default:
|
|
31
|
+
UNREACHABLE();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
inline PerformanceMilestone ToPerformanceMilestoneEnum(const char* str) {
|
|
36
|
+
#define V(name, label) \
|
|
37
|
+
if (strcmp(str, label) == 0) return NODE_PERFORMANCE_MILESTONE_##name;
|
|
38
|
+
NODE_PERFORMANCE_MILESTONES(V)
|
|
39
|
+
#undef V
|
|
40
|
+
return NODE_PERFORMANCE_MILESTONE_INVALID;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
inline const char* GetPerformanceEntryTypeName(
|
|
44
|
+
PerformanceEntryType type) {
|
|
45
|
+
switch (type) {
|
|
46
|
+
#define V(name, label) case NODE_PERFORMANCE_ENTRY_TYPE_##name: return label;
|
|
47
|
+
NODE_PERFORMANCE_ENTRY_TYPES(V)
|
|
48
|
+
#undef V
|
|
49
|
+
default:
|
|
50
|
+
UNREACHABLE();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
inline PerformanceEntryType ToPerformanceEntryTypeEnum(
|
|
55
|
+
const char* type) {
|
|
56
|
+
#define V(name, label) \
|
|
57
|
+
if (strcmp(type, label) == 0) return NODE_PERFORMANCE_ENTRY_TYPE_##name;
|
|
58
|
+
NODE_PERFORMANCE_ENTRY_TYPES(V)
|
|
59
|
+
#undef V
|
|
60
|
+
return NODE_PERFORMANCE_ENTRY_TYPE_INVALID;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
enum PerformanceGCKind {
|
|
64
|
+
NODE_PERFORMANCE_GC_MAJOR = v8::GCType::kGCTypeMarkSweepCompact,
|
|
65
|
+
NODE_PERFORMANCE_GC_MINOR = v8::GCType::kGCTypeScavenge,
|
|
66
|
+
NODE_PERFORMANCE_GC_INCREMENTAL = v8::GCType::kGCTypeIncrementalMarking,
|
|
67
|
+
NODE_PERFORMANCE_GC_WEAKCB = v8::GCType::kGCTypeProcessWeakCallbacks
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
enum PerformanceGCFlags {
|
|
71
|
+
NODE_PERFORMANCE_GC_FLAGS_NO =
|
|
72
|
+
v8::GCCallbackFlags::kNoGCCallbackFlags,
|
|
73
|
+
NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED =
|
|
74
|
+
v8::GCCallbackFlags::kGCCallbackFlagConstructRetainedObjectInfos,
|
|
75
|
+
NODE_PERFORMANCE_GC_FLAGS_FORCED =
|
|
76
|
+
v8::GCCallbackFlags::kGCCallbackFlagForced,
|
|
77
|
+
NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING =
|
|
78
|
+
v8::GCCallbackFlags::kGCCallbackFlagSynchronousPhantomCallbackProcessing,
|
|
79
|
+
NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE =
|
|
80
|
+
v8::GCCallbackFlags::kGCCallbackFlagCollectAllAvailableGarbage,
|
|
81
|
+
NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY =
|
|
82
|
+
v8::GCCallbackFlags::kGCCallbackFlagCollectAllExternalMemory,
|
|
83
|
+
NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE =
|
|
84
|
+
v8::GCCallbackFlags::kGCCallbackScheduleIdleGarbageCollection
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
template <typename Traits>
|
|
88
|
+
struct PerformanceEntry {
|
|
89
|
+
using Details = typename Traits::Details;
|
|
90
|
+
std::string name;
|
|
91
|
+
double start_time;
|
|
92
|
+
double duration;
|
|
93
|
+
Details details;
|
|
94
|
+
|
|
95
|
+
PerformanceEntry(
|
|
96
|
+
const std::string& name_,
|
|
97
|
+
double start_time_,
|
|
98
|
+
double duration_,
|
|
99
|
+
const Details& details_)
|
|
100
|
+
: name(name_),
|
|
101
|
+
start_time(start_time_),
|
|
102
|
+
duration(duration_),
|
|
103
|
+
details(details_) {}
|
|
104
|
+
|
|
105
|
+
static v8::MaybeLocal<v8::Object> GetDetails(
|
|
106
|
+
Environment* env,
|
|
107
|
+
const PerformanceEntry<Traits>& entry) {
|
|
108
|
+
return Traits::GetDetails(env, entry);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void Notify(Environment* env) {
|
|
112
|
+
v8::HandleScope handle_scope(env->isolate());
|
|
113
|
+
v8::Context::Scope scope(env->context());
|
|
114
|
+
AliasedUint32Array& observers = env->performance_state()->observers;
|
|
115
|
+
if (env->performance_entry_callback().IsEmpty() ||
|
|
116
|
+
!observers[Traits::kType]) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
v8::Local<v8::Object> detail;
|
|
121
|
+
if (!Traits::GetDetails(env, *this).ToLocal(&detail)) {
|
|
122
|
+
// TODO(@jasnell): Handle the error here
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
v8::Local<v8::Value> argv[] = {
|
|
127
|
+
OneByteString(env->isolate(), name.c_str()),
|
|
128
|
+
OneByteString(env->isolate(), GetPerformanceEntryTypeName(Traits::kType)),
|
|
129
|
+
v8::Number::New(env->isolate(), start_time),
|
|
130
|
+
v8::Number::New(env->isolate(), duration),
|
|
131
|
+
detail
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
node::MakeSyncCallback(
|
|
135
|
+
env->isolate(),
|
|
136
|
+
env->context()->Global(),
|
|
137
|
+
env->performance_entry_callback(),
|
|
138
|
+
arraysize(argv),
|
|
139
|
+
argv);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
struct GCPerformanceEntryTraits {
|
|
144
|
+
static constexpr PerformanceEntryType kType =
|
|
145
|
+
NODE_PERFORMANCE_ENTRY_TYPE_GC;
|
|
146
|
+
struct Details {
|
|
147
|
+
PerformanceGCKind kind;
|
|
148
|
+
PerformanceGCFlags flags;
|
|
149
|
+
|
|
150
|
+
Details(PerformanceGCKind kind_, PerformanceGCFlags flags_)
|
|
151
|
+
: kind(kind_), flags(flags_) {}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
static v8::MaybeLocal<v8::Object> GetDetails(
|
|
155
|
+
Environment* env,
|
|
156
|
+
const PerformanceEntry<GCPerformanceEntryTraits>& entry);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
using GCPerformanceEntry = PerformanceEntry<GCPerformanceEntryTraits>;
|
|
160
|
+
|
|
161
|
+
} // namespace performance
|
|
162
|
+
} // namespace node
|
|
163
|
+
|
|
164
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
165
|
+
|
|
166
|
+
#endif // SRC_NODE_PERF_H_
|