@encharm/cws 4.5.2 → 4.6.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/CHANGELOG.md +9 -0
- package/CLAUDE.md +81 -0
- package/README.md +10 -5
- package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node127.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node137.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node147.node +0 -0
- package/dist/bindings/cws_linux_arm64_node115.node +0 -0
- package/dist/bindings/cws_linux_arm64_node127.node +0 -0
- package/dist/bindings/cws_linux_arm64_node137.node +0 -0
- package/dist/bindings/cws_linux_arm64_node147.node +0 -0
- package/dist/bindings/cws_linux_x64_node115.node +0 -0
- package/dist/bindings/cws_linux_x64_node127.node +0 -0
- package/dist/bindings/cws_linux_x64_node137.node +0 -0
- package/dist/bindings/cws_linux_x64_node147.node +0 -0
- package/dist/bindings/cws_win32_x64_node115.node +0 -0
- package/dist/bindings/cws_win32_x64_node127.node +0 -0
- package/dist/bindings/cws_win32_x64_node137.node +0 -0
- package/dist/bindings/cws_win32_x64_node147.node +0 -0
- package/package.json +1 -1
- package/src/Addon.cpp +2 -1
- package/src/Addon.h +70 -14
- package/src/Hub.h +1 -0
- package/src/Networking.h +11 -0
- package/src/Socket.h +201 -6
- package/src/WebSocket.cpp +4 -1
- package/src/cSNode.cpp +2 -0
- package/src/cSNode.h +4 -0
- package/src/headers/24/tracing/agent.h +195 -0
- package/src/headers/24/tracing/trace_event.h +722 -0
- package/src/headers/26/acorn_version.h +6 -0
- package/src/headers/26/aliased_buffer-inl.h +264 -0
- package/src/headers/26/aliased_buffer.h +205 -0
- package/src/headers/26/aliased_struct-inl.h +143 -0
- package/src/headers/26/aliased_struct.h +248 -0
- package/src/headers/26/amaro_version.h +6 -0
- package/src/headers/26/async_context_frame.h +33 -0
- package/src/headers/26/async_wrap-inl.h +123 -0
- package/src/headers/26/async_wrap.h +254 -0
- package/src/headers/26/base_object-inl.h +333 -0
- package/src/headers/26/base_object.h +339 -0
- package/src/headers/26/base_object_types.h +76 -0
- package/src/headers/26/blob_serializer_deserializer-inl.h +385 -0
- package/src/headers/26/blob_serializer_deserializer.h +142 -0
- package/src/headers/26/builtin_info.h +57 -0
- package/src/headers/26/callback_queue-inl.h +97 -0
- package/src/headers/26/callback_queue.h +79 -0
- package/src/headers/26/cares_wrap.h +475 -0
- package/src/headers/26/cleanup_queue-inl.h +36 -0
- package/src/headers/26/cleanup_queue.h +79 -0
- package/src/headers/26/compile_cache.h +134 -0
- package/src/headers/26/connect_wrap.h +26 -0
- package/src/headers/26/connection_wrap.h +30 -0
- package/src/headers/26/cppgc_helpers-inl.h +69 -0
- package/src/headers/26/cppgc_helpers.h +162 -0
- package/src/headers/26/crypto/crypto_aes.h +107 -0
- package/src/headers/26/crypto/crypto_argon2.h +88 -0
- package/src/headers/26/crypto/crypto_bio.h +193 -0
- package/src/headers/26/crypto/crypto_chacha20_poly1305.h +62 -0
- package/src/headers/26/crypto/crypto_cipher.h +291 -0
- package/src/headers/26/crypto/crypto_common.h +48 -0
- package/src/headers/26/crypto/crypto_context.h +219 -0
- package/src/headers/26/crypto/crypto_dh.h +104 -0
- package/src/headers/26/crypto/crypto_dsa.h +50 -0
- package/src/headers/26/crypto/crypto_ec.h +102 -0
- package/src/headers/26/crypto/crypto_hash.h +157 -0
- package/src/headers/26/crypto/crypto_hkdf.h +62 -0
- package/src/headers/26/crypto/crypto_hmac.h +92 -0
- package/src/headers/26/crypto/crypto_kem.h +131 -0
- package/src/headers/26/crypto/crypto_keygen.h +382 -0
- package/src/headers/26/crypto/crypto_keys.h +366 -0
- package/src/headers/26/crypto/crypto_kmac.h +79 -0
- package/src/headers/26/crypto/crypto_pbkdf2.h +76 -0
- package/src/headers/26/crypto/crypto_pqc.h +39 -0
- package/src/headers/26/crypto/crypto_random.h +127 -0
- package/src/headers/26/crypto/crypto_rsa.h +108 -0
- package/src/headers/26/crypto/crypto_scrypt.h +85 -0
- package/src/headers/26/crypto/crypto_sig.h +159 -0
- package/src/headers/26/crypto/crypto_spkac.h +21 -0
- package/src/headers/26/crypto/crypto_timing.h +20 -0
- package/src/headers/26/crypto/crypto_tls.h +342 -0
- package/src/headers/26/crypto/crypto_turboshake.h +105 -0
- package/src/headers/26/crypto/crypto_util.h +775 -0
- package/src/headers/26/crypto/crypto_x509.h +140 -0
- package/src/headers/26/dataqueue/queue.h +311 -0
- package/src/headers/26/debug_utils-inl.h +291 -0
- package/src/headers/26/debug_utils.h +200 -0
- package/src/headers/26/diagnosticfilename-inl.h +33 -0
- package/src/headers/26/embedded_data.h +17 -0
- package/src/headers/26/encoding_binding.h +59 -0
- package/src/headers/26/env-inl.h +956 -0
- package/src/headers/26/env.h +1294 -0
- package/src/headers/26/env_properties.h +562 -0
- package/src/headers/26/ffi/data.h +30 -0
- package/src/headers/26/ffi/fast.h +96 -0
- package/src/headers/26/ffi/jit_memory.h +26 -0
- package/src/headers/26/ffi/types.h +99 -0
- package/src/headers/26/handle_wrap.h +123 -0
- package/src/headers/26/histogram-inl.h +211 -0
- package/src/headers/26/histogram.h +474 -0
- package/src/headers/26/inspector/dom_storage_agent.h +68 -0
- package/src/headers/26/inspector/inspector_object_utils.h +38 -0
- package/src/headers/26/inspector/io_agent.h +30 -0
- package/src/headers/26/inspector/main_thread_interface.h +116 -0
- package/src/headers/26/inspector/network_agent.h +110 -0
- package/src/headers/26/inspector/network_inspector.h +45 -0
- package/src/headers/26/inspector/network_requests_buffer.h +195 -0
- package/src/headers/26/inspector/network_resource_manager.h +29 -0
- package/src/headers/26/inspector/node_json.h +24 -0
- package/src/headers/26/inspector/node_string.h +101 -0
- package/src/headers/26/inspector/notification_emitter.h +38 -0
- package/src/headers/26/inspector/protocol_helper.h +27 -0
- package/src/headers/26/inspector/runtime_agent.h +41 -0
- package/src/headers/26/inspector/storage_agent.h +33 -0
- package/src/headers/26/inspector/target_agent.h +59 -0
- package/src/headers/26/inspector/target_manager.h +70 -0
- package/src/headers/26/inspector/tracing_agent.h +43 -0
- package/src/headers/26/inspector/worker_agent.h +40 -0
- package/src/headers/26/inspector/worker_inspector.h +124 -0
- package/src/headers/26/inspector_agent.h +168 -0
- package/src/headers/26/inspector_io.h +78 -0
- package/src/headers/26/inspector_profiler.h +149 -0
- package/src/headers/26/inspector_socket.h +60 -0
- package/src/headers/26/inspector_socket_server.h +110 -0
- package/src/headers/26/js_native_api.h +634 -0
- package/src/headers/26/js_native_api_types.h +244 -0
- package/src/headers/26/js_native_api_v8.h +485 -0
- package/src/headers/26/js_native_api_v8_internals.h +45 -0
- package/src/headers/26/js_stream.h +57 -0
- package/src/headers/26/json_utils.h +172 -0
- package/src/headers/26/large_pages/node_large_page.h +34 -0
- package/src/headers/26/lru_cache-inl.h +69 -0
- package/src/headers/26/memory_tracker-inl.h +461 -0
- package/src/headers/26/memory_tracker.h +341 -0
- package/src/headers/26/module_wrap.h +231 -0
- package/src/headers/26/ncrypto.h +2008 -0
- package/src/headers/26/node.h +1693 -0
- package/src/headers/26/node_api.h +265 -0
- package/src/headers/26/node_api_internals.h +48 -0
- package/src/headers/26/node_api_types.h +58 -0
- package/src/headers/26/node_binding.h +170 -0
- package/src/headers/26/node_blob.h +160 -0
- package/src/headers/26/node_bob-inl.h +36 -0
- package/src/headers/26/node_bob.h +107 -0
- package/src/headers/26/node_buffer.h +92 -0
- package/src/headers/26/node_builtins.h +239 -0
- package/src/headers/26/node_concepts.h +46 -0
- package/src/headers/26/node_config_file.h +77 -0
- package/src/headers/26/node_constants.h +82 -0
- package/src/headers/26/node_context_data.h +171 -0
- package/src/headers/26/node_contextify.h +261 -0
- package/src/headers/26/node_crypto.h +66 -0
- package/src/headers/26/node_debug.h +30 -0
- package/src/headers/26/node_diagnostics_channel.h +121 -0
- package/src/headers/26/node_dir.h +52 -0
- package/src/headers/26/node_dotenv.h +45 -0
- package/src/headers/26/node_errors.h +378 -0
- package/src/headers/26/node_exit_code.h +54 -0
- package/src/headers/26/node_external_reference.h +171 -0
- package/src/headers/26/node_ffi.h +212 -0
- package/src/headers/26/node_file-inl.h +421 -0
- package/src/headers/26/node_file.h +561 -0
- package/src/headers/26/node_file_utils.h +39 -0
- package/src/headers/26/node_hash.h +212 -0
- package/src/headers/26/node_http2.h +1202 -0
- package/src/headers/26/node_http2_state.h +159 -0
- package/src/headers/26/node_http_common-inl.h +199 -0
- package/src/headers/26/node_http_common.h +535 -0
- package/src/headers/26/node_i18n.h +132 -0
- package/src/headers/26/node_internals.h +485 -0
- package/src/headers/26/node_locks.h +184 -0
- package/src/headers/26/node_main_instance.h +67 -0
- package/src/headers/26/node_mem-inl.h +113 -0
- package/src/headers/26/node_mem.h +45 -0
- package/src/headers/26/node_messaging.h +389 -0
- package/src/headers/26/node_metadata.h +172 -0
- package/src/headers/26/node_modules.h +102 -0
- package/src/headers/26/node_mutex.h +323 -0
- package/src/headers/26/node_object_wrap.h +145 -0
- package/src/headers/26/node_options-inl.h +524 -0
- package/src/headers/26/node_options.h +710 -0
- package/src/headers/26/node_perf.h +167 -0
- package/src/headers/26/node_perf_common.h +103 -0
- package/src/headers/26/node_platform.h +290 -0
- package/src/headers/26/node_process-inl.h +26 -0
- package/src/headers/26/node_process.h +112 -0
- package/src/headers/26/node_profiling.h +38 -0
- package/src/headers/26/node_realm-inl.h +156 -0
- package/src/headers/26/node_realm.h +236 -0
- package/src/headers/26/node_report.h +43 -0
- package/src/headers/26/node_revert.h +82 -0
- package/src/headers/26/node_root_certs.h +2937 -0
- package/src/headers/26/node_sea.h +101 -0
- package/src/headers/26/node_shadow_realm.h +46 -0
- package/src/headers/26/node_snapshot_builder.h +57 -0
- package/src/headers/26/node_snapshotable.h +167 -0
- package/src/headers/26/node_sockaddr-inl.h +248 -0
- package/src/headers/26/node_sockaddr.h +459 -0
- package/src/headers/26/node_sqlite.h +607 -0
- package/src/headers/26/node_stat_watcher.h +73 -0
- package/src/headers/26/node_task_runner.h +92 -0
- package/src/headers/26/node_threadsafe_cow-inl.h +54 -0
- package/src/headers/26/node_threadsafe_cow.h +105 -0
- package/src/headers/26/node_union_bytes.h +81 -0
- package/src/headers/26/node_url.h +101 -0
- package/src/headers/26/node_url_pattern.h +118 -0
- package/src/headers/26/node_v8.h +78 -0
- package/src/headers/26/node_v8_embedder.h +26 -0
- package/src/headers/26/node_v8_platform-inl.h +96 -0
- package/src/headers/26/node_version.h +116 -0
- package/src/headers/26/node_wasi.h +184 -0
- package/src/headers/26/node_wasm_web_api.h +55 -0
- package/src/headers/26/node_watchdog.h +164 -0
- package/src/headers/26/node_webstorage.h +62 -0
- package/src/headers/26/node_worker.h +162 -0
- package/src/headers/26/path.h +36 -0
- package/src/headers/26/permission/boolean_permission.h +50 -0
- package/src/headers/26/permission/fs_permission.h +192 -0
- package/src/headers/26/permission/permission.h +155 -0
- package/src/headers/26/permission/permission_base.h +79 -0
- package/src/headers/26/pipe_wrap.h +80 -0
- package/src/headers/26/quic/application.h +279 -0
- package/src/headers/26/quic/arena.h +373 -0
- package/src/headers/26/quic/bindingdata.h +440 -0
- package/src/headers/26/quic/cid.h +127 -0
- package/src/headers/26/quic/data.h +358 -0
- package/src/headers/26/quic/defs.h +417 -0
- package/src/headers/26/quic/endpoint.h +519 -0
- package/src/headers/26/quic/guard.h +5 -0
- package/src/headers/26/quic/http3.h +25 -0
- package/src/headers/26/quic/packet.h +166 -0
- package/src/headers/26/quic/preferredaddress.h +72 -0
- package/src/headers/26/quic/session.h +770 -0
- package/src/headers/26/quic/session_manager.h +107 -0
- package/src/headers/26/quic/sessionticket.h +110 -0
- package/src/headers/26/quic/streams.h +518 -0
- package/src/headers/26/quic/tlscontext.h +353 -0
- package/src/headers/26/quic/tokens.h +263 -0
- package/src/headers/26/quic/transportparams.h +184 -0
- package/src/headers/26/req_wrap-inl.h +175 -0
- package/src/headers/26/req_wrap.h +79 -0
- package/src/headers/26/spawn_sync.h +243 -0
- package/src/headers/26/stream_base-inl.h +170 -0
- package/src/headers/26/stream_base.h +487 -0
- package/src/headers/26/stream_pipe.h +76 -0
- package/src/headers/26/stream_wrap.h +137 -0
- package/src/headers/26/string_bytes.h +114 -0
- package/src/headers/26/string_decoder-inl.h +31 -0
- package/src/headers/26/string_decoder.h +49 -0
- package/src/headers/26/tcp_wrap.h +138 -0
- package/src/headers/26/threadpoolwork-inl.h +70 -0
- package/src/headers/26/timer_wrap-inl.h +32 -0
- package/src/headers/26/timer_wrap.h +87 -0
- package/src/headers/26/timers.h +70 -0
- package/src/headers/26/tracing/agent.h +125 -0
- package/src/headers/26/tracing/agent_legacy.h +146 -0
- package/src/headers/26/tracing/agent_perfetto.h +145 -0
- package/src/headers/26/tracing/node_trace_buffer.h +91 -0
- package/src/headers/26/tracing/node_trace_writer.h +79 -0
- package/src/headers/26/tracing/trace_event.h +27 -0
- package/src/headers/26/tracing/trace_event_helper.h +40 -0
- package/src/headers/26/tracing/trace_event_legacy.h +1113 -0
- package/src/headers/26/tracing/trace_event_legacy_inl.h +711 -0
- package/src/headers/26/tracing/trace_event_perfetto.h +47 -0
- package/src/headers/26/tracing/traced_value.h +167 -0
- package/src/headers/26/tty_wrap.h +65 -0
- package/src/headers/26/udp_wrap.h +231 -0
- package/src/headers/26/undici_version.h +6 -0
- package/src/headers/26/util-inl.h +788 -0
- package/src/headers/26/util.h +1207 -0
- package/src/headers/26/v8-cpp-heap-external.h +56 -0
- package/src/headers/26/v8-external-memory-accounter.h +60 -0
- package/src/headers/26/v8-fast-api-calls.h +784 -0
- package/src/headers/26/v8-inspector-protocol.h +13 -0
- package/src/headers/26/v8-inspector.h +458 -0
- package/src/headers/26/v8-metrics.h +273 -0
- package/src/headers/26/v8-trace-categories.h +28 -0
- package/src/headers/26/v8-unwinder-state.h +30 -0
- package/src/headers/26/v8-util.h +549 -0
- package/src/headers/26/v8-value-serializer-version.h +24 -0
- package/src/headers/26/v8-version-string.h +38 -0
- package/src/headers/26/v8-wasm-trap-handler-posix.h +31 -0
- package/src/headers/26/v8-wasm-trap-handler-win.h +28 -0
- package/src/headers/26/zlib_version.h +6 -0
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
// Copyright 2014 the V8 project authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
#ifndef V8_UTIL_H_
|
|
6
|
+
#define V8_UTIL_H_
|
|
7
|
+
|
|
8
|
+
#include <assert.h>
|
|
9
|
+
|
|
10
|
+
#include <map>
|
|
11
|
+
#include <vector>
|
|
12
|
+
|
|
13
|
+
#include "v8-function-callback.h" // NOLINT(build/include_directory)
|
|
14
|
+
#include "v8-persistent-handle.h" // NOLINT(build/include_directory)
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Support for Persistent containers.
|
|
18
|
+
*
|
|
19
|
+
* C++11 embedders can use STL containers with Global values,
|
|
20
|
+
* but pre-C++11 does not support the required move semantic and hence
|
|
21
|
+
* may want these container classes.
|
|
22
|
+
*/
|
|
23
|
+
namespace v8 {
|
|
24
|
+
|
|
25
|
+
template <typename K, typename V, typename Traits>
|
|
26
|
+
class GlobalValueMap;
|
|
27
|
+
|
|
28
|
+
typedef uintptr_t PersistentContainerValue;
|
|
29
|
+
static const uintptr_t kPersistentContainerNotFound = 0;
|
|
30
|
+
enum PersistentContainerCallbackType {
|
|
31
|
+
kNotWeak,
|
|
32
|
+
// These correspond to v8::WeakCallbackType
|
|
33
|
+
kWeakWithParameter,
|
|
34
|
+
kWeakWithInternalFields
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A default trait implementation for PersistentValueMap which uses std::map
|
|
39
|
+
* as a backing map.
|
|
40
|
+
*
|
|
41
|
+
* Users will have to implement their own weak callbacks & dispose traits.
|
|
42
|
+
*/
|
|
43
|
+
template<typename K, typename V>
|
|
44
|
+
class StdMapTraits {
|
|
45
|
+
public:
|
|
46
|
+
// STL map & related:
|
|
47
|
+
typedef std::map<K, PersistentContainerValue> Impl;
|
|
48
|
+
typedef typename Impl::iterator Iterator;
|
|
49
|
+
|
|
50
|
+
static bool Empty(Impl* impl) { return impl->empty(); }
|
|
51
|
+
static size_t Size(Impl* impl) { return impl->size(); }
|
|
52
|
+
static void Swap(Impl& a, Impl& b) { std::swap(a, b); }
|
|
53
|
+
static Iterator Begin(Impl* impl) { return impl->begin(); }
|
|
54
|
+
static Iterator End(Impl* impl) { return impl->end(); }
|
|
55
|
+
static K Key(Iterator it) { return it->first; }
|
|
56
|
+
static PersistentContainerValue Value(Iterator it) { return it->second; }
|
|
57
|
+
static PersistentContainerValue Set(Impl* impl, K key,
|
|
58
|
+
PersistentContainerValue value) {
|
|
59
|
+
std::pair<Iterator, bool> res = impl->insert(std::make_pair(key, value));
|
|
60
|
+
PersistentContainerValue old_value = kPersistentContainerNotFound;
|
|
61
|
+
if (!res.second) {
|
|
62
|
+
old_value = res.first->second;
|
|
63
|
+
res.first->second = value;
|
|
64
|
+
}
|
|
65
|
+
return old_value;
|
|
66
|
+
}
|
|
67
|
+
static PersistentContainerValue Get(Impl* impl, K key) {
|
|
68
|
+
Iterator it = impl->find(key);
|
|
69
|
+
if (it == impl->end()) return kPersistentContainerNotFound;
|
|
70
|
+
return it->second;
|
|
71
|
+
}
|
|
72
|
+
static PersistentContainerValue Remove(Impl* impl, K key) {
|
|
73
|
+
Iterator it = impl->find(key);
|
|
74
|
+
if (it == impl->end()) return kPersistentContainerNotFound;
|
|
75
|
+
PersistentContainerValue value = it->second;
|
|
76
|
+
impl->erase(it);
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A default trait implementation for PersistentValueMap, which inherits
|
|
84
|
+
* a std:map backing map from StdMapTraits and holds non-weak persistent
|
|
85
|
+
* objects and has no special Dispose handling.
|
|
86
|
+
*
|
|
87
|
+
* You should not derive from this class, since MapType depends on the
|
|
88
|
+
* surrounding class, and hence a subclass cannot simply inherit the methods.
|
|
89
|
+
*/
|
|
90
|
+
template<typename K, typename V>
|
|
91
|
+
class DefaultPersistentValueMapTraits : public StdMapTraits<K, V> {
|
|
92
|
+
public:
|
|
93
|
+
// Weak callback & friends:
|
|
94
|
+
static const PersistentContainerCallbackType kCallbackType = kNotWeak;
|
|
95
|
+
typedef PersistentValueMap<K, V, DefaultPersistentValueMapTraits<K, V> >
|
|
96
|
+
MapType;
|
|
97
|
+
typedef void WeakCallbackDataType;
|
|
98
|
+
|
|
99
|
+
static WeakCallbackDataType* WeakCallbackParameter(
|
|
100
|
+
MapType* map, const K& key, Local<V> value) {
|
|
101
|
+
return nullptr;
|
|
102
|
+
}
|
|
103
|
+
static MapType* MapFromWeakCallbackInfo(
|
|
104
|
+
const WeakCallbackInfo<WeakCallbackDataType>& data) {
|
|
105
|
+
return nullptr;
|
|
106
|
+
}
|
|
107
|
+
static K KeyFromWeakCallbackInfo(
|
|
108
|
+
const WeakCallbackInfo<WeakCallbackDataType>& data) {
|
|
109
|
+
return K();
|
|
110
|
+
}
|
|
111
|
+
static void DisposeCallbackData(WeakCallbackDataType* data) { }
|
|
112
|
+
static void Dispose(Isolate* isolate, Global<V> value, K key) {}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
template <typename K, typename V>
|
|
117
|
+
class DefaultGlobalMapTraits : public StdMapTraits<K, V> {
|
|
118
|
+
private:
|
|
119
|
+
template <typename T>
|
|
120
|
+
struct RemovePointer;
|
|
121
|
+
|
|
122
|
+
public:
|
|
123
|
+
// Weak callback & friends:
|
|
124
|
+
static const PersistentContainerCallbackType kCallbackType = kNotWeak;
|
|
125
|
+
typedef GlobalValueMap<K, V, DefaultGlobalMapTraits<K, V> > MapType;
|
|
126
|
+
typedef void WeakCallbackDataType;
|
|
127
|
+
|
|
128
|
+
static WeakCallbackDataType* WeakCallbackParameter(MapType* map, const K& key,
|
|
129
|
+
Local<V> value) {
|
|
130
|
+
return nullptr;
|
|
131
|
+
}
|
|
132
|
+
static MapType* MapFromWeakCallbackInfo(
|
|
133
|
+
const WeakCallbackInfo<WeakCallbackDataType>& data) {
|
|
134
|
+
return nullptr;
|
|
135
|
+
}
|
|
136
|
+
static K KeyFromWeakCallbackInfo(
|
|
137
|
+
const WeakCallbackInfo<WeakCallbackDataType>& data) {
|
|
138
|
+
return K();
|
|
139
|
+
}
|
|
140
|
+
static void DisposeCallbackData(WeakCallbackDataType* data) {}
|
|
141
|
+
static void OnWeakCallback(
|
|
142
|
+
const WeakCallbackInfo<WeakCallbackDataType>& data) {}
|
|
143
|
+
static void Dispose(Isolate* isolate, Global<V> value, K key) {}
|
|
144
|
+
// This is a second pass callback, so SetSecondPassCallback cannot be called.
|
|
145
|
+
static void DisposeWeak(const WeakCallbackInfo<WeakCallbackDataType>& data) {}
|
|
146
|
+
|
|
147
|
+
private:
|
|
148
|
+
template <typename T>
|
|
149
|
+
struct RemovePointer<T*> {
|
|
150
|
+
typedef T Type;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A map wrapper that allows using Global as a mapped value.
|
|
157
|
+
* C++11 embedders don't need this class, as they can use Global
|
|
158
|
+
* directly in std containers.
|
|
159
|
+
*
|
|
160
|
+
* The map relies on a backing map, whose type and accessors are described
|
|
161
|
+
* by the Traits class. The backing map will handle values of type
|
|
162
|
+
* PersistentContainerValue, with all conversion into and out of V8
|
|
163
|
+
* handles being transparently handled by this class.
|
|
164
|
+
*/
|
|
165
|
+
template <typename K, typename V, typename Traits>
|
|
166
|
+
class PersistentValueMapBase {
|
|
167
|
+
public:
|
|
168
|
+
Isolate* GetIsolate() { return isolate_; }
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Return size of the map.
|
|
172
|
+
*/
|
|
173
|
+
size_t Size() { return Traits::Size(&impl_); }
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Return whether the map holds weak persistents.
|
|
177
|
+
*/
|
|
178
|
+
bool IsWeak() { return Traits::kCallbackType != kNotWeak; }
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Get value stored in map.
|
|
182
|
+
*/
|
|
183
|
+
Local<V> Get(const K& key) {
|
|
184
|
+
V* p = FromVal(Traits::Get(&impl_, key));
|
|
185
|
+
#ifdef V8_ENABLE_DIRECT_HANDLE
|
|
186
|
+
if (p == nullptr) return Local<V>();
|
|
187
|
+
#endif
|
|
188
|
+
return Local<V>::New(isolate_, p);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Check whether a value is contained in the map.
|
|
193
|
+
*/
|
|
194
|
+
bool Contains(const K& key) {
|
|
195
|
+
return Traits::Get(&impl_, key) != kPersistentContainerNotFound;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Get value stored in map and set it in returnValue.
|
|
200
|
+
* Return true if a value was found.
|
|
201
|
+
*/
|
|
202
|
+
bool SetReturnValue(const K& key,
|
|
203
|
+
ReturnValue<Value> returnValue) {
|
|
204
|
+
return SetReturnValueFromVal(&returnValue, Traits::Get(&impl_, key));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Return value for key and remove it from the map.
|
|
209
|
+
*/
|
|
210
|
+
Global<V> Remove(const K& key) {
|
|
211
|
+
return Release(Traits::Remove(&impl_, key)).Pass();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Traverses the map repeatedly,
|
|
216
|
+
* in case side effects of disposal cause insertions.
|
|
217
|
+
**/
|
|
218
|
+
void Clear() {
|
|
219
|
+
typedef typename Traits::Iterator It;
|
|
220
|
+
HandleScope handle_scope(isolate_);
|
|
221
|
+
// TODO(dcarney): figure out if this swap and loop is necessary.
|
|
222
|
+
while (!Traits::Empty(&impl_)) {
|
|
223
|
+
typename Traits::Impl impl;
|
|
224
|
+
Traits::Swap(impl_, impl);
|
|
225
|
+
for (It i = Traits::Begin(&impl); i != Traits::End(&impl); ++i) {
|
|
226
|
+
Traits::Dispose(isolate_, Release(Traits::Value(i)).Pass(),
|
|
227
|
+
Traits::Key(i));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Helper class for GetReference/SetWithReference. Do not use outside
|
|
234
|
+
* that context.
|
|
235
|
+
*/
|
|
236
|
+
class PersistentValueReference {
|
|
237
|
+
public:
|
|
238
|
+
PersistentValueReference() : value_(kPersistentContainerNotFound) { }
|
|
239
|
+
PersistentValueReference(const PersistentValueReference& other)
|
|
240
|
+
: value_(other.value_) { }
|
|
241
|
+
|
|
242
|
+
Local<V> NewLocal(Isolate* isolate) const {
|
|
243
|
+
return Local<V>::New(isolate,
|
|
244
|
+
internal::ValueHelper::SlotAsValue<V>(
|
|
245
|
+
reinterpret_cast<internal::Address*>(value_)));
|
|
246
|
+
}
|
|
247
|
+
bool IsEmpty() const {
|
|
248
|
+
return value_ == kPersistentContainerNotFound;
|
|
249
|
+
}
|
|
250
|
+
template<typename T>
|
|
251
|
+
bool SetReturnValue(ReturnValue<T> returnValue) {
|
|
252
|
+
return SetReturnValueFromVal(&returnValue, value_);
|
|
253
|
+
}
|
|
254
|
+
void Reset() {
|
|
255
|
+
value_ = kPersistentContainerNotFound;
|
|
256
|
+
}
|
|
257
|
+
void operator=(const PersistentValueReference& other) {
|
|
258
|
+
value_ = other.value_;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
private:
|
|
262
|
+
friend class PersistentValueMapBase;
|
|
263
|
+
friend class PersistentValueMap<K, V, Traits>;
|
|
264
|
+
friend class GlobalValueMap<K, V, Traits>;
|
|
265
|
+
|
|
266
|
+
explicit PersistentValueReference(PersistentContainerValue value)
|
|
267
|
+
: value_(value) { }
|
|
268
|
+
|
|
269
|
+
void operator=(PersistentContainerValue value) {
|
|
270
|
+
value_ = value;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
PersistentContainerValue value_;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Get a reference to a map value. This enables fast, repeated access
|
|
278
|
+
* to a value stored in the map while the map remains unchanged.
|
|
279
|
+
*
|
|
280
|
+
* Careful: This is potentially unsafe, so please use with care.
|
|
281
|
+
* The value will become invalid if the value for this key changes
|
|
282
|
+
* in the underlying map, as a result of Set or Remove for the same
|
|
283
|
+
* key; as a result of the weak callback for the same key; or as a
|
|
284
|
+
* result of calling Clear() or destruction of the map.
|
|
285
|
+
*/
|
|
286
|
+
PersistentValueReference GetReference(const K& key) {
|
|
287
|
+
return PersistentValueReference(Traits::Get(&impl_, key));
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
protected:
|
|
291
|
+
explicit PersistentValueMapBase(Isolate* isolate)
|
|
292
|
+
: isolate_(isolate), label_(nullptr) {}
|
|
293
|
+
PersistentValueMapBase(Isolate* isolate, const char* label)
|
|
294
|
+
: isolate_(isolate), label_(label) {}
|
|
295
|
+
|
|
296
|
+
~PersistentValueMapBase() { Clear(); }
|
|
297
|
+
|
|
298
|
+
Isolate* isolate() { return isolate_; }
|
|
299
|
+
typename Traits::Impl* impl() { return &impl_; }
|
|
300
|
+
|
|
301
|
+
static V* FromVal(PersistentContainerValue v) {
|
|
302
|
+
return internal::ValueHelper::SlotAsValue<V>(
|
|
303
|
+
reinterpret_cast<internal::Address*>(v));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
static PersistentContainerValue ClearAndLeak(Global<V>* persistent) {
|
|
307
|
+
internal::Address* address = persistent->slot();
|
|
308
|
+
persistent->Clear();
|
|
309
|
+
return reinterpret_cast<PersistentContainerValue>(address);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
static PersistentContainerValue Leak(Global<V>* persistent) {
|
|
313
|
+
return reinterpret_cast<PersistentContainerValue>(persistent->slot());
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Return a container value as Global and make sure the weak
|
|
318
|
+
* callback is properly disposed of. All remove functionality should go
|
|
319
|
+
* through this.
|
|
320
|
+
*/
|
|
321
|
+
static Global<V> Release(PersistentContainerValue v) {
|
|
322
|
+
Global<V> p;
|
|
323
|
+
p.slot() = reinterpret_cast<internal::Address*>(v);
|
|
324
|
+
if (Traits::kCallbackType != kNotWeak && p.IsWeak()) {
|
|
325
|
+
Traits::DisposeCallbackData(
|
|
326
|
+
p.template ClearWeak<typename Traits::WeakCallbackDataType>());
|
|
327
|
+
}
|
|
328
|
+
return p.Pass();
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
void RemoveWeak(const K& key) {
|
|
332
|
+
Global<V> p;
|
|
333
|
+
p.slot() =
|
|
334
|
+
reinterpret_cast<internal::Address*>(Traits::Remove(&impl_, key));
|
|
335
|
+
p.Reset();
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
void AnnotateStrongRetainer(Global<V>* persistent) {
|
|
339
|
+
persistent->AnnotateStrongRetainer(label_);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
private:
|
|
343
|
+
PersistentValueMapBase(PersistentValueMapBase&);
|
|
344
|
+
void operator=(PersistentValueMapBase&);
|
|
345
|
+
|
|
346
|
+
static bool SetReturnValueFromVal(ReturnValue<Value>* returnValue,
|
|
347
|
+
PersistentContainerValue value) {
|
|
348
|
+
bool hasValue = value != kPersistentContainerNotFound;
|
|
349
|
+
if (hasValue) {
|
|
350
|
+
returnValue->SetInternal(*reinterpret_cast<internal::Address*>(value));
|
|
351
|
+
}
|
|
352
|
+
return hasValue;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
Isolate* isolate_;
|
|
356
|
+
typename Traits::Impl impl_;
|
|
357
|
+
const char* label_;
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
template <typename K, typename V, typename Traits>
|
|
361
|
+
class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> {
|
|
362
|
+
public:
|
|
363
|
+
explicit PersistentValueMap(Isolate* isolate)
|
|
364
|
+
: PersistentValueMapBase<K, V, Traits>(isolate) {}
|
|
365
|
+
PersistentValueMap(Isolate* isolate, const char* label)
|
|
366
|
+
: PersistentValueMapBase<K, V, Traits>(isolate, label) {}
|
|
367
|
+
|
|
368
|
+
typedef
|
|
369
|
+
typename PersistentValueMapBase<K, V, Traits>::PersistentValueReference
|
|
370
|
+
PersistentValueReference;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Put value into map. Depending on Traits::kIsWeak, the value will be held
|
|
374
|
+
* by the map strongly or weakly.
|
|
375
|
+
* Returns old value as Global.
|
|
376
|
+
*/
|
|
377
|
+
Global<V> Set(const K& key, Local<V> value) {
|
|
378
|
+
Global<V> persistent(this->isolate(), value);
|
|
379
|
+
return SetUnique(key, &persistent);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Put value into map, like Set(const K&, Local<V>).
|
|
384
|
+
*/
|
|
385
|
+
Global<V> Set(const K& key, Global<V> value) {
|
|
386
|
+
return SetUnique(key, &value);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Put the value into the map, and set the 'weak' callback when demanded
|
|
391
|
+
* by the Traits class.
|
|
392
|
+
*/
|
|
393
|
+
Global<V> SetUnique(const K& key, Global<V>* persistent) {
|
|
394
|
+
if (Traits::kCallbackType == kNotWeak) {
|
|
395
|
+
this->AnnotateStrongRetainer(persistent);
|
|
396
|
+
} else {
|
|
397
|
+
WeakCallbackType callback_type =
|
|
398
|
+
Traits::kCallbackType == kWeakWithInternalFields
|
|
399
|
+
? WeakCallbackType::kInternalFields
|
|
400
|
+
: WeakCallbackType::kParameter;
|
|
401
|
+
auto value = Local<V>::New(this->isolate(), *persistent);
|
|
402
|
+
persistent->template SetWeak<typename Traits::WeakCallbackDataType>(
|
|
403
|
+
Traits::WeakCallbackParameter(this, key, value), WeakCallback,
|
|
404
|
+
callback_type);
|
|
405
|
+
}
|
|
406
|
+
PersistentContainerValue old_value =
|
|
407
|
+
Traits::Set(this->impl(), key, this->ClearAndLeak(persistent));
|
|
408
|
+
return this->Release(old_value).Pass();
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Put a value into the map and update the reference.
|
|
413
|
+
* Restrictions of GetReference apply here as well.
|
|
414
|
+
*/
|
|
415
|
+
Global<V> Set(const K& key, Global<V> value,
|
|
416
|
+
PersistentValueReference* reference) {
|
|
417
|
+
*reference = this->Leak(&value);
|
|
418
|
+
return SetUnique(key, &value);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
private:
|
|
422
|
+
static void WeakCallback(
|
|
423
|
+
const WeakCallbackInfo<typename Traits::WeakCallbackDataType>& data) {
|
|
424
|
+
if (Traits::kCallbackType != kNotWeak) {
|
|
425
|
+
PersistentValueMap<K, V, Traits>* persistentValueMap =
|
|
426
|
+
Traits::MapFromWeakCallbackInfo(data);
|
|
427
|
+
K key = Traits::KeyFromWeakCallbackInfo(data);
|
|
428
|
+
Traits::Dispose(data.GetIsolate(),
|
|
429
|
+
persistentValueMap->Remove(key).Pass(), key);
|
|
430
|
+
Traits::DisposeCallbackData(data.GetParameter());
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
template <typename K, typename V, typename Traits>
|
|
437
|
+
class GlobalValueMap : public PersistentValueMapBase<K, V, Traits> {
|
|
438
|
+
public:
|
|
439
|
+
explicit GlobalValueMap(Isolate* isolate)
|
|
440
|
+
: PersistentValueMapBase<K, V, Traits>(isolate) {}
|
|
441
|
+
GlobalValueMap(Isolate* isolate, const char* label)
|
|
442
|
+
: PersistentValueMapBase<K, V, Traits>(isolate, label) {}
|
|
443
|
+
|
|
444
|
+
typedef
|
|
445
|
+
typename PersistentValueMapBase<K, V, Traits>::PersistentValueReference
|
|
446
|
+
PersistentValueReference;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Put value into map. Depending on Traits::kIsWeak, the value will be held
|
|
450
|
+
* by the map strongly or weakly.
|
|
451
|
+
* Returns old value as Global.
|
|
452
|
+
*/
|
|
453
|
+
Global<V> Set(const K& key, Local<V> value) {
|
|
454
|
+
Global<V> persistent(this->isolate(), value);
|
|
455
|
+
return SetUnique(key, &persistent);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Put value into map, like Set(const K&, Local<V>).
|
|
460
|
+
*/
|
|
461
|
+
Global<V> Set(const K& key, Global<V> value) {
|
|
462
|
+
return SetUnique(key, &value);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Put the value into the map, and set the 'weak' callback when demanded
|
|
467
|
+
* by the Traits class.
|
|
468
|
+
*/
|
|
469
|
+
Global<V> SetUnique(const K& key, Global<V>* persistent) {
|
|
470
|
+
if (Traits::kCallbackType == kNotWeak) {
|
|
471
|
+
this->AnnotateStrongRetainer(persistent);
|
|
472
|
+
} else {
|
|
473
|
+
WeakCallbackType callback_type =
|
|
474
|
+
Traits::kCallbackType == kWeakWithInternalFields
|
|
475
|
+
? WeakCallbackType::kInternalFields
|
|
476
|
+
: WeakCallbackType::kParameter;
|
|
477
|
+
auto value = Local<V>::New(this->isolate(), *persistent);
|
|
478
|
+
persistent->template SetWeak<typename Traits::WeakCallbackDataType>(
|
|
479
|
+
Traits::WeakCallbackParameter(this, key, value), OnWeakCallback,
|
|
480
|
+
callback_type);
|
|
481
|
+
}
|
|
482
|
+
PersistentContainerValue old_value =
|
|
483
|
+
Traits::Set(this->impl(), key, this->ClearAndLeak(persistent));
|
|
484
|
+
return this->Release(old_value).Pass();
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Put a value into the map and update the reference.
|
|
489
|
+
* Restrictions of GetReference apply here as well.
|
|
490
|
+
*/
|
|
491
|
+
Global<V> Set(const K& key, Global<V> value,
|
|
492
|
+
PersistentValueReference* reference) {
|
|
493
|
+
*reference = this->Leak(&value);
|
|
494
|
+
return SetUnique(key, &value);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
private:
|
|
498
|
+
static void OnWeakCallback(
|
|
499
|
+
const WeakCallbackInfo<typename Traits::WeakCallbackDataType>& data) {
|
|
500
|
+
if (Traits::kCallbackType != kNotWeak) {
|
|
501
|
+
auto map = Traits::MapFromWeakCallbackInfo(data);
|
|
502
|
+
K key = Traits::KeyFromWeakCallbackInfo(data);
|
|
503
|
+
map->RemoveWeak(key);
|
|
504
|
+
Traits::OnWeakCallback(data);
|
|
505
|
+
data.SetSecondPassCallback(SecondWeakCallback);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
static void SecondWeakCallback(
|
|
510
|
+
const WeakCallbackInfo<typename Traits::WeakCallbackDataType>& data) {
|
|
511
|
+
Traits::DisposeWeak(data);
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* A map that uses Global as value and std::map as the backing
|
|
518
|
+
* implementation. Persistents are held non-weak.
|
|
519
|
+
*
|
|
520
|
+
* C++11 embedders don't need this class, as they can use
|
|
521
|
+
* Global directly in std containers.
|
|
522
|
+
*/
|
|
523
|
+
template<typename K, typename V,
|
|
524
|
+
typename Traits = DefaultPersistentValueMapTraits<K, V> >
|
|
525
|
+
class StdPersistentValueMap : public PersistentValueMap<K, V, Traits> {
|
|
526
|
+
public:
|
|
527
|
+
explicit StdPersistentValueMap(Isolate* isolate)
|
|
528
|
+
: PersistentValueMap<K, V, Traits>(isolate) {}
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* A map that uses Global as value and std::map as the backing
|
|
534
|
+
* implementation. Globals are held non-weak.
|
|
535
|
+
*
|
|
536
|
+
* C++11 embedders don't need this class, as they can use
|
|
537
|
+
* Global directly in std containers.
|
|
538
|
+
*/
|
|
539
|
+
template <typename K, typename V,
|
|
540
|
+
typename Traits = DefaultGlobalMapTraits<K, V> >
|
|
541
|
+
class StdGlobalValueMap : public GlobalValueMap<K, V, Traits> {
|
|
542
|
+
public:
|
|
543
|
+
explicit StdGlobalValueMap(Isolate* isolate)
|
|
544
|
+
: GlobalValueMap<K, V, Traits>(isolate) {}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
} // namespace v8
|
|
548
|
+
|
|
549
|
+
#endif // V8_UTIL_H
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
#ifndef INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_
|
|
6
|
+
#define INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Compile-time constants.
|
|
10
|
+
*
|
|
11
|
+
* This header provides access to information about the value serializer at
|
|
12
|
+
* compile time, without declaring or defining any symbols that require linking
|
|
13
|
+
* to V8.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
#include <stdint.h>
|
|
17
|
+
|
|
18
|
+
namespace v8 {
|
|
19
|
+
|
|
20
|
+
constexpr uint32_t CurrentValueSerializerFormatVersion() { return 15; }
|
|
21
|
+
|
|
22
|
+
} // namespace v8
|
|
23
|
+
|
|
24
|
+
#endif // INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
#ifndef V8_VERSION_STRING_H_
|
|
6
|
+
#define V8_VERSION_STRING_H_
|
|
7
|
+
|
|
8
|
+
#include "v8-version.h" // NOLINT(build/include_directory)
|
|
9
|
+
|
|
10
|
+
// This is here rather than v8-version.h to keep that file simple and
|
|
11
|
+
// machine-processable.
|
|
12
|
+
|
|
13
|
+
#if V8_IS_CANDIDATE_VERSION
|
|
14
|
+
#define V8_CANDIDATE_STRING " (candidate)"
|
|
15
|
+
#else
|
|
16
|
+
#define V8_CANDIDATE_STRING ""
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
#ifndef V8_EMBEDDER_STRING
|
|
20
|
+
#define V8_EMBEDDER_STRING ""
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
#define V8_SX(x) #x
|
|
24
|
+
#define V8_S(x) V8_SX(x)
|
|
25
|
+
|
|
26
|
+
#if V8_PATCH_LEVEL > 0
|
|
27
|
+
#define V8_VERSION_STRING \
|
|
28
|
+
V8_S(V8_MAJOR_VERSION) \
|
|
29
|
+
"." V8_S(V8_MINOR_VERSION) "." V8_S(V8_BUILD_NUMBER) "." V8_S( \
|
|
30
|
+
V8_PATCH_LEVEL) V8_EMBEDDER_STRING V8_CANDIDATE_STRING
|
|
31
|
+
#else
|
|
32
|
+
#define V8_VERSION_STRING \
|
|
33
|
+
V8_S(V8_MAJOR_VERSION) \
|
|
34
|
+
"." V8_S(V8_MINOR_VERSION) "." V8_S(V8_BUILD_NUMBER) \
|
|
35
|
+
V8_EMBEDDER_STRING V8_CANDIDATE_STRING
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#endif // V8_VERSION_STRING_H_
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright 2018 the V8 project authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
#ifndef V8_WASM_TRAP_HANDLER_POSIX_H_
|
|
6
|
+
#define V8_WASM_TRAP_HANDLER_POSIX_H_
|
|
7
|
+
|
|
8
|
+
#include <signal.h>
|
|
9
|
+
|
|
10
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
11
|
+
|
|
12
|
+
namespace v8 {
|
|
13
|
+
/**
|
|
14
|
+
* This function determines whether a memory access violation has been an
|
|
15
|
+
* out-of-bounds memory access in WebAssembly. If so, it will modify the context
|
|
16
|
+
* parameter and add a return address where the execution can continue after the
|
|
17
|
+
* signal handling, and return true. Otherwise, false will be returned.
|
|
18
|
+
*
|
|
19
|
+
* The parameters to this function correspond to those passed to a Posix signal
|
|
20
|
+
* handler. Use this function only on Linux and Mac.
|
|
21
|
+
*
|
|
22
|
+
* \param sig_code The signal code, e.g. SIGSEGV.
|
|
23
|
+
* \param info A pointer to the siginfo_t struct provided to the signal handler.
|
|
24
|
+
* \param context A pointer to a ucontext_t struct provided to the signal
|
|
25
|
+
* handler.
|
|
26
|
+
*/
|
|
27
|
+
V8_EXPORT bool TryHandleWebAssemblyTrapPosix(int sig_code, siginfo_t* info,
|
|
28
|
+
void* context);
|
|
29
|
+
|
|
30
|
+
} // namespace v8
|
|
31
|
+
#endif // V8_WASM_TRAP_HANDLER_POSIX_H_
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2018 the V8 project authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
#ifndef V8_WASM_TRAP_HANDLER_WIN_H_
|
|
6
|
+
#define V8_WASM_TRAP_HANDLER_WIN_H_
|
|
7
|
+
|
|
8
|
+
#include <windows.h>
|
|
9
|
+
|
|
10
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
11
|
+
|
|
12
|
+
namespace v8 {
|
|
13
|
+
/**
|
|
14
|
+
* This function determines whether a memory access violation has been an
|
|
15
|
+
* out-of-bounds memory access in WebAssembly. If so, it will modify the
|
|
16
|
+
* exception parameter and add a return address where the execution can continue
|
|
17
|
+
* after the exception handling, and return true. Otherwise the return value
|
|
18
|
+
* will be false.
|
|
19
|
+
*
|
|
20
|
+
* The parameter to this function corresponds to the one passed to a Windows
|
|
21
|
+
* vectored exception handler. Use this function only on Windows.
|
|
22
|
+
*
|
|
23
|
+
* \param exception An EXCEPTION_POINTERS* as provided to the exception handler.
|
|
24
|
+
*/
|
|
25
|
+
V8_EXPORT bool TryHandleWebAssemblyTrapWindows(EXCEPTION_POINTERS* exception);
|
|
26
|
+
|
|
27
|
+
} // namespace v8
|
|
28
|
+
#endif // V8_WASM_TRAP_HANDLER_WIN_H_
|