@encharm/cws 4.3.0 → 4.4.0
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 +55 -90
- 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 +29 -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 +416 -0
- package/src/headers/20/crypto/crypto_tls.h +295 -0
- package/src/headers/20/crypto/crypto_util.h +805 -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 +444 -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 +591 -0
- package/src/headers/20/js_native_api_types.h +168 -0
- package/src/headers/20/js_native_api_v8.h +426 -0
- package/src/headers/20/js_native_api_v8_internals.h +39 -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 +1514 -0
- package/src/headers/20/node_api.h +260 -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 +79 -0
- package/src/headers/20/node_context_data.h +98 -0
- package/src/headers/20/node_contextify.h +182 -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 +357 -0
- package/src/headers/20/node_file.h +524 -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 +28 -0
- package/src/headers/20/permission/fs_permission.h +152 -0
- package/src/headers/20/permission/permission.h +71 -0
- package/src/headers/20/permission/permission_base.h +49 -0
- package/src/headers/20/permission/worker_permission.h +28 -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/trace_event.h +720 -0
- package/src/headers/20/tracing/trace_event_common.h +1109 -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,81 @@
|
|
|
1
|
+
|
|
2
|
+
#ifndef SRC_NODE_UNION_BYTES_H_
|
|
3
|
+
#define SRC_NODE_UNION_BYTES_H_
|
|
4
|
+
|
|
5
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
6
|
+
|
|
7
|
+
#include "v8.h"
|
|
8
|
+
|
|
9
|
+
namespace node {
|
|
10
|
+
|
|
11
|
+
// An external resource intended to be used with static lifetime.
|
|
12
|
+
template <typename Char, typename IChar, typename Base>
|
|
13
|
+
class StaticExternalByteResource : public Base {
|
|
14
|
+
static_assert(sizeof(IChar) == sizeof(Char),
|
|
15
|
+
"incompatible interface and internal pointers");
|
|
16
|
+
|
|
17
|
+
public:
|
|
18
|
+
explicit StaticExternalByteResource(const Char* data,
|
|
19
|
+
size_t length,
|
|
20
|
+
std::shared_ptr<void> owning_ptr)
|
|
21
|
+
: data_(data), length_(length), owning_ptr_(owning_ptr) {}
|
|
22
|
+
|
|
23
|
+
const IChar* data() const override {
|
|
24
|
+
return reinterpret_cast<const IChar*>(data_);
|
|
25
|
+
}
|
|
26
|
+
size_t length() const override { return length_; }
|
|
27
|
+
|
|
28
|
+
void Dispose() override {
|
|
29
|
+
// We ignore Dispose calls from V8, even if we "own" a resource via
|
|
30
|
+
// owning_ptr_. All instantiations of this class are static or owned by a
|
|
31
|
+
// static map, and will be destructed when static variables are destructed.
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
StaticExternalByteResource(const StaticExternalByteResource&) = delete;
|
|
35
|
+
StaticExternalByteResource& operator=(const StaticExternalByteResource&) =
|
|
36
|
+
delete;
|
|
37
|
+
|
|
38
|
+
private:
|
|
39
|
+
const Char* data_;
|
|
40
|
+
const size_t length_;
|
|
41
|
+
std::shared_ptr<void> owning_ptr_;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
using StaticExternalOneByteResource =
|
|
45
|
+
StaticExternalByteResource<uint8_t,
|
|
46
|
+
char,
|
|
47
|
+
v8::String::ExternalOneByteStringResource>;
|
|
48
|
+
using StaticExternalTwoByteResource =
|
|
49
|
+
StaticExternalByteResource<uint16_t,
|
|
50
|
+
uint16_t,
|
|
51
|
+
v8::String::ExternalStringResource>;
|
|
52
|
+
|
|
53
|
+
// Similar to a v8::String, but it's independent from Isolates
|
|
54
|
+
// and can be materialized in Isolates as external Strings
|
|
55
|
+
// via ToStringChecked.
|
|
56
|
+
class UnionBytes {
|
|
57
|
+
public:
|
|
58
|
+
explicit UnionBytes(StaticExternalOneByteResource* one_byte_resource)
|
|
59
|
+
: one_byte_resource_(one_byte_resource), two_byte_resource_(nullptr) {}
|
|
60
|
+
explicit UnionBytes(StaticExternalTwoByteResource* two_byte_resource)
|
|
61
|
+
: one_byte_resource_(nullptr), two_byte_resource_(two_byte_resource) {}
|
|
62
|
+
|
|
63
|
+
UnionBytes(const UnionBytes&) = default;
|
|
64
|
+
UnionBytes& operator=(const UnionBytes&) = default;
|
|
65
|
+
UnionBytes(UnionBytes&&) = default;
|
|
66
|
+
UnionBytes& operator=(UnionBytes&&) = default;
|
|
67
|
+
|
|
68
|
+
bool is_one_byte() const { return one_byte_resource_ != nullptr; }
|
|
69
|
+
|
|
70
|
+
v8::Local<v8::String> ToStringChecked(v8::Isolate* isolate) const;
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
StaticExternalOneByteResource* one_byte_resource_;
|
|
74
|
+
StaticExternalTwoByteResource* two_byte_resource_;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace node
|
|
78
|
+
|
|
79
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
80
|
+
|
|
81
|
+
#endif // SRC_NODE_UNION_BYTES_H_
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#ifndef SRC_NODE_URL_H_
|
|
2
|
+
#define SRC_NODE_URL_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include <cinttypes>
|
|
7
|
+
#include "ada.h"
|
|
8
|
+
#include "aliased_buffer.h"
|
|
9
|
+
#include "node.h"
|
|
10
|
+
#include "node_snapshotable.h"
|
|
11
|
+
#include "util.h"
|
|
12
|
+
#include "v8-fast-api-calls.h"
|
|
13
|
+
#include "v8.h"
|
|
14
|
+
|
|
15
|
+
#include <string>
|
|
16
|
+
|
|
17
|
+
namespace node {
|
|
18
|
+
class ExternalReferenceRegistry;
|
|
19
|
+
|
|
20
|
+
namespace url {
|
|
21
|
+
|
|
22
|
+
enum url_update_action {
|
|
23
|
+
kProtocol = 0,
|
|
24
|
+
kHost = 1,
|
|
25
|
+
kHostname = 2,
|
|
26
|
+
kPort = 3,
|
|
27
|
+
kUsername = 4,
|
|
28
|
+
kPassword = 5,
|
|
29
|
+
kPathname = 6,
|
|
30
|
+
kSearch = 7,
|
|
31
|
+
kHash = 8,
|
|
32
|
+
kHref = 9,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
class BindingData : public SnapshotableObject {
|
|
36
|
+
public:
|
|
37
|
+
BindingData(Realm* realm, v8::Local<v8::Object> obj);
|
|
38
|
+
|
|
39
|
+
using InternalFieldInfo = InternalFieldInfoBase;
|
|
40
|
+
|
|
41
|
+
SERIALIZABLE_OBJECT_METHODS()
|
|
42
|
+
SET_BINDING_ID(url_binding_data)
|
|
43
|
+
|
|
44
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
45
|
+
SET_SELF_SIZE(BindingData)
|
|
46
|
+
SET_MEMORY_INFO_NAME(BindingData)
|
|
47
|
+
|
|
48
|
+
static void DomainToASCII(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
49
|
+
static void DomainToUnicode(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
50
|
+
|
|
51
|
+
static void CanParse(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
52
|
+
static bool FastCanParse(v8::Local<v8::Value> receiver,
|
|
53
|
+
const v8::FastOneByteString& input);
|
|
54
|
+
static bool FastCanParseWithBase(v8::Local<v8::Value> receiver,
|
|
55
|
+
const v8::FastOneByteString& input,
|
|
56
|
+
const v8::FastOneByteString& base);
|
|
57
|
+
|
|
58
|
+
static void Format(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
59
|
+
static void GetOrigin(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
60
|
+
static void Parse(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
61
|
+
static void Update(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
62
|
+
|
|
63
|
+
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
|
64
|
+
v8::Local<v8::ObjectTemplate> ctor);
|
|
65
|
+
static void CreatePerContextProperties(v8::Local<v8::Object> target,
|
|
66
|
+
v8::Local<v8::Value> unused,
|
|
67
|
+
v8::Local<v8::Context> context,
|
|
68
|
+
void* priv);
|
|
69
|
+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
70
|
+
|
|
71
|
+
private:
|
|
72
|
+
static constexpr size_t kURLComponentsLength = 9;
|
|
73
|
+
AliasedUint32Array url_components_buffer_;
|
|
74
|
+
|
|
75
|
+
void UpdateComponents(const ada::url_components& components,
|
|
76
|
+
const ada::scheme::type type);
|
|
77
|
+
|
|
78
|
+
static v8::CFunction fast_can_parse_methods_[];
|
|
79
|
+
static void ThrowInvalidURL(Environment* env,
|
|
80
|
+
std::string_view input,
|
|
81
|
+
std::optional<std::string> base);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
std::string FromFilePath(const std::string_view file_path);
|
|
85
|
+
|
|
86
|
+
} // namespace url
|
|
87
|
+
|
|
88
|
+
} // namespace node
|
|
89
|
+
|
|
90
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
91
|
+
|
|
92
|
+
#endif // SRC_NODE_URL_H_
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#ifndef SRC_NODE_V8_H_
|
|
2
|
+
#define SRC_NODE_V8_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include <sstream>
|
|
7
|
+
#include "aliased_buffer.h"
|
|
8
|
+
#include "base_object.h"
|
|
9
|
+
#include "json_utils.h"
|
|
10
|
+
#include "node_snapshotable.h"
|
|
11
|
+
#include "util.h"
|
|
12
|
+
#include "v8.h"
|
|
13
|
+
|
|
14
|
+
namespace node {
|
|
15
|
+
class Environment;
|
|
16
|
+
struct InternalFieldInfoBase;
|
|
17
|
+
|
|
18
|
+
namespace v8_utils {
|
|
19
|
+
class BindingData : public SnapshotableObject {
|
|
20
|
+
public:
|
|
21
|
+
struct InternalFieldInfo : public node::InternalFieldInfoBase {
|
|
22
|
+
AliasedBufferIndex heap_statistics_buffer;
|
|
23
|
+
AliasedBufferIndex heap_space_statistics_buffer;
|
|
24
|
+
AliasedBufferIndex heap_code_statistics_buffer;
|
|
25
|
+
};
|
|
26
|
+
BindingData(Realm* realm,
|
|
27
|
+
v8::Local<v8::Object> obj,
|
|
28
|
+
InternalFieldInfo* info = nullptr);
|
|
29
|
+
|
|
30
|
+
SERIALIZABLE_OBJECT_METHODS()
|
|
31
|
+
SET_BINDING_ID(v8_binding_data)
|
|
32
|
+
|
|
33
|
+
AliasedFloat64Array heap_statistics_buffer;
|
|
34
|
+
AliasedFloat64Array heap_space_statistics_buffer;
|
|
35
|
+
AliasedFloat64Array heap_code_statistics_buffer;
|
|
36
|
+
|
|
37
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
38
|
+
SET_SELF_SIZE(BindingData)
|
|
39
|
+
SET_MEMORY_INFO_NAME(BindingData)
|
|
40
|
+
|
|
41
|
+
private:
|
|
42
|
+
InternalFieldInfo* internal_field_info_ = nullptr;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
class GCProfiler : public BaseObject {
|
|
46
|
+
public:
|
|
47
|
+
enum class GCProfilerState { kInitialized, kStarted, kStopped };
|
|
48
|
+
GCProfiler(Environment* env, v8::Local<v8::Object> object);
|
|
49
|
+
inline ~GCProfiler() override;
|
|
50
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
51
|
+
static void Start(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
52
|
+
static void Stop(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
53
|
+
|
|
54
|
+
JSONWriter* writer();
|
|
55
|
+
|
|
56
|
+
std::ostringstream* out_stream();
|
|
57
|
+
|
|
58
|
+
SET_NO_MEMORY_INFO()
|
|
59
|
+
SET_MEMORY_INFO_NAME(GCProfiler)
|
|
60
|
+
SET_SELF_SIZE(GCProfiler)
|
|
61
|
+
|
|
62
|
+
uint64_t start_time;
|
|
63
|
+
uint8_t current_gc_type;
|
|
64
|
+
GCProfilerState state;
|
|
65
|
+
|
|
66
|
+
private:
|
|
67
|
+
std::ostringstream out_stream_;
|
|
68
|
+
JSONWriter writer_;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
} // namespace v8_utils
|
|
72
|
+
|
|
73
|
+
} // namespace node
|
|
74
|
+
|
|
75
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
76
|
+
|
|
77
|
+
#endif // SRC_NODE_V8_H_
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
#ifndef SRC_NODE_V8_PLATFORM_INL_H_
|
|
2
|
+
#define SRC_NODE_V8_PLATFORM_INL_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <string_view>
|
|
8
|
+
|
|
9
|
+
#include "env-inl.h"
|
|
10
|
+
#include "node.h"
|
|
11
|
+
#include "node_metadata.h"
|
|
12
|
+
#include "node_platform.h"
|
|
13
|
+
#include "node_options.h"
|
|
14
|
+
#include "tracing/node_trace_writer.h"
|
|
15
|
+
#include "tracing/trace_event.h"
|
|
16
|
+
#include "tracing/traced_value.h"
|
|
17
|
+
#include "util.h"
|
|
18
|
+
|
|
19
|
+
namespace node {
|
|
20
|
+
|
|
21
|
+
// Ensures that __metadata trace events are only emitted
|
|
22
|
+
// when tracing is enabled.
|
|
23
|
+
class NodeTraceStateObserver
|
|
24
|
+
: public v8::TracingController::TraceStateObserver {
|
|
25
|
+
public:
|
|
26
|
+
inline void OnTraceEnabled() override {
|
|
27
|
+
std::string title = GetProcessTitle("");
|
|
28
|
+
if (!title.empty()) {
|
|
29
|
+
// Only emit the metadata event if the title can be retrieved
|
|
30
|
+
// successfully. Ignore it otherwise.
|
|
31
|
+
TRACE_EVENT_METADATA1(
|
|
32
|
+
"__metadata", "process_name", "name", TRACE_STR_COPY(title.c_str()));
|
|
33
|
+
}
|
|
34
|
+
TRACE_EVENT_METADATA1("__metadata",
|
|
35
|
+
"version",
|
|
36
|
+
"node",
|
|
37
|
+
per_process::metadata.versions.node.c_str());
|
|
38
|
+
TRACE_EVENT_METADATA1(
|
|
39
|
+
"__metadata", "thread_name", "name", "JavaScriptMainThread");
|
|
40
|
+
|
|
41
|
+
auto trace_process = tracing::TracedValue::Create();
|
|
42
|
+
trace_process->BeginDictionary("versions");
|
|
43
|
+
|
|
44
|
+
#define V(key) \
|
|
45
|
+
trace_process->SetString(#key, per_process::metadata.versions.key.c_str());
|
|
46
|
+
|
|
47
|
+
NODE_VERSIONS_KEYS(V)
|
|
48
|
+
#undef V
|
|
49
|
+
|
|
50
|
+
trace_process->EndDictionary();
|
|
51
|
+
|
|
52
|
+
trace_process->SetString("arch", per_process::metadata.arch.c_str());
|
|
53
|
+
trace_process->SetString("platform",
|
|
54
|
+
per_process::metadata.platform.c_str());
|
|
55
|
+
|
|
56
|
+
trace_process->BeginDictionary("release");
|
|
57
|
+
trace_process->SetString("name",
|
|
58
|
+
per_process::metadata.release.name.c_str());
|
|
59
|
+
#if NODE_VERSION_IS_LTS
|
|
60
|
+
trace_process->SetString("lts", per_process::metadata.release.lts.c_str());
|
|
61
|
+
#endif
|
|
62
|
+
trace_process->EndDictionary();
|
|
63
|
+
TRACE_EVENT_METADATA1(
|
|
64
|
+
"__metadata", "node", "process", std::move(trace_process));
|
|
65
|
+
|
|
66
|
+
// This only runs the first time tracing is enabled
|
|
67
|
+
controller_->RemoveTraceStateObserver(this);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
inline void OnTraceDisabled() override {
|
|
71
|
+
// Do nothing here. This should never be called because the
|
|
72
|
+
// observer removes itself when OnTraceEnabled() is called.
|
|
73
|
+
UNREACHABLE();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
explicit NodeTraceStateObserver(v8::TracingController* controller)
|
|
77
|
+
: controller_(controller) {}
|
|
78
|
+
~NodeTraceStateObserver() override = default;
|
|
79
|
+
|
|
80
|
+
private:
|
|
81
|
+
v8::TracingController* controller_;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
struct V8Platform {
|
|
85
|
+
bool initialized_ = false;
|
|
86
|
+
|
|
87
|
+
#if NODE_USE_V8_PLATFORM
|
|
88
|
+
inline void Initialize(int thread_pool_size) {
|
|
89
|
+
CHECK(!initialized_);
|
|
90
|
+
initialized_ = true;
|
|
91
|
+
tracing_agent_ = std::make_unique<tracing::Agent>();
|
|
92
|
+
node::tracing::TraceEventHelper::SetAgent(tracing_agent_.get());
|
|
93
|
+
node::tracing::TracingController* controller =
|
|
94
|
+
tracing_agent_->GetTracingController();
|
|
95
|
+
trace_state_observer_ =
|
|
96
|
+
std::make_unique<NodeTraceStateObserver>(controller);
|
|
97
|
+
controller->AddTraceStateObserver(trace_state_observer_.get());
|
|
98
|
+
tracing_file_writer_ = tracing_agent_->DefaultHandle();
|
|
99
|
+
// Only start the tracing agent if we enabled any tracing categories.
|
|
100
|
+
if (!per_process::cli_options->trace_event_categories.empty()) {
|
|
101
|
+
StartTracingAgent();
|
|
102
|
+
}
|
|
103
|
+
// Tracing must be initialized before platform threads are created.
|
|
104
|
+
platform_ = new NodePlatform(thread_pool_size, controller);
|
|
105
|
+
v8::V8::InitializePlatform(platform_);
|
|
106
|
+
}
|
|
107
|
+
// Make sure V8Platform don not call into Libuv threadpool,
|
|
108
|
+
// see DefaultProcessExitHandlerInternal in environment.cc
|
|
109
|
+
inline void Dispose() {
|
|
110
|
+
if (!initialized_)
|
|
111
|
+
return;
|
|
112
|
+
initialized_ = false;
|
|
113
|
+
node::tracing::TraceEventHelper::SetAgent(nullptr);
|
|
114
|
+
StopTracingAgent();
|
|
115
|
+
platform_->Shutdown();
|
|
116
|
+
delete platform_;
|
|
117
|
+
platform_ = nullptr;
|
|
118
|
+
// Destroy tracing after the platform (and platform threads) have been
|
|
119
|
+
// stopped.
|
|
120
|
+
tracing_agent_.reset(nullptr);
|
|
121
|
+
// The observer remove itself in OnTraceEnabled
|
|
122
|
+
trace_state_observer_.reset(nullptr);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
inline void DrainVMTasks(v8::Isolate* isolate) {
|
|
126
|
+
platform_->DrainTasks(isolate);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
inline void StartTracingAgent() {
|
|
130
|
+
constexpr auto convert_to_set =
|
|
131
|
+
[](std::vector<std::string_view> categories) -> std::set<std::string> {
|
|
132
|
+
std::set<std::string> out;
|
|
133
|
+
for (const auto& s : categories) {
|
|
134
|
+
out.emplace(s);
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
};
|
|
138
|
+
// Attach a new NodeTraceWriter only if this function hasn't been called
|
|
139
|
+
// before.
|
|
140
|
+
if (tracing_file_writer_.IsDefaultHandle()) {
|
|
141
|
+
using std::string_view_literals::operator""sv;
|
|
142
|
+
const std::vector<std::string_view> categories =
|
|
143
|
+
SplitString(per_process::cli_options->trace_event_categories, ","sv);
|
|
144
|
+
|
|
145
|
+
tracing_file_writer_ = tracing_agent_->AddClient(
|
|
146
|
+
convert_to_set(categories),
|
|
147
|
+
std::unique_ptr<tracing::AsyncTraceWriter>(
|
|
148
|
+
new tracing::NodeTraceWriter(
|
|
149
|
+
per_process::cli_options->trace_event_file_pattern)),
|
|
150
|
+
tracing::Agent::kUseDefaultCategories);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
inline void StopTracingAgent() { tracing_file_writer_.reset(); }
|
|
155
|
+
|
|
156
|
+
inline tracing::AgentWriterHandle* GetTracingAgentWriter() {
|
|
157
|
+
return &tracing_file_writer_;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
inline NodePlatform* Platform() { return platform_; }
|
|
161
|
+
|
|
162
|
+
std::unique_ptr<NodeTraceStateObserver> trace_state_observer_;
|
|
163
|
+
std::unique_ptr<tracing::Agent> tracing_agent_;
|
|
164
|
+
tracing::AgentWriterHandle tracing_file_writer_;
|
|
165
|
+
NodePlatform* platform_;
|
|
166
|
+
#else // !NODE_USE_V8_PLATFORM
|
|
167
|
+
inline void Initialize(int thread_pool_size) {}
|
|
168
|
+
inline void Dispose() {}
|
|
169
|
+
inline void DrainVMTasks(v8::Isolate* isolate) {}
|
|
170
|
+
inline void StartTracingAgent() {
|
|
171
|
+
if (!per_process::cli_options->trace_event_categories.empty()) {
|
|
172
|
+
fprintf(stderr,
|
|
173
|
+
"Node compiled with NODE_USE_V8_PLATFORM=0, "
|
|
174
|
+
"so event tracing is not available.\n");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
inline void StopTracingAgent() {}
|
|
178
|
+
|
|
179
|
+
inline tracing::AgentWriterHandle* GetTracingAgentWriter() { return nullptr; }
|
|
180
|
+
|
|
181
|
+
inline NodePlatform* Platform() { return nullptr; }
|
|
182
|
+
#endif // !NODE_USE_V8_PLATFORM
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
namespace per_process {
|
|
186
|
+
extern struct V8Platform v8_platform;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
inline void StartTracingAgent() {
|
|
190
|
+
return per_process::v8_platform.StartTracingAgent();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
inline tracing::AgentWriterHandle* GetTracingAgentWriter() {
|
|
194
|
+
return per_process::v8_platform.GetTracingAgentWriter();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
inline void DisposePlatform() {
|
|
198
|
+
per_process::v8_platform.Dispose();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
} // namespace node
|
|
202
|
+
|
|
203
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
204
|
+
|
|
205
|
+
#endif // SRC_NODE_V8_PLATFORM_INL_H_
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
4
|
+
// copy of this software and associated documentation files (the
|
|
5
|
+
// "Software"), to deal in the Software without restriction, including
|
|
6
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
8
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
9
|
+
// following conditions:
|
|
10
|
+
//
|
|
11
|
+
// The above copyright notice and this permission notice shall be included
|
|
12
|
+
// in all copies or substantial portions of the Software.
|
|
13
|
+
//
|
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
15
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
17
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
19
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
20
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
#ifndef SRC_NODE_VERSION_H_
|
|
23
|
+
#define SRC_NODE_VERSION_H_
|
|
24
|
+
|
|
25
|
+
#define NODE_MAJOR_VERSION 20
|
|
26
|
+
#define NODE_MINOR_VERSION 9
|
|
27
|
+
#define NODE_PATCH_VERSION 0
|
|
28
|
+
|
|
29
|
+
#define NODE_VERSION_IS_LTS 1
|
|
30
|
+
#define NODE_VERSION_LTS_CODENAME "Iron"
|
|
31
|
+
|
|
32
|
+
#define NODE_VERSION_IS_RELEASE 1
|
|
33
|
+
|
|
34
|
+
#ifndef NODE_STRINGIFY
|
|
35
|
+
#define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)
|
|
36
|
+
#define NODE_STRINGIFY_HELPER(n) #n
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
#ifndef NODE_RELEASE
|
|
40
|
+
#define NODE_RELEASE "node"
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
#ifndef NODE_TAG
|
|
44
|
+
# if NODE_VERSION_IS_RELEASE
|
|
45
|
+
# define NODE_TAG ""
|
|
46
|
+
# else
|
|
47
|
+
# define NODE_TAG "-pre"
|
|
48
|
+
# endif
|
|
49
|
+
#else
|
|
50
|
+
// NODE_TAG is passed without quotes when rc.exe is run from msbuild
|
|
51
|
+
# define NODE_EXE_VERSION NODE_STRINGIFY(NODE_MAJOR_VERSION) "." \
|
|
52
|
+
NODE_STRINGIFY(NODE_MINOR_VERSION) "." \
|
|
53
|
+
NODE_STRINGIFY(NODE_PATCH_VERSION) \
|
|
54
|
+
NODE_STRINGIFY(NODE_TAG)
|
|
55
|
+
#endif
|
|
56
|
+
|
|
57
|
+
# define NODE_VERSION_STRING NODE_STRINGIFY(NODE_MAJOR_VERSION) "." \
|
|
58
|
+
NODE_STRINGIFY(NODE_MINOR_VERSION) "." \
|
|
59
|
+
NODE_STRINGIFY(NODE_PATCH_VERSION) \
|
|
60
|
+
NODE_TAG
|
|
61
|
+
#ifndef NODE_EXE_VERSION
|
|
62
|
+
# define NODE_EXE_VERSION NODE_VERSION_STRING
|
|
63
|
+
#endif
|
|
64
|
+
|
|
65
|
+
#define NODE_VERSION "v" NODE_VERSION_STRING
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
#define NODE_VERSION_AT_LEAST(major, minor, patch) \
|
|
69
|
+
(( (major) < NODE_MAJOR_VERSION) \
|
|
70
|
+
|| ((major) == NODE_MAJOR_VERSION && (minor) < NODE_MINOR_VERSION) \
|
|
71
|
+
|| ((major) == NODE_MAJOR_VERSION && \
|
|
72
|
+
(minor) == NODE_MINOR_VERSION && (patch) <= NODE_PATCH_VERSION))
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Node.js will refuse to load modules that weren't compiled against its own
|
|
76
|
+
* module ABI number, exposed as the process.versions.modules property.
|
|
77
|
+
*
|
|
78
|
+
* Node.js will refuse to load modules with a non-matching ABI version. The
|
|
79
|
+
* version number here should be changed whenever an ABI-incompatible API change
|
|
80
|
+
* is made in the C++ side, including in V8 or other dependencies.
|
|
81
|
+
*
|
|
82
|
+
* Node.js will not change the module version during a Major release line
|
|
83
|
+
* We will, at times update the version of V8 shipped in the release line
|
|
84
|
+
* if it can be made ABI compatible with the previous version.
|
|
85
|
+
*
|
|
86
|
+
* Embedders building Node.js can define NODE_EMBEDDER_MODULE_VERSION to
|
|
87
|
+
* override the default value of NODE_MODULE_VERSION.
|
|
88
|
+
*
|
|
89
|
+
* The registry of used NODE_MODULE_VERSION numbers is located at
|
|
90
|
+
* https://github.com/nodejs/node/blob/HEAD/doc/abi_version_registry.json
|
|
91
|
+
* Extenders, embedders and other consumers of Node.js that require ABI
|
|
92
|
+
* version matching should open a pull request to reserve a number in this
|
|
93
|
+
* registry.
|
|
94
|
+
*/
|
|
95
|
+
#if defined(NODE_EMBEDDER_MODULE_VERSION)
|
|
96
|
+
#define NODE_MODULE_VERSION NODE_EMBEDDER_MODULE_VERSION
|
|
97
|
+
#else
|
|
98
|
+
#define NODE_MODULE_VERSION 115
|
|
99
|
+
#endif
|
|
100
|
+
|
|
101
|
+
// The NAPI_VERSION provided by this version of the runtime. This is the version
|
|
102
|
+
// which the Node binary being built supports.
|
|
103
|
+
#define NAPI_VERSION 9
|
|
104
|
+
|
|
105
|
+
// Node API modules use NAPI_VERSION 8 by default if it is not explicitly
|
|
106
|
+
// specified. It must be always 8.
|
|
107
|
+
#define NODE_API_DEFAULT_MODULE_API_VERSION 8
|
|
108
|
+
|
|
109
|
+
#endif // SRC_NODE_VERSION_H_
|