@kungfu-tech/libnode-win32-x64 0.0.0-bootstrap.0 → 22.22.3-kf.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +3 -0
- package/dist/node/include/acorn_version.h +6 -0
- package/dist/node/include/aliased_buffer-inl.h +244 -0
- package/dist/node/include/aliased_buffer.h +206 -0
- package/dist/node/include/aliased_struct-inl.h +54 -0
- package/dist/node/include/aliased_struct.h +63 -0
- package/dist/node/include/amaro_version.h +6 -0
- package/dist/node/include/async_context_frame.h +33 -0
- package/dist/node/include/async_wrap-inl.h +96 -0
- package/dist/node/include/async_wrap.h +243 -0
- package/dist/node/include/base_object-inl.h +335 -0
- package/dist/node/include/base_object.h +342 -0
- package/dist/node/include/base_object_types.h +74 -0
- package/dist/node/include/blob_serializer_deserializer-inl.h +385 -0
- package/dist/node/include/blob_serializer_deserializer.h +132 -0
- package/dist/node/include/callback_queue-inl.h +97 -0
- package/dist/node/include/callback_queue.h +79 -0
- package/dist/node/include/cares_wrap.h +447 -0
- package/dist/node/include/cjs_module_lexer_version.h +6 -0
- package/dist/node/include/cleanup_queue-inl.h +36 -0
- package/dist/node/include/cleanup_queue.h +79 -0
- package/dist/node/include/compile_cache.h +104 -0
- package/dist/node/include/connect_wrap.h +26 -0
- package/dist/node/include/connection_wrap.h +30 -0
- package/dist/node/include/cppgc/allocation.h +310 -0
- package/dist/node/include/cppgc/common.h +28 -0
- package/dist/node/include/cppgc/cross-thread-persistent.h +466 -0
- package/dist/node/include/cppgc/custom-space.h +97 -0
- package/dist/node/include/cppgc/default-platform.h +67 -0
- package/dist/node/include/cppgc/ephemeron-pair.h +30 -0
- package/dist/node/include/cppgc/explicit-management.h +100 -0
- package/dist/node/include/cppgc/garbage-collected.h +106 -0
- package/dist/node/include/cppgc/heap-consistency.h +309 -0
- package/dist/node/include/cppgc/heap-handle.h +48 -0
- package/dist/node/include/cppgc/heap-state.h +82 -0
- package/dist/node/include/cppgc/heap-statistics.h +120 -0
- package/dist/node/include/cppgc/heap.h +202 -0
- package/dist/node/include/cppgc/internal/api-constants.h +87 -0
- package/dist/node/include/cppgc/internal/atomic-entry-flag.h +48 -0
- package/dist/node/include/cppgc/internal/base-page-handle.h +45 -0
- package/dist/node/include/cppgc/internal/caged-heap-local-data.h +121 -0
- package/dist/node/include/cppgc/internal/caged-heap.h +68 -0
- package/dist/node/include/cppgc/internal/compiler-specific.h +38 -0
- package/dist/node/include/cppgc/internal/finalizer-trait.h +93 -0
- package/dist/node/include/cppgc/internal/gc-info.h +148 -0
- package/dist/node/include/cppgc/internal/logging.h +50 -0
- package/dist/node/include/cppgc/internal/member-storage.h +256 -0
- package/dist/node/include/cppgc/internal/name-trait.h +137 -0
- package/dist/node/include/cppgc/internal/persistent-node.h +214 -0
- package/dist/node/include/cppgc/internal/pointer-policies.h +243 -0
- package/dist/node/include/cppgc/internal/write-barrier.h +487 -0
- package/dist/node/include/cppgc/liveness-broker.h +78 -0
- package/dist/node/include/cppgc/macros.h +35 -0
- package/dist/node/include/cppgc/member.h +629 -0
- package/dist/node/include/cppgc/name-provider.h +65 -0
- package/dist/node/include/cppgc/object-size-trait.h +58 -0
- package/dist/node/include/cppgc/persistent.h +377 -0
- package/dist/node/include/cppgc/platform.h +163 -0
- package/dist/node/include/cppgc/prefinalizer.h +75 -0
- package/dist/node/include/cppgc/process-heap-statistics.h +36 -0
- package/dist/node/include/cppgc/sentinel-pointer.h +39 -0
- package/dist/node/include/cppgc/source-location.h +16 -0
- package/dist/node/include/cppgc/testing.h +106 -0
- package/dist/node/include/cppgc/trace-trait.h +128 -0
- package/dist/node/include/cppgc/type-traits.h +271 -0
- package/dist/node/include/cppgc/visitor.h +504 -0
- package/dist/node/include/crypto/crypto_aes.h +88 -0
- package/dist/node/include/crypto/crypto_bio.h +193 -0
- package/dist/node/include/crypto/crypto_cipher.h +293 -0
- package/dist/node/include/crypto/crypto_clienthello-inl.h +90 -0
- package/dist/node/include/crypto/crypto_clienthello.h +131 -0
- package/dist/node/include/crypto/crypto_common.h +64 -0
- package/dist/node/include/crypto/crypto_context.h +171 -0
- package/dist/node/include/crypto/crypto_dh.h +126 -0
- package/dist/node/include/crypto/crypto_dsa.h +52 -0
- package/dist/node/include/crypto/crypto_ec.h +164 -0
- package/dist/node/include/crypto/crypto_hash.h +91 -0
- package/dist/node/include/crypto/crypto_hkdf.h +61 -0
- package/dist/node/include/crypto/crypto_hmac.h +92 -0
- package/dist/node/include/crypto/crypto_keygen.h +299 -0
- package/dist/node/include/crypto/crypto_keys.h +392 -0
- package/dist/node/include/crypto/crypto_pbkdf2.h +74 -0
- package/dist/node/include/crypto/crypto_random.h +124 -0
- package/dist/node/include/crypto/crypto_rsa.h +136 -0
- package/dist/node/include/crypto/crypto_scrypt.h +85 -0
- package/dist/node/include/crypto/crypto_sig.h +165 -0
- package/dist/node/include/crypto/crypto_spkac.h +21 -0
- package/dist/node/include/crypto/crypto_timing.h +20 -0
- package/dist/node/include/crypto/crypto_tls.h +305 -0
- package/dist/node/include/crypto/crypto_util.h +725 -0
- package/dist/node/include/crypto/crypto_x509.h +140 -0
- package/dist/node/include/dataqueue/queue.h +306 -0
- package/dist/node/include/debug_utils-inl.h +278 -0
- package/dist/node/include/debug_utils.h +196 -0
- package/dist/node/include/diagnosticfilename-inl.h +33 -0
- package/dist/node/include/embedded_data.h +17 -0
- package/dist/node/include/encoding_binding.h +61 -0
- package/dist/node/include/env-inl.h +984 -0
- package/dist/node/include/env.h +1287 -0
- package/dist/node/include/env_properties.h +540 -0
- package/dist/node/include/handle_wrap.h +123 -0
- package/dist/node/include/histogram-inl.h +107 -0
- package/dist/node/include/histogram.h +279 -0
- package/dist/node/include/inspector/io_agent.h +30 -0
- package/dist/node/include/inspector/main_thread_interface.h +116 -0
- package/dist/node/include/inspector/network_agent.h +94 -0
- package/dist/node/include/inspector/network_inspector.h +45 -0
- package/dist/node/include/inspector/network_requests_buffer.h +195 -0
- package/dist/node/include/inspector/network_resource_manager.h +29 -0
- package/dist/node/include/inspector/node_json.h +24 -0
- package/dist/node/include/inspector/node_string.h +101 -0
- package/dist/node/include/inspector/protocol_helper.h +27 -0
- package/dist/node/include/inspector/runtime_agent.h +41 -0
- package/dist/node/include/inspector/target_agent.h +75 -0
- package/dist/node/include/inspector/tracing_agent.h +43 -0
- package/dist/node/include/inspector/worker_agent.h +40 -0
- package/dist/node/include/inspector/worker_inspector.h +124 -0
- package/dist/node/include/inspector_agent.h +165 -0
- package/dist/node/include/inspector_io.h +78 -0
- package/dist/node/include/inspector_profiler.h +149 -0
- package/dist/node/include/inspector_socket.h +60 -0
- package/dist/node/include/inspector_socket_server.h +110 -0
- package/dist/node/include/js_native_api.h +607 -0
- package/dist/node/include/js_native_api_types.h +226 -0
- package/dist/node/include/js_native_api_v8.h +485 -0
- package/dist/node/include/js_native_api_v8_internals.h +45 -0
- package/dist/node/include/js_stream.h +52 -0
- package/dist/node/include/json_utils.h +172 -0
- package/dist/node/include/large_pages/node_large_page.h +34 -0
- package/dist/node/include/libplatform/libplatform-export.h +29 -0
- package/dist/node/include/libplatform/libplatform.h +112 -0
- package/dist/node/include/libplatform/v8-tracing.h +333 -0
- package/dist/node/include/memory_tracker-inl.h +359 -0
- package/dist/node/include/memory_tracker.h +289 -0
- package/dist/node/include/module_wrap.h +216 -0
- package/dist/node/include/node.h +1593 -0
- package/dist/node/include/node_api.h +265 -0
- package/dist/node/include/node_api_internals.h +48 -0
- package/dist/node/include/node_api_types.h +56 -0
- package/dist/node/include/node_binding.h +161 -0
- package/dist/node/include/node_blob.h +159 -0
- package/dist/node/include/node_bob-inl.h +36 -0
- package/dist/node/include/node_bob.h +107 -0
- package/dist/node/include/node_buffer.h +92 -0
- package/dist/node/include/node_builtins.h +220 -0
- package/dist/node/include/node_config_file.h +46 -0
- package/dist/node/include/node_constants.h +82 -0
- package/dist/node/include/node_context_data.h +168 -0
- package/dist/node/include/node_contextify.h +204 -0
- package/dist/node/include/node_crypto.h +56 -0
- package/dist/node/include/node_debug.h +30 -0
- package/dist/node/include/node_dir.h +52 -0
- package/dist/node/include/node_dotenv.h +45 -0
- package/dist/node/include/node_errors.h +380 -0
- package/dist/node/include/node_exit_code.h +54 -0
- package/dist/node/include/node_external_reference.h +165 -0
- package/dist/node/include/node_file-inl.h +406 -0
- package/dist/node/include/node_file.h +537 -0
- package/dist/node/include/node_http2.h +1177 -0
- package/dist/node/include/node_http2_state.h +159 -0
- package/dist/node/include/node_http_common-inl.h +202 -0
- package/dist/node/include/node_http_common.h +535 -0
- package/dist/node/include/node_i18n.h +132 -0
- package/dist/node/include/node_internals.h +483 -0
- package/dist/node/include/node_main_instance.h +67 -0
- package/dist/node/include/node_mem-inl.h +113 -0
- package/dist/node/include/node_mem.h +45 -0
- package/dist/node/include/node_messaging.h +389 -0
- package/dist/node/include/node_metadata.h +164 -0
- package/dist/node/include/node_modules.h +91 -0
- package/dist/node/include/node_mutex.h +323 -0
- package/dist/node/include/node_object_wrap.h +132 -0
- package/dist/node/include/node_options-inl.h +490 -0
- package/dist/node/include/node_options.h +615 -0
- package/dist/node/include/node_perf.h +166 -0
- package/dist/node/include/node_perf_common.h +102 -0
- package/dist/node/include/node_platform.h +238 -0
- package/dist/node/include/node_process-inl.h +26 -0
- package/dist/node/include/node_process.h +112 -0
- package/dist/node/include/node_realm-inl.h +151 -0
- package/dist/node/include/node_realm.h +183 -0
- package/dist/node/include/node_report.h +43 -0
- package/dist/node/include/node_revert.h +82 -0
- package/dist/node/include/node_root_certs.h +3520 -0
- package/dist/node/include/node_sea.h +74 -0
- package/dist/node/include/node_shadow_realm.h +46 -0
- package/dist/node/include/node_snapshot_builder.h +57 -0
- package/dist/node/include/node_snapshotable.h +174 -0
- package/dist/node/include/node_sockaddr-inl.h +257 -0
- package/dist/node/include/node_sockaddr.h +394 -0
- package/dist/node/include/node_sqlite.h +270 -0
- package/dist/node/include/node_stat_watcher.h +73 -0
- package/dist/node/include/node_task_runner.h +92 -0
- package/dist/node/include/node_threadsafe_cow-inl.h +54 -0
- package/dist/node/include/node_threadsafe_cow.h +105 -0
- package/dist/node/include/node_union_bytes.h +81 -0
- package/dist/node/include/node_url.h +96 -0
- package/dist/node/include/node_v8.h +77 -0
- package/dist/node/include/node_v8_platform-inl.h +185 -0
- package/dist/node/include/node_version.h +110 -0
- package/dist/node/include/node_wasi.h +184 -0
- package/dist/node/include/node_wasm_web_api.h +55 -0
- package/dist/node/include/node_watchdog.h +154 -0
- package/dist/node/include/node_webstorage.h +60 -0
- package/dist/node/include/node_worker.h +158 -0
- package/dist/node/include/path.h +33 -0
- package/dist/node/include/permission/addon_permission.h +31 -0
- package/dist/node/include/permission/child_process_permission.h +31 -0
- package/dist/node/include/permission/fs_permission.h +167 -0
- package/dist/node/include/permission/inspector_permission.h +31 -0
- package/dist/node/include/permission/permission.h +138 -0
- package/dist/node/include/permission/permission_base.h +65 -0
- package/dist/node/include/permission/wasi_permission.h +31 -0
- package/dist/node/include/permission/worker_permission.h +31 -0
- package/dist/node/include/pipe_wrap.h +80 -0
- package/dist/node/include/quic/application.h +159 -0
- package/dist/node/include/quic/bindingdata.h +272 -0
- package/dist/node/include/quic/cid.h +127 -0
- package/dist/node/include/quic/data.h +148 -0
- package/dist/node/include/quic/defs.h +245 -0
- package/dist/node/include/quic/endpoint.h +458 -0
- package/dist/node/include/quic/http3.h +15 -0
- package/dist/node/include/quic/logstream.h +81 -0
- package/dist/node/include/quic/packet.h +152 -0
- package/dist/node/include/quic/preferredaddress.h +72 -0
- package/dist/node/include/quic/session.h +443 -0
- package/dist/node/include/quic/sessionticket.h +108 -0
- package/dist/node/include/quic/streams.h +232 -0
- package/dist/node/include/quic/tlscontext.h +227 -0
- package/dist/node/include/quic/tokens.h +256 -0
- package/dist/node/include/quic/transportparams.h +165 -0
- package/dist/node/include/req_wrap-inl.h +171 -0
- package/dist/node/include/req_wrap.h +77 -0
- package/dist/node/include/spawn_sync.h +243 -0
- package/dist/node/include/stream_base-inl.h +173 -0
- package/dist/node/include/stream_base.h +478 -0
- package/dist/node/include/stream_pipe.h +76 -0
- package/dist/node/include/stream_wrap.h +132 -0
- package/dist/node/include/string_bytes.h +113 -0
- package/dist/node/include/string_decoder-inl.h +31 -0
- package/dist/node/include/string_decoder.h +49 -0
- package/dist/node/include/tcp_wrap.h +105 -0
- package/dist/node/include/threadpoolwork-inl.h +70 -0
- package/dist/node/include/timer_wrap-inl.h +32 -0
- package/dist/node/include/timer_wrap.h +85 -0
- package/dist/node/include/timers.h +70 -0
- package/dist/node/include/tracing/agent.h +195 -0
- package/dist/node/include/tracing/node_trace_buffer.h +83 -0
- package/dist/node/include/tracing/node_trace_writer.h +75 -0
- package/dist/node/include/tracing/trace_event.h +722 -0
- package/dist/node/include/tracing/trace_event_common.h +1109 -0
- package/dist/node/include/tracing/traced_value.h +129 -0
- package/dist/node/include/tty_wrap.h +65 -0
- package/dist/node/include/udp_wrap.h +230 -0
- package/dist/node/include/undici_version.h +6 -0
- package/dist/node/include/util-inl.h +700 -0
- package/dist/node/include/util.h +1021 -0
- package/dist/node/include/uv/aix.h +32 -0
- package/dist/node/include/uv/bsd.h +34 -0
- package/dist/node/include/uv/darwin.h +61 -0
- package/dist/node/include/uv/errno.h +483 -0
- package/dist/node/include/uv/linux.h +34 -0
- package/dist/node/include/uv/os390.h +33 -0
- package/dist/node/include/uv/posix.h +31 -0
- package/dist/node/include/uv/sunos.h +44 -0
- package/dist/node/include/uv/threadpool.h +37 -0
- package/dist/node/include/uv/tree.h +521 -0
- package/dist/node/include/uv/unix.h +512 -0
- package/dist/node/include/uv/version.h +43 -0
- package/dist/node/include/uv/win.h +698 -0
- package/dist/node/include/uv.h +1990 -0
- package/dist/node/include/v8-array-buffer.h +525 -0
- package/dist/node/include/v8-callbacks.h +462 -0
- package/dist/node/include/v8-container.h +183 -0
- package/dist/node/include/v8-context.h +485 -0
- package/dist/node/include/v8-cppgc.h +245 -0
- package/dist/node/include/v8-data.h +80 -0
- package/dist/node/include/v8-date.h +48 -0
- package/dist/node/include/v8-debug.h +168 -0
- package/dist/node/include/v8-embedder-heap.h +82 -0
- package/dist/node/include/v8-embedder-state-scope.h +52 -0
- package/dist/node/include/v8-exception.h +223 -0
- package/dist/node/include/v8-extension.h +62 -0
- package/dist/node/include/v8-external.h +37 -0
- package/dist/node/include/v8-fast-api-calls.h +984 -0
- package/dist/node/include/v8-forward.h +82 -0
- package/dist/node/include/v8-function-callback.h +607 -0
- package/dist/node/include/v8-function.h +140 -0
- package/dist/node/include/v8-handle-base.h +137 -0
- package/dist/node/include/v8-initialization.h +289 -0
- package/dist/node/include/v8-inspector-protocol.h +13 -0
- package/dist/node/include/v8-inspector.h +419 -0
- package/dist/node/include/v8-internal.h +1397 -0
- package/dist/node/include/v8-isolate.h +1767 -0
- package/dist/node/include/v8-json.h +47 -0
- package/dist/node/include/v8-local-handle.h +758 -0
- package/dist/node/include/v8-locker.h +138 -0
- package/dist/node/include/v8-maybe.h +160 -0
- package/dist/node/include/v8-memory-span.h +198 -0
- package/dist/node/include/v8-message.h +233 -0
- package/dist/node/include/v8-metrics.h +264 -0
- package/dist/node/include/v8-microtask-queue.h +157 -0
- package/dist/node/include/v8-microtask.h +28 -0
- package/dist/node/include/v8-object.h +824 -0
- package/dist/node/include/v8-persistent-handle.h +582 -0
- package/dist/node/include/v8-platform.h +1358 -0
- package/dist/node/include/v8-primitive-object.h +118 -0
- package/dist/node/include/v8-primitive.h +877 -0
- package/dist/node/include/v8-profiler.h +1302 -0
- package/dist/node/include/v8-promise.h +174 -0
- package/dist/node/include/v8-proxy.h +50 -0
- package/dist/node/include/v8-regexp.h +106 -0
- package/dist/node/include/v8-script.h +904 -0
- package/dist/node/include/v8-snapshot.h +266 -0
- package/dist/node/include/v8-source-location.h +92 -0
- package/dist/node/include/v8-statistics.h +238 -0
- package/dist/node/include/v8-template.h +1297 -0
- package/dist/node/include/v8-traced-handle.h +432 -0
- package/dist/node/include/v8-typed-array.h +390 -0
- package/dist/node/include/v8-unwinder-state.h +31 -0
- package/dist/node/include/v8-unwinder.h +132 -0
- package/dist/node/include/v8-util.h +665 -0
- package/dist/node/include/v8-value-serializer-version.h +24 -0
- package/dist/node/include/v8-value-serializer.h +316 -0
- package/dist/node/include/v8-value.h +655 -0
- package/dist/node/include/v8-version-string.h +38 -0
- package/dist/node/include/v8-version.h +20 -0
- package/dist/node/include/v8-wasm-trap-handler-posix.h +31 -0
- package/dist/node/include/v8-wasm-trap-handler-win.h +28 -0
- package/dist/node/include/v8-wasm.h +201 -0
- package/dist/node/include/v8-weak-callback-info.h +80 -0
- package/dist/node/include/v8.h +88 -0
- package/dist/node/include/v8config.h +981 -0
- package/dist/node/include/zlib_version.h +6 -0
- package/dist/node/libnode.dll +0 -0
- package/dist/node/libnode.lib +0 -0
- package/dist/node/libnodebuildinfo.json +10 -0
- package/dist/node/link_node.lib +0 -0
- package/dist/node/link_node.node +0 -0
- package/index.js +5 -0
- package/libnode.release.json +8 -0
- package/package.json +29 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
#ifndef SRC_ALIASED_BUFFER_INL_H_
|
|
2
|
+
#define SRC_ALIASED_BUFFER_INL_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "aliased_buffer.h"
|
|
7
|
+
#include "memory_tracker-inl.h"
|
|
8
|
+
#include "util-inl.h"
|
|
9
|
+
|
|
10
|
+
namespace node {
|
|
11
|
+
|
|
12
|
+
typedef size_t AliasedBufferIndex;
|
|
13
|
+
|
|
14
|
+
template <typename NativeT, typename V8T>
|
|
15
|
+
AliasedBufferBase<NativeT, V8T>::AliasedBufferBase(
|
|
16
|
+
v8::Isolate* isolate, const size_t count, const AliasedBufferIndex* index)
|
|
17
|
+
: isolate_(isolate), count_(count), byte_offset_(0), index_(index) {
|
|
18
|
+
CHECK_GT(count, 0);
|
|
19
|
+
if (index != nullptr) {
|
|
20
|
+
// Will be deserialized later.
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const v8::HandleScope handle_scope(isolate_);
|
|
24
|
+
const size_t size_in_bytes =
|
|
25
|
+
MultiplyWithOverflowCheck(sizeof(NativeT), count);
|
|
26
|
+
|
|
27
|
+
// allocate v8 ArrayBuffer
|
|
28
|
+
v8::Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate_, size_in_bytes);
|
|
29
|
+
buffer_ = static_cast<NativeT*>(ab->Data());
|
|
30
|
+
|
|
31
|
+
// allocate v8 TypedArray
|
|
32
|
+
v8::Local<V8T> js_array = V8T::New(ab, byte_offset_, count);
|
|
33
|
+
js_array_ = v8::Global<V8T>(isolate, js_array);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
template <typename NativeT, typename V8T>
|
|
37
|
+
AliasedBufferBase<NativeT, V8T>::AliasedBufferBase(
|
|
38
|
+
v8::Isolate* isolate,
|
|
39
|
+
const size_t byte_offset,
|
|
40
|
+
const size_t count,
|
|
41
|
+
const AliasedBufferBase<uint8_t, v8::Uint8Array>& backing_buffer,
|
|
42
|
+
const AliasedBufferIndex* index)
|
|
43
|
+
: isolate_(isolate),
|
|
44
|
+
count_(count),
|
|
45
|
+
byte_offset_(byte_offset),
|
|
46
|
+
index_(index) {
|
|
47
|
+
if (index != nullptr) {
|
|
48
|
+
// Will be deserialized later.
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const v8::HandleScope handle_scope(isolate_);
|
|
52
|
+
v8::Local<v8::ArrayBuffer> ab = backing_buffer.GetArrayBuffer();
|
|
53
|
+
|
|
54
|
+
// validate that the byte_offset is aligned with sizeof(NativeT)
|
|
55
|
+
CHECK_EQ(byte_offset & (sizeof(NativeT) - 1), 0);
|
|
56
|
+
// validate this fits inside the backing buffer
|
|
57
|
+
CHECK_LE(MultiplyWithOverflowCheck(sizeof(NativeT), count),
|
|
58
|
+
ab->ByteLength() - byte_offset);
|
|
59
|
+
|
|
60
|
+
buffer_ = reinterpret_cast<NativeT*>(
|
|
61
|
+
const_cast<uint8_t*>(backing_buffer.GetNativeBuffer() + byte_offset));
|
|
62
|
+
|
|
63
|
+
v8::Local<V8T> js_array = V8T::New(ab, byte_offset, count);
|
|
64
|
+
js_array_ = v8::Global<V8T>(isolate, js_array);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
template <typename NativeT, typename V8T>
|
|
68
|
+
AliasedBufferBase<NativeT, V8T>::AliasedBufferBase(
|
|
69
|
+
const AliasedBufferBase& that)
|
|
70
|
+
: isolate_(that.isolate_),
|
|
71
|
+
count_(that.count_),
|
|
72
|
+
byte_offset_(that.byte_offset_),
|
|
73
|
+
buffer_(that.buffer_) {
|
|
74
|
+
js_array_ = v8::Global<V8T>(that.isolate_, that.GetJSArray());
|
|
75
|
+
DCHECK(is_valid());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
template <typename NativeT, typename V8T>
|
|
79
|
+
AliasedBufferIndex AliasedBufferBase<NativeT, V8T>::Serialize(
|
|
80
|
+
v8::Local<v8::Context> context, v8::SnapshotCreator* creator) {
|
|
81
|
+
DCHECK(is_valid());
|
|
82
|
+
return creator->AddData(context, GetJSArray());
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
template <typename NativeT, typename V8T>
|
|
86
|
+
inline void AliasedBufferBase<NativeT, V8T>::Deserialize(
|
|
87
|
+
v8::Local<v8::Context> context) {
|
|
88
|
+
DCHECK_NOT_NULL(index_);
|
|
89
|
+
v8::Local<V8T> arr =
|
|
90
|
+
context->GetDataFromSnapshotOnce<V8T>(*index_).ToLocalChecked();
|
|
91
|
+
// These may not hold true for AliasedBuffers that have grown, so should
|
|
92
|
+
// be removed when we expand the snapshot support.
|
|
93
|
+
DCHECK_EQ(count_, arr->Length());
|
|
94
|
+
DCHECK_EQ(byte_offset_, arr->ByteOffset());
|
|
95
|
+
uint8_t* raw = static_cast<uint8_t*>(arr->Buffer()->Data());
|
|
96
|
+
buffer_ = reinterpret_cast<NativeT*>(raw + byte_offset_);
|
|
97
|
+
js_array_.Reset(isolate_, arr);
|
|
98
|
+
index_ = nullptr;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
template <typename NativeT, typename V8T>
|
|
102
|
+
AliasedBufferBase<NativeT, V8T>& AliasedBufferBase<NativeT, V8T>::operator=(
|
|
103
|
+
AliasedBufferBase<NativeT, V8T>&& that) noexcept {
|
|
104
|
+
DCHECK(is_valid());
|
|
105
|
+
this->~AliasedBufferBase();
|
|
106
|
+
isolate_ = that.isolate_;
|
|
107
|
+
count_ = that.count_;
|
|
108
|
+
byte_offset_ = that.byte_offset_;
|
|
109
|
+
buffer_ = that.buffer_;
|
|
110
|
+
|
|
111
|
+
js_array_.Reset(isolate_, that.js_array_.Get(isolate_));
|
|
112
|
+
|
|
113
|
+
that.buffer_ = nullptr;
|
|
114
|
+
that.js_array_.Reset();
|
|
115
|
+
return *this;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
template <typename NativeT, typename V8T>
|
|
119
|
+
v8::Local<V8T> AliasedBufferBase<NativeT, V8T>::GetJSArray() const {
|
|
120
|
+
DCHECK(is_valid());
|
|
121
|
+
return js_array_.Get(isolate_);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
template <typename NativeT, typename V8T>
|
|
125
|
+
void AliasedBufferBase<NativeT, V8T>::Release() {
|
|
126
|
+
DCHECK_NULL(index_);
|
|
127
|
+
js_array_.Reset();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
template <typename NativeT, typename V8T>
|
|
131
|
+
inline void AliasedBufferBase<NativeT, V8T>::MakeWeak() {
|
|
132
|
+
DCHECK(is_valid());
|
|
133
|
+
js_array_.SetWeak();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
template <typename NativeT, typename V8T>
|
|
137
|
+
v8::Local<v8::ArrayBuffer> AliasedBufferBase<NativeT, V8T>::GetArrayBuffer()
|
|
138
|
+
const {
|
|
139
|
+
return GetJSArray()->Buffer();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
template <typename NativeT, typename V8T>
|
|
143
|
+
inline const NativeT* AliasedBufferBase<NativeT, V8T>::GetNativeBuffer() const {
|
|
144
|
+
DCHECK(is_valid());
|
|
145
|
+
return buffer_;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
template <typename NativeT, typename V8T>
|
|
149
|
+
inline const NativeT* AliasedBufferBase<NativeT, V8T>::operator*() const {
|
|
150
|
+
return GetNativeBuffer();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
template <typename NativeT, typename V8T>
|
|
154
|
+
inline void AliasedBufferBase<NativeT, V8T>::SetValue(const size_t index,
|
|
155
|
+
NativeT value) {
|
|
156
|
+
DCHECK_LT(index, count_);
|
|
157
|
+
DCHECK(is_valid());
|
|
158
|
+
buffer_[index] = value;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
template <typename NativeT, typename V8T>
|
|
162
|
+
inline const NativeT AliasedBufferBase<NativeT, V8T>::GetValue(
|
|
163
|
+
const size_t index) const {
|
|
164
|
+
DCHECK(is_valid());
|
|
165
|
+
DCHECK_LT(index, count_);
|
|
166
|
+
return buffer_[index];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
template <typename NativeT, typename V8T>
|
|
170
|
+
typename AliasedBufferBase<NativeT, V8T>::Reference
|
|
171
|
+
AliasedBufferBase<NativeT, V8T>::operator[](size_t index) {
|
|
172
|
+
DCHECK(is_valid());
|
|
173
|
+
return Reference(this, index);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
template <typename NativeT, typename V8T>
|
|
177
|
+
NativeT AliasedBufferBase<NativeT, V8T>::operator[](size_t index) const {
|
|
178
|
+
return GetValue(index);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
template <typename NativeT, typename V8T>
|
|
182
|
+
size_t AliasedBufferBase<NativeT, V8T>::Length() const {
|
|
183
|
+
return count_;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
template <typename NativeT, typename V8T>
|
|
187
|
+
void AliasedBufferBase<NativeT, V8T>::reserve(size_t new_capacity) {
|
|
188
|
+
DCHECK(is_valid());
|
|
189
|
+
DCHECK_GE(new_capacity, count_);
|
|
190
|
+
DCHECK_EQ(byte_offset_, 0);
|
|
191
|
+
const v8::HandleScope handle_scope(isolate_);
|
|
192
|
+
|
|
193
|
+
const size_t old_size_in_bytes = sizeof(NativeT) * count_;
|
|
194
|
+
const size_t new_size_in_bytes =
|
|
195
|
+
MultiplyWithOverflowCheck(sizeof(NativeT), new_capacity);
|
|
196
|
+
|
|
197
|
+
// allocate v8 new ArrayBuffer
|
|
198
|
+
v8::Local<v8::ArrayBuffer> ab =
|
|
199
|
+
v8::ArrayBuffer::New(isolate_, new_size_in_bytes);
|
|
200
|
+
|
|
201
|
+
// allocate new native buffer
|
|
202
|
+
NativeT* new_buffer = static_cast<NativeT*>(ab->Data());
|
|
203
|
+
// copy old content
|
|
204
|
+
memcpy(new_buffer, buffer_, old_size_in_bytes);
|
|
205
|
+
|
|
206
|
+
// allocate v8 TypedArray
|
|
207
|
+
v8::Local<V8T> js_array = V8T::New(ab, byte_offset_, new_capacity);
|
|
208
|
+
|
|
209
|
+
// move over old v8 TypedArray
|
|
210
|
+
js_array_ = std::move(v8::Global<V8T>(isolate_, js_array));
|
|
211
|
+
|
|
212
|
+
buffer_ = new_buffer;
|
|
213
|
+
count_ = new_capacity;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
template <typename NativeT, typename V8T>
|
|
217
|
+
inline bool AliasedBufferBase<NativeT, V8T>::is_valid() const {
|
|
218
|
+
return index_ == nullptr && !js_array_.IsEmpty();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
template <typename NativeT, typename V8T>
|
|
222
|
+
inline size_t AliasedBufferBase<NativeT, V8T>::SelfSize() const {
|
|
223
|
+
return sizeof(*this);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
#define VM(NativeT, V8T) \
|
|
227
|
+
template <> \
|
|
228
|
+
inline const char* AliasedBufferBase<NativeT, v8::V8T>::MemoryInfoName() \
|
|
229
|
+
const { \
|
|
230
|
+
return "Aliased" #V8T; \
|
|
231
|
+
} \
|
|
232
|
+
template <> \
|
|
233
|
+
inline void AliasedBufferBase<NativeT, v8::V8T>::MemoryInfo( \
|
|
234
|
+
node::MemoryTracker* tracker) const { \
|
|
235
|
+
tracker->TrackField("js_array", js_array_); \
|
|
236
|
+
}
|
|
237
|
+
ALIASED_BUFFER_LIST(VM)
|
|
238
|
+
#undef VM
|
|
239
|
+
|
|
240
|
+
} // namespace node
|
|
241
|
+
|
|
242
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
243
|
+
|
|
244
|
+
#endif // SRC_ALIASED_BUFFER_INL_H_
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#ifndef SRC_ALIASED_BUFFER_H_
|
|
2
|
+
#define SRC_ALIASED_BUFFER_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include <cinttypes>
|
|
7
|
+
#include "memory_tracker.h"
|
|
8
|
+
#include "v8.h"
|
|
9
|
+
|
|
10
|
+
namespace node {
|
|
11
|
+
|
|
12
|
+
typedef size_t AliasedBufferIndex;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Do not use this class directly when creating instances of it - use the
|
|
16
|
+
* Aliased*Array defined at the end of this file instead.
|
|
17
|
+
*
|
|
18
|
+
* This class encapsulates the technique of having a native buffer mapped to
|
|
19
|
+
* a JS object. Writes to the native buffer can happen efficiently without
|
|
20
|
+
* going through JS, and the data is then available to user's via the exposed
|
|
21
|
+
* JS object.
|
|
22
|
+
*
|
|
23
|
+
* While this technique is computationally efficient, it is effectively a
|
|
24
|
+
* write to JS program state w/out going through the standard
|
|
25
|
+
* (monitored) API. Thus, any VM capabilities to detect the modification are
|
|
26
|
+
* circumvented.
|
|
27
|
+
*
|
|
28
|
+
* The encapsulation herein provides a placeholder where such writes can be
|
|
29
|
+
* observed. Any notification APIs will be left as a future exercise.
|
|
30
|
+
*/
|
|
31
|
+
template <class NativeT, class V8T>
|
|
32
|
+
class AliasedBufferBase final : public MemoryRetainer {
|
|
33
|
+
public:
|
|
34
|
+
static_assert(std::is_scalar_v<NativeT>);
|
|
35
|
+
|
|
36
|
+
AliasedBufferBase(v8::Isolate* isolate,
|
|
37
|
+
size_t count,
|
|
38
|
+
const AliasedBufferIndex* index = nullptr);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create an AliasedBufferBase over a sub-region of another aliased buffer.
|
|
42
|
+
* The two will share a v8::ArrayBuffer instance &
|
|
43
|
+
* a native buffer, but will each read/write to different sections of the
|
|
44
|
+
* native buffer.
|
|
45
|
+
*
|
|
46
|
+
* Note that byte_offset must be aligned by sizeof(NativeT).
|
|
47
|
+
*/
|
|
48
|
+
// TODO(refack): refactor into a non-owning `AliasedBufferBaseView`
|
|
49
|
+
AliasedBufferBase(
|
|
50
|
+
v8::Isolate* isolate,
|
|
51
|
+
size_t byte_offset,
|
|
52
|
+
size_t count,
|
|
53
|
+
const AliasedBufferBase<uint8_t, v8::Uint8Array>& backing_buffer,
|
|
54
|
+
const AliasedBufferIndex* index = nullptr);
|
|
55
|
+
|
|
56
|
+
AliasedBufferBase(const AliasedBufferBase& that);
|
|
57
|
+
|
|
58
|
+
AliasedBufferIndex Serialize(v8::Local<v8::Context> context,
|
|
59
|
+
v8::SnapshotCreator* creator);
|
|
60
|
+
|
|
61
|
+
void Deserialize(v8::Local<v8::Context> context);
|
|
62
|
+
|
|
63
|
+
AliasedBufferBase& operator=(AliasedBufferBase&& that) noexcept;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Helper class that is returned from operator[] to support assignment into
|
|
67
|
+
* a specified location.
|
|
68
|
+
*/
|
|
69
|
+
class Reference {
|
|
70
|
+
public:
|
|
71
|
+
Reference(AliasedBufferBase* aliased_buffer, const size_t index)
|
|
72
|
+
: aliased_buffer_(aliased_buffer), index_(index) {}
|
|
73
|
+
|
|
74
|
+
Reference(const Reference& that)
|
|
75
|
+
: aliased_buffer_(that.aliased_buffer_),
|
|
76
|
+
index_(that.index_) {
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
Reference& operator=(const NativeT& val) {
|
|
80
|
+
aliased_buffer_->SetValue(index_, val);
|
|
81
|
+
return *this;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
Reference& operator=(const Reference& val) {
|
|
85
|
+
return *this = static_cast<NativeT>(val);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
operator NativeT() const {
|
|
89
|
+
return aliased_buffer_->GetValue(index_);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
Reference& operator+=(const NativeT& val) {
|
|
93
|
+
const NativeT current = aliased_buffer_->GetValue(index_);
|
|
94
|
+
aliased_buffer_->SetValue(index_, current + val);
|
|
95
|
+
return *this;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
Reference& operator+=(const Reference& val) {
|
|
99
|
+
return this->operator+=(static_cast<NativeT>(val));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
Reference& operator-=(const NativeT& val) {
|
|
103
|
+
const NativeT current = aliased_buffer_->GetValue(index_);
|
|
104
|
+
aliased_buffer_->SetValue(index_, current - val);
|
|
105
|
+
return *this;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private:
|
|
109
|
+
AliasedBufferBase* aliased_buffer_;
|
|
110
|
+
size_t index_;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Get the underlying v8 TypedArray overlaid on top of the native buffer
|
|
115
|
+
*/
|
|
116
|
+
v8::Local<V8T> GetJSArray() const;
|
|
117
|
+
|
|
118
|
+
void Release();
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Make the global reference to the typed array weak. The caller must make
|
|
122
|
+
* sure that no operation can be done on the AliasedBuffer when the typed
|
|
123
|
+
* array becomes unreachable. Usually this means the caller must maintain
|
|
124
|
+
* a JS reference to the typed array from JS object.
|
|
125
|
+
*/
|
|
126
|
+
void MakeWeak();
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Get the underlying v8::ArrayBuffer underlying the TypedArray and
|
|
130
|
+
* overlaying the native buffer
|
|
131
|
+
*/
|
|
132
|
+
v8::Local<v8::ArrayBuffer> GetArrayBuffer() const;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get the underlying native buffer. Note that all reads/writes should occur
|
|
136
|
+
* through the GetValue/SetValue/operator[] methods
|
|
137
|
+
*/
|
|
138
|
+
const NativeT* GetNativeBuffer() const;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Synonym for GetBuffer()
|
|
142
|
+
*/
|
|
143
|
+
const NativeT* operator*() const;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Set position index to given value.
|
|
147
|
+
*/
|
|
148
|
+
void SetValue(size_t index, NativeT value);
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Get value at position index
|
|
152
|
+
*/
|
|
153
|
+
const NativeT GetValue(size_t index) const;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Effectively, a synonym for GetValue/SetValue
|
|
157
|
+
*/
|
|
158
|
+
Reference operator[](size_t index);
|
|
159
|
+
|
|
160
|
+
NativeT operator[](size_t index) const;
|
|
161
|
+
|
|
162
|
+
size_t Length() const;
|
|
163
|
+
|
|
164
|
+
// Should only be used to extend the array.
|
|
165
|
+
// Should only be used on an owning array, not one created as a sub array of
|
|
166
|
+
// an owning `AliasedBufferBase`.
|
|
167
|
+
void reserve(size_t new_capacity);
|
|
168
|
+
|
|
169
|
+
size_t SelfSize() const override;
|
|
170
|
+
|
|
171
|
+
const char* MemoryInfoName() const override;
|
|
172
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
173
|
+
|
|
174
|
+
private:
|
|
175
|
+
bool is_valid() const;
|
|
176
|
+
v8::Isolate* isolate_ = nullptr;
|
|
177
|
+
size_t count_ = 0;
|
|
178
|
+
size_t byte_offset_ = 0;
|
|
179
|
+
NativeT* buffer_ = nullptr;
|
|
180
|
+
v8::Global<V8T> js_array_;
|
|
181
|
+
|
|
182
|
+
// Deserialize data
|
|
183
|
+
const AliasedBufferIndex* index_ = nullptr;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
#define ALIASED_BUFFER_LIST(V) \
|
|
187
|
+
V(int8_t, Int8Array) \
|
|
188
|
+
V(uint8_t, Uint8Array) \
|
|
189
|
+
V(int16_t, Int16Array) \
|
|
190
|
+
V(uint16_t, Uint16Array) \
|
|
191
|
+
V(int32_t, Int32Array) \
|
|
192
|
+
V(uint32_t, Uint32Array) \
|
|
193
|
+
V(float, Float32Array) \
|
|
194
|
+
V(double, Float64Array) \
|
|
195
|
+
V(int64_t, BigInt64Array)
|
|
196
|
+
|
|
197
|
+
#define V(NativeT, V8T) \
|
|
198
|
+
typedef AliasedBufferBase<NativeT, v8::V8T> Aliased##V8T;
|
|
199
|
+
ALIASED_BUFFER_LIST(V)
|
|
200
|
+
#undef V
|
|
201
|
+
|
|
202
|
+
} // namespace node
|
|
203
|
+
|
|
204
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
205
|
+
|
|
206
|
+
#endif // SRC_ALIASED_BUFFER_H_
|