@kungfu-tech/libnode-win32-x64 22.22.3-kf.0 → 22.22.3-kf.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/include/acorn_version.h +6 -0
- package/dist/node/include/aliased_buffer-inl.h +244 -0
- package/dist/node/include/aliased_buffer.h +206 -0
- package/dist/node/include/aliased_struct-inl.h +54 -0
- package/dist/node/include/aliased_struct.h +63 -0
- package/dist/node/include/amaro_version.h +6 -0
- package/dist/node/include/async_context_frame.h +33 -0
- package/dist/node/include/async_wrap-inl.h +96 -0
- package/dist/node/include/async_wrap.h +243 -0
- package/dist/node/include/base_object-inl.h +335 -0
- package/dist/node/include/base_object.h +342 -0
- package/dist/node/include/base_object_types.h +74 -0
- package/dist/node/include/blob_serializer_deserializer-inl.h +385 -0
- package/dist/node/include/blob_serializer_deserializer.h +132 -0
- package/dist/node/include/callback_queue-inl.h +97 -0
- package/dist/node/include/callback_queue.h +79 -0
- package/dist/node/include/cares_wrap.h +447 -0
- package/dist/node/include/cjs_module_lexer_version.h +6 -0
- package/dist/node/include/cleanup_queue-inl.h +36 -0
- package/dist/node/include/cleanup_queue.h +79 -0
- package/dist/node/include/compile_cache.h +104 -0
- package/dist/node/include/connect_wrap.h +26 -0
- package/dist/node/include/connection_wrap.h +30 -0
- package/dist/node/include/cppgc/allocation.h +310 -0
- package/dist/node/include/cppgc/common.h +28 -0
- package/dist/node/include/cppgc/cross-thread-persistent.h +466 -0
- package/dist/node/include/cppgc/custom-space.h +97 -0
- package/dist/node/include/cppgc/default-platform.h +67 -0
- package/dist/node/include/cppgc/ephemeron-pair.h +30 -0
- package/dist/node/include/cppgc/explicit-management.h +100 -0
- package/dist/node/include/cppgc/garbage-collected.h +106 -0
- package/dist/node/include/cppgc/heap-consistency.h +309 -0
- package/dist/node/include/cppgc/heap-handle.h +48 -0
- package/dist/node/include/cppgc/heap-state.h +82 -0
- package/dist/node/include/cppgc/heap-statistics.h +120 -0
- package/dist/node/include/cppgc/heap.h +202 -0
- package/dist/node/include/cppgc/internal/api-constants.h +87 -0
- package/dist/node/include/cppgc/internal/atomic-entry-flag.h +48 -0
- package/dist/node/include/cppgc/internal/base-page-handle.h +45 -0
- package/dist/node/include/cppgc/internal/caged-heap-local-data.h +121 -0
- package/dist/node/include/cppgc/internal/caged-heap.h +68 -0
- package/dist/node/include/cppgc/internal/compiler-specific.h +38 -0
- package/dist/node/include/cppgc/internal/finalizer-trait.h +93 -0
- package/dist/node/include/cppgc/internal/gc-info.h +148 -0
- package/dist/node/include/cppgc/internal/logging.h +50 -0
- package/dist/node/include/cppgc/internal/member-storage.h +256 -0
- package/dist/node/include/cppgc/internal/name-trait.h +137 -0
- package/dist/node/include/cppgc/internal/persistent-node.h +214 -0
- package/dist/node/include/cppgc/internal/pointer-policies.h +243 -0
- package/dist/node/include/cppgc/internal/write-barrier.h +487 -0
- package/dist/node/include/cppgc/liveness-broker.h +78 -0
- package/dist/node/include/cppgc/macros.h +35 -0
- package/dist/node/include/cppgc/member.h +629 -0
- package/dist/node/include/cppgc/name-provider.h +65 -0
- package/dist/node/include/cppgc/object-size-trait.h +58 -0
- package/dist/node/include/cppgc/persistent.h +377 -0
- package/dist/node/include/cppgc/platform.h +163 -0
- package/dist/node/include/cppgc/prefinalizer.h +75 -0
- package/dist/node/include/cppgc/process-heap-statistics.h +36 -0
- package/dist/node/include/cppgc/sentinel-pointer.h +39 -0
- package/dist/node/include/cppgc/source-location.h +16 -0
- package/dist/node/include/cppgc/testing.h +106 -0
- package/dist/node/include/cppgc/trace-trait.h +128 -0
- package/dist/node/include/cppgc/type-traits.h +271 -0
- package/dist/node/include/cppgc/visitor.h +504 -0
- package/dist/node/include/crypto/crypto_aes.h +88 -0
- package/dist/node/include/crypto/crypto_bio.h +193 -0
- package/dist/node/include/crypto/crypto_cipher.h +293 -0
- package/dist/node/include/crypto/crypto_clienthello-inl.h +90 -0
- package/dist/node/include/crypto/crypto_clienthello.h +131 -0
- package/dist/node/include/crypto/crypto_common.h +64 -0
- package/dist/node/include/crypto/crypto_context.h +171 -0
- package/dist/node/include/crypto/crypto_dh.h +126 -0
- package/dist/node/include/crypto/crypto_dsa.h +52 -0
- package/dist/node/include/crypto/crypto_ec.h +164 -0
- package/dist/node/include/crypto/crypto_hash.h +91 -0
- package/dist/node/include/crypto/crypto_hkdf.h +61 -0
- package/dist/node/include/crypto/crypto_hmac.h +92 -0
- package/dist/node/include/crypto/crypto_keygen.h +299 -0
- package/dist/node/include/crypto/crypto_keys.h +392 -0
- package/dist/node/include/crypto/crypto_pbkdf2.h +74 -0
- package/dist/node/include/crypto/crypto_random.h +124 -0
- package/dist/node/include/crypto/crypto_rsa.h +136 -0
- package/dist/node/include/crypto/crypto_scrypt.h +85 -0
- package/dist/node/include/crypto/crypto_sig.h +165 -0
- package/dist/node/include/crypto/crypto_spkac.h +21 -0
- package/dist/node/include/crypto/crypto_timing.h +20 -0
- package/dist/node/include/crypto/crypto_tls.h +305 -0
- package/dist/node/include/crypto/crypto_util.h +725 -0
- package/dist/node/include/crypto/crypto_x509.h +140 -0
- package/dist/node/include/dataqueue/queue.h +306 -0
- package/dist/node/include/debug_utils-inl.h +278 -0
- package/dist/node/include/debug_utils.h +196 -0
- package/dist/node/include/diagnosticfilename-inl.h +33 -0
- package/dist/node/include/embedded_data.h +17 -0
- package/dist/node/include/encoding_binding.h +61 -0
- package/dist/node/include/env-inl.h +984 -0
- package/dist/node/include/env.h +1287 -0
- package/dist/node/include/env_properties.h +540 -0
- package/dist/node/include/handle_wrap.h +123 -0
- package/dist/node/include/histogram-inl.h +107 -0
- package/dist/node/include/histogram.h +279 -0
- package/dist/node/include/inspector/io_agent.h +30 -0
- package/dist/node/include/inspector/main_thread_interface.h +116 -0
- package/dist/node/include/inspector/network_agent.h +94 -0
- package/dist/node/include/inspector/network_inspector.h +45 -0
- package/dist/node/include/inspector/network_requests_buffer.h +195 -0
- package/dist/node/include/inspector/network_resource_manager.h +29 -0
- package/dist/node/include/inspector/node_json.h +24 -0
- package/dist/node/include/inspector/node_string.h +101 -0
- package/dist/node/include/inspector/protocol_helper.h +27 -0
- package/dist/node/include/inspector/runtime_agent.h +41 -0
- package/dist/node/include/inspector/target_agent.h +75 -0
- package/dist/node/include/inspector/tracing_agent.h +43 -0
- package/dist/node/include/inspector/worker_agent.h +40 -0
- package/dist/node/include/inspector/worker_inspector.h +124 -0
- package/dist/node/include/inspector_agent.h +165 -0
- package/dist/node/include/inspector_io.h +78 -0
- package/dist/node/include/inspector_profiler.h +149 -0
- package/dist/node/include/inspector_socket.h +60 -0
- package/dist/node/include/inspector_socket_server.h +110 -0
- package/dist/node/include/js_native_api.h +607 -0
- package/dist/node/include/js_native_api_types.h +226 -0
- package/dist/node/include/js_native_api_v8.h +485 -0
- package/dist/node/include/js_native_api_v8_internals.h +45 -0
- package/dist/node/include/js_stream.h +52 -0
- package/dist/node/include/json_utils.h +172 -0
- package/dist/node/include/large_pages/node_large_page.h +34 -0
- package/dist/node/include/libplatform/libplatform-export.h +29 -0
- package/dist/node/include/libplatform/libplatform.h +112 -0
- package/dist/node/include/libplatform/v8-tracing.h +333 -0
- package/dist/node/include/memory_tracker-inl.h +359 -0
- package/dist/node/include/memory_tracker.h +289 -0
- package/dist/node/include/module_wrap.h +216 -0
- package/dist/node/include/node.h +1593 -0
- package/dist/node/include/node_api.h +265 -0
- package/dist/node/include/node_api_internals.h +48 -0
- package/dist/node/include/node_api_types.h +56 -0
- package/dist/node/include/node_binding.h +161 -0
- package/dist/node/include/node_blob.h +159 -0
- package/dist/node/include/node_bob-inl.h +36 -0
- package/dist/node/include/node_bob.h +107 -0
- package/dist/node/include/node_buffer.h +92 -0
- package/dist/node/include/node_builtins.h +220 -0
- package/dist/node/include/node_config_file.h +46 -0
- package/dist/node/include/node_constants.h +82 -0
- package/dist/node/include/node_context_data.h +168 -0
- package/dist/node/include/node_contextify.h +204 -0
- package/dist/node/include/node_crypto.h +56 -0
- package/dist/node/include/node_debug.h +30 -0
- package/dist/node/include/node_dir.h +52 -0
- package/dist/node/include/node_dotenv.h +45 -0
- package/dist/node/include/node_errors.h +380 -0
- package/dist/node/include/node_exit_code.h +54 -0
- package/dist/node/include/node_external_reference.h +165 -0
- package/dist/node/include/node_file-inl.h +406 -0
- package/dist/node/include/node_file.h +537 -0
- package/dist/node/include/node_http2.h +1177 -0
- package/dist/node/include/node_http2_state.h +159 -0
- package/dist/node/include/node_http_common-inl.h +202 -0
- package/dist/node/include/node_http_common.h +535 -0
- package/dist/node/include/node_i18n.h +132 -0
- package/dist/node/include/node_internals.h +483 -0
- package/dist/node/include/node_main_instance.h +67 -0
- package/dist/node/include/node_mem-inl.h +113 -0
- package/dist/node/include/node_mem.h +45 -0
- package/dist/node/include/node_messaging.h +389 -0
- package/dist/node/include/node_metadata.h +164 -0
- package/dist/node/include/node_modules.h +91 -0
- package/dist/node/include/node_mutex.h +323 -0
- package/dist/node/include/node_object_wrap.h +132 -0
- package/dist/node/include/node_options-inl.h +490 -0
- package/dist/node/include/node_options.h +615 -0
- package/dist/node/include/node_perf.h +166 -0
- package/dist/node/include/node_perf_common.h +102 -0
- package/dist/node/include/node_platform.h +238 -0
- package/dist/node/include/node_process-inl.h +26 -0
- package/dist/node/include/node_process.h +112 -0
- package/dist/node/include/node_realm-inl.h +151 -0
- package/dist/node/include/node_realm.h +183 -0
- package/dist/node/include/node_report.h +43 -0
- package/dist/node/include/node_revert.h +82 -0
- package/dist/node/include/node_root_certs.h +3520 -0
- package/dist/node/include/node_sea.h +74 -0
- package/dist/node/include/node_shadow_realm.h +46 -0
- package/dist/node/include/node_snapshot_builder.h +57 -0
- package/dist/node/include/node_snapshotable.h +174 -0
- package/dist/node/include/node_sockaddr-inl.h +257 -0
- package/dist/node/include/node_sockaddr.h +394 -0
- package/dist/node/include/node_sqlite.h +270 -0
- package/dist/node/include/node_stat_watcher.h +73 -0
- package/dist/node/include/node_task_runner.h +92 -0
- package/dist/node/include/node_threadsafe_cow-inl.h +54 -0
- package/dist/node/include/node_threadsafe_cow.h +105 -0
- package/dist/node/include/node_union_bytes.h +81 -0
- package/dist/node/include/node_url.h +96 -0
- package/dist/node/include/node_v8.h +77 -0
- package/dist/node/include/node_v8_platform-inl.h +185 -0
- package/dist/node/include/node_version.h +110 -0
- package/dist/node/include/node_wasi.h +184 -0
- package/dist/node/include/node_wasm_web_api.h +55 -0
- package/dist/node/include/node_watchdog.h +154 -0
- package/dist/node/include/node_webstorage.h +60 -0
- package/dist/node/include/node_worker.h +158 -0
- package/dist/node/include/path.h +33 -0
- package/dist/node/include/permission/addon_permission.h +31 -0
- package/dist/node/include/permission/child_process_permission.h +31 -0
- package/dist/node/include/permission/fs_permission.h +167 -0
- package/dist/node/include/permission/inspector_permission.h +31 -0
- package/dist/node/include/permission/permission.h +138 -0
- package/dist/node/include/permission/permission_base.h +65 -0
- package/dist/node/include/permission/wasi_permission.h +31 -0
- package/dist/node/include/permission/worker_permission.h +31 -0
- package/dist/node/include/pipe_wrap.h +80 -0
- package/dist/node/include/quic/application.h +159 -0
- package/dist/node/include/quic/bindingdata.h +272 -0
- package/dist/node/include/quic/cid.h +127 -0
- package/dist/node/include/quic/data.h +148 -0
- package/dist/node/include/quic/defs.h +245 -0
- package/dist/node/include/quic/endpoint.h +458 -0
- package/dist/node/include/quic/http3.h +15 -0
- package/dist/node/include/quic/logstream.h +81 -0
- package/dist/node/include/quic/packet.h +152 -0
- package/dist/node/include/quic/preferredaddress.h +72 -0
- package/dist/node/include/quic/session.h +443 -0
- package/dist/node/include/quic/sessionticket.h +108 -0
- package/dist/node/include/quic/streams.h +232 -0
- package/dist/node/include/quic/tlscontext.h +227 -0
- package/dist/node/include/quic/tokens.h +256 -0
- package/dist/node/include/quic/transportparams.h +165 -0
- package/dist/node/include/req_wrap-inl.h +171 -0
- package/dist/node/include/req_wrap.h +77 -0
- package/dist/node/include/spawn_sync.h +243 -0
- package/dist/node/include/stream_base-inl.h +173 -0
- package/dist/node/include/stream_base.h +478 -0
- package/dist/node/include/stream_pipe.h +76 -0
- package/dist/node/include/stream_wrap.h +132 -0
- package/dist/node/include/string_bytes.h +113 -0
- package/dist/node/include/string_decoder-inl.h +31 -0
- package/dist/node/include/string_decoder.h +49 -0
- package/dist/node/include/tcp_wrap.h +105 -0
- package/dist/node/include/threadpoolwork-inl.h +70 -0
- package/dist/node/include/timer_wrap-inl.h +32 -0
- package/dist/node/include/timer_wrap.h +85 -0
- package/dist/node/include/timers.h +70 -0
- package/dist/node/include/tracing/agent.h +195 -0
- package/dist/node/include/tracing/node_trace_buffer.h +83 -0
- package/dist/node/include/tracing/node_trace_writer.h +75 -0
- package/dist/node/include/tracing/trace_event.h +722 -0
- package/dist/node/include/tracing/trace_event_common.h +1109 -0
- package/dist/node/include/tracing/traced_value.h +129 -0
- package/dist/node/include/tty_wrap.h +65 -0
- package/dist/node/include/udp_wrap.h +230 -0
- package/dist/node/include/undici_version.h +6 -0
- package/dist/node/include/util-inl.h +700 -0
- package/dist/node/include/util.h +1021 -0
- package/dist/node/include/uv/aix.h +32 -0
- package/dist/node/include/uv/bsd.h +34 -0
- package/dist/node/include/uv/darwin.h +61 -0
- package/dist/node/include/uv/errno.h +483 -0
- package/dist/node/include/uv/linux.h +34 -0
- package/dist/node/include/uv/os390.h +33 -0
- package/dist/node/include/uv/posix.h +31 -0
- package/dist/node/include/uv/sunos.h +44 -0
- package/dist/node/include/uv/threadpool.h +37 -0
- package/dist/node/include/uv/tree.h +521 -0
- package/dist/node/include/uv/unix.h +512 -0
- package/dist/node/include/uv/version.h +43 -0
- package/dist/node/include/uv/win.h +698 -0
- package/dist/node/include/uv.h +1990 -0
- package/dist/node/include/v8-array-buffer.h +525 -0
- package/dist/node/include/v8-callbacks.h +462 -0
- package/dist/node/include/v8-container.h +183 -0
- package/dist/node/include/v8-context.h +485 -0
- package/dist/node/include/v8-cppgc.h +245 -0
- package/dist/node/include/v8-data.h +80 -0
- package/dist/node/include/v8-date.h +48 -0
- package/dist/node/include/v8-debug.h +168 -0
- package/dist/node/include/v8-embedder-heap.h +82 -0
- package/dist/node/include/v8-embedder-state-scope.h +52 -0
- package/dist/node/include/v8-exception.h +223 -0
- package/dist/node/include/v8-extension.h +62 -0
- package/dist/node/include/v8-external.h +37 -0
- package/dist/node/include/v8-fast-api-calls.h +984 -0
- package/dist/node/include/v8-forward.h +82 -0
- package/dist/node/include/v8-function-callback.h +607 -0
- package/dist/node/include/v8-function.h +140 -0
- package/dist/node/include/v8-handle-base.h +137 -0
- package/dist/node/include/v8-initialization.h +289 -0
- package/dist/node/include/v8-inspector-protocol.h +13 -0
- package/dist/node/include/v8-inspector.h +419 -0
- package/dist/node/include/v8-internal.h +1397 -0
- package/dist/node/include/v8-isolate.h +1767 -0
- package/dist/node/include/v8-json.h +47 -0
- package/dist/node/include/v8-local-handle.h +758 -0
- package/dist/node/include/v8-locker.h +138 -0
- package/dist/node/include/v8-maybe.h +160 -0
- package/dist/node/include/v8-memory-span.h +198 -0
- package/dist/node/include/v8-message.h +233 -0
- package/dist/node/include/v8-metrics.h +264 -0
- package/dist/node/include/v8-microtask-queue.h +157 -0
- package/dist/node/include/v8-microtask.h +28 -0
- package/dist/node/include/v8-object.h +824 -0
- package/dist/node/include/v8-persistent-handle.h +582 -0
- package/dist/node/include/v8-platform.h +1358 -0
- package/dist/node/include/v8-primitive-object.h +118 -0
- package/dist/node/include/v8-primitive.h +877 -0
- package/dist/node/include/v8-profiler.h +1302 -0
- package/dist/node/include/v8-promise.h +174 -0
- package/dist/node/include/v8-proxy.h +50 -0
- package/dist/node/include/v8-regexp.h +106 -0
- package/dist/node/include/v8-script.h +904 -0
- package/dist/node/include/v8-snapshot.h +266 -0
- package/dist/node/include/v8-source-location.h +92 -0
- package/dist/node/include/v8-statistics.h +238 -0
- package/dist/node/include/v8-template.h +1297 -0
- package/dist/node/include/v8-traced-handle.h +432 -0
- package/dist/node/include/v8-typed-array.h +390 -0
- package/dist/node/include/v8-unwinder-state.h +31 -0
- package/dist/node/include/v8-unwinder.h +132 -0
- package/dist/node/include/v8-util.h +665 -0
- package/dist/node/include/v8-value-serializer-version.h +24 -0
- package/dist/node/include/v8-value-serializer.h +316 -0
- package/dist/node/include/v8-value.h +655 -0
- package/dist/node/include/v8-version-string.h +38 -0
- package/dist/node/include/v8-version.h +20 -0
- package/dist/node/include/v8-wasm-trap-handler-posix.h +31 -0
- package/dist/node/include/v8-wasm-trap-handler-win.h +28 -0
- package/dist/node/include/v8-wasm.h +201 -0
- package/dist/node/include/v8-weak-callback-info.h +80 -0
- package/dist/node/include/v8.h +88 -0
- package/dist/node/include/v8config.h +981 -0
- package/dist/node/include/zlib_version.h +6 -0
- package/dist/node/libnode.dll +0 -0
- package/dist/node/libnode.lib +0 -0
- package/dist/node/libnodebuildinfo.json +10 -0
- package/dist/node/link_node.lib +0 -0
- package/dist/node/link_node.node +0 -0
- package/libnode.release.json +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
// Copyright 2020 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_CPPGC_H_
|
|
6
|
+
#define INCLUDE_V8_CPPGC_H_
|
|
7
|
+
|
|
8
|
+
#include <cstdint>
|
|
9
|
+
#include <memory>
|
|
10
|
+
#include <vector>
|
|
11
|
+
|
|
12
|
+
#include "cppgc/common.h"
|
|
13
|
+
#include "cppgc/custom-space.h"
|
|
14
|
+
#include "cppgc/heap-statistics.h"
|
|
15
|
+
#include "cppgc/visitor.h"
|
|
16
|
+
#include "v8-internal.h" // NOLINT(build/include_directory)
|
|
17
|
+
#include "v8-platform.h" // NOLINT(build/include_directory)
|
|
18
|
+
#include "v8-traced-handle.h" // NOLINT(build/include_directory)
|
|
19
|
+
|
|
20
|
+
namespace cppgc {
|
|
21
|
+
class AllocationHandle;
|
|
22
|
+
class HeapHandle;
|
|
23
|
+
} // namespace cppgc
|
|
24
|
+
|
|
25
|
+
namespace v8 {
|
|
26
|
+
|
|
27
|
+
class Object;
|
|
28
|
+
|
|
29
|
+
namespace internal {
|
|
30
|
+
class CppHeap;
|
|
31
|
+
} // namespace internal
|
|
32
|
+
|
|
33
|
+
class CustomSpaceStatisticsReceiver;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Describes how V8 wrapper objects maintain references to garbage-collected C++
|
|
37
|
+
* objects.
|
|
38
|
+
*/
|
|
39
|
+
struct WrapperDescriptor final {
|
|
40
|
+
/**
|
|
41
|
+
* The index used on `v8::Ojbect::SetAlignedPointerFromInternalField()` and
|
|
42
|
+
* related APIs to add additional data to an object which is used to identify
|
|
43
|
+
* JS->C++ references.
|
|
44
|
+
*/
|
|
45
|
+
using InternalFieldIndex = int;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Unknown embedder id. The value is reserved for internal usages and must not
|
|
49
|
+
* be used with `CppHeap`.
|
|
50
|
+
*/
|
|
51
|
+
static constexpr uint16_t kUnknownEmbedderId = UINT16_MAX;
|
|
52
|
+
|
|
53
|
+
constexpr WrapperDescriptor(InternalFieldIndex wrappable_type_index,
|
|
54
|
+
InternalFieldIndex wrappable_instance_index,
|
|
55
|
+
uint16_t embedder_id_for_garbage_collected)
|
|
56
|
+
: wrappable_type_index(wrappable_type_index),
|
|
57
|
+
wrappable_instance_index(wrappable_instance_index),
|
|
58
|
+
embedder_id_for_garbage_collected(embedder_id_for_garbage_collected) {}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Index of the wrappable type.
|
|
62
|
+
*/
|
|
63
|
+
InternalFieldIndex wrappable_type_index;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Index of the wrappable instance.
|
|
67
|
+
*/
|
|
68
|
+
InternalFieldIndex wrappable_instance_index;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Embedder id identifying instances of garbage-collected objects. It is
|
|
72
|
+
* expected that the first field of the wrappable type is a uint16_t holding
|
|
73
|
+
* the id. Only references to instances of wrappables types with an id of
|
|
74
|
+
* `embedder_id_for_garbage_collected` will be considered by CppHeap.
|
|
75
|
+
*/
|
|
76
|
+
uint16_t embedder_id_for_garbage_collected;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
struct V8_EXPORT CppHeapCreateParams {
|
|
80
|
+
CppHeapCreateParams(
|
|
81
|
+
std::vector<std::unique_ptr<cppgc::CustomSpaceBase>> custom_spaces,
|
|
82
|
+
WrapperDescriptor wrapper_descriptor)
|
|
83
|
+
: custom_spaces(std::move(custom_spaces)),
|
|
84
|
+
wrapper_descriptor(wrapper_descriptor) {}
|
|
85
|
+
|
|
86
|
+
CppHeapCreateParams(const CppHeapCreateParams&) = delete;
|
|
87
|
+
CppHeapCreateParams& operator=(const CppHeapCreateParams&) = delete;
|
|
88
|
+
|
|
89
|
+
std::vector<std::unique_ptr<cppgc::CustomSpaceBase>> custom_spaces;
|
|
90
|
+
WrapperDescriptor wrapper_descriptor;
|
|
91
|
+
/**
|
|
92
|
+
* Specifies which kind of marking are supported by the heap. The type may be
|
|
93
|
+
* further reduced via runtime flags when attaching the heap to an Isolate.
|
|
94
|
+
*/
|
|
95
|
+
cppgc::Heap::MarkingType marking_support =
|
|
96
|
+
cppgc::Heap::MarkingType::kIncrementalAndConcurrent;
|
|
97
|
+
/**
|
|
98
|
+
* Specifies which kind of sweeping is supported by the heap. The type may be
|
|
99
|
+
* further reduced via runtime flags when attaching the heap to an Isolate.
|
|
100
|
+
*/
|
|
101
|
+
cppgc::Heap::SweepingType sweeping_support =
|
|
102
|
+
cppgc::Heap::SweepingType::kIncrementalAndConcurrent;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A heap for allocating managed C++ objects.
|
|
107
|
+
*
|
|
108
|
+
* Similar to v8::Isolate, the heap may only be accessed from one thread at a
|
|
109
|
+
* time. The heap may be used from different threads using the
|
|
110
|
+
* v8::Locker/v8::Unlocker APIs which is different from generic Oilpan.
|
|
111
|
+
*/
|
|
112
|
+
class V8_EXPORT CppHeap {
|
|
113
|
+
public:
|
|
114
|
+
static std::unique_ptr<CppHeap> Create(v8::Platform* platform,
|
|
115
|
+
const CppHeapCreateParams& params);
|
|
116
|
+
|
|
117
|
+
virtual ~CppHeap() = default;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* \returns the opaque handle for allocating objects using
|
|
121
|
+
* `MakeGarbageCollected()`.
|
|
122
|
+
*/
|
|
123
|
+
cppgc::AllocationHandle& GetAllocationHandle();
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* \returns the opaque heap handle which may be used to refer to this heap in
|
|
127
|
+
* other APIs. Valid as long as the underlying `CppHeap` is alive.
|
|
128
|
+
*/
|
|
129
|
+
cppgc::HeapHandle& GetHeapHandle();
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Terminate clears all roots and performs multiple garbage collections to
|
|
133
|
+
* reclaim potentially newly created objects in destructors.
|
|
134
|
+
*
|
|
135
|
+
* After this call, object allocation is prohibited.
|
|
136
|
+
*/
|
|
137
|
+
void Terminate();
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* \param detail_level specifies whether should return detailed
|
|
141
|
+
* statistics or only brief summary statistics.
|
|
142
|
+
* \returns current CppHeap statistics regarding memory consumption
|
|
143
|
+
* and utilization.
|
|
144
|
+
*/
|
|
145
|
+
cppgc::HeapStatistics CollectStatistics(
|
|
146
|
+
cppgc::HeapStatistics::DetailLevel detail_level);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Collects statistics for the given spaces and reports them to the receiver.
|
|
150
|
+
*
|
|
151
|
+
* \param custom_spaces a collection of custom space indicies.
|
|
152
|
+
* \param receiver an object that gets the results.
|
|
153
|
+
*/
|
|
154
|
+
void CollectCustomSpaceStatisticsAtLastGC(
|
|
155
|
+
std::vector<cppgc::CustomSpaceIndex> custom_spaces,
|
|
156
|
+
std::unique_ptr<CustomSpaceStatisticsReceiver> receiver);
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Enables a detached mode that allows testing garbage collection using
|
|
160
|
+
* `cppgc::testing` APIs. Once used, the heap cannot be attached to an
|
|
161
|
+
* `Isolate` anymore.
|
|
162
|
+
*/
|
|
163
|
+
void EnableDetachedGarbageCollectionsForTesting();
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Performs a stop-the-world garbage collection for testing purposes.
|
|
167
|
+
*
|
|
168
|
+
* \param stack_state The stack state to assume for the garbage collection.
|
|
169
|
+
*/
|
|
170
|
+
void CollectGarbageForTesting(cppgc::EmbedderStackState stack_state);
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Performs a stop-the-world minor garbage collection for testing purposes.
|
|
174
|
+
*
|
|
175
|
+
* \param stack_state The stack state to assume for the garbage collection.
|
|
176
|
+
*/
|
|
177
|
+
void CollectGarbageInYoungGenerationForTesting(
|
|
178
|
+
cppgc::EmbedderStackState stack_state);
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* \returns the wrapper descriptor of this CppHeap.
|
|
182
|
+
*/
|
|
183
|
+
v8::WrapperDescriptor wrapper_descriptor() const;
|
|
184
|
+
|
|
185
|
+
private:
|
|
186
|
+
CppHeap() = default;
|
|
187
|
+
|
|
188
|
+
friend class internal::CppHeap;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
class JSVisitor : public cppgc::Visitor {
|
|
192
|
+
public:
|
|
193
|
+
explicit JSVisitor(cppgc::Visitor::Key key) : cppgc::Visitor(key) {}
|
|
194
|
+
~JSVisitor() override = default;
|
|
195
|
+
|
|
196
|
+
void Trace(const TracedReferenceBase& ref) {
|
|
197
|
+
if (ref.IsEmptyThreadSafe()) return;
|
|
198
|
+
Visit(ref);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
protected:
|
|
202
|
+
using cppgc::Visitor::Visit;
|
|
203
|
+
|
|
204
|
+
virtual void Visit(const TracedReferenceBase& ref) {}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Provided as input to `CppHeap::CollectCustomSpaceStatisticsAtLastGC()`.
|
|
209
|
+
*
|
|
210
|
+
* Its method is invoked with the results of the statistic collection.
|
|
211
|
+
*/
|
|
212
|
+
class CustomSpaceStatisticsReceiver {
|
|
213
|
+
public:
|
|
214
|
+
virtual ~CustomSpaceStatisticsReceiver() = default;
|
|
215
|
+
/**
|
|
216
|
+
* Reports the size of a space at the last GC. It is called for each space
|
|
217
|
+
* that was requested in `CollectCustomSpaceStatisticsAtLastGC()`.
|
|
218
|
+
*
|
|
219
|
+
* \param space_index The index of the space.
|
|
220
|
+
* \param bytes The total size of live objects in the space at the last GC.
|
|
221
|
+
* It is zero if there was no GC yet.
|
|
222
|
+
*/
|
|
223
|
+
virtual void AllocatedBytes(cppgc::CustomSpaceIndex space_index,
|
|
224
|
+
size_t bytes) = 0;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
} // namespace v8
|
|
228
|
+
|
|
229
|
+
namespace cppgc {
|
|
230
|
+
|
|
231
|
+
template <typename T>
|
|
232
|
+
struct TraceTrait<v8::TracedReference<T>> {
|
|
233
|
+
static cppgc::TraceDescriptor GetTraceDescriptor(const void* self) {
|
|
234
|
+
return {nullptr, Trace};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
static void Trace(Visitor* visitor, const void* self) {
|
|
238
|
+
static_cast<v8::JSVisitor*>(visitor)->Trace(
|
|
239
|
+
*static_cast<const v8::TracedReference<T>*>(self));
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
} // namespace cppgc
|
|
244
|
+
|
|
245
|
+
#endif // INCLUDE_V8_CPPGC_H_
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Copyright 2021 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_DATA_H_
|
|
6
|
+
#define INCLUDE_V8_DATA_H_
|
|
7
|
+
|
|
8
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
|
9
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
10
|
+
|
|
11
|
+
namespace v8 {
|
|
12
|
+
|
|
13
|
+
class Context;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The superclass of objects that can reside on V8's heap.
|
|
17
|
+
*/
|
|
18
|
+
class V8_EXPORT Data {
|
|
19
|
+
public:
|
|
20
|
+
/**
|
|
21
|
+
* Returns true if this data is a |v8::Value|.
|
|
22
|
+
*/
|
|
23
|
+
bool IsValue() const;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Returns true if this data is a |v8::Module|.
|
|
27
|
+
*/
|
|
28
|
+
bool IsModule() const;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Returns tru if this data is a |v8::FixedArray|
|
|
32
|
+
*/
|
|
33
|
+
bool IsFixedArray() const;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns true if this data is a |v8::Private|.
|
|
37
|
+
*/
|
|
38
|
+
bool IsPrivate() const;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns true if this data is a |v8::ObjectTemplate|.
|
|
42
|
+
*/
|
|
43
|
+
bool IsObjectTemplate() const;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns true if this data is a |v8::FunctionTemplate|.
|
|
47
|
+
*/
|
|
48
|
+
bool IsFunctionTemplate() const;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns true if this data is a |v8::Context|.
|
|
52
|
+
*/
|
|
53
|
+
bool IsContext() const;
|
|
54
|
+
|
|
55
|
+
private:
|
|
56
|
+
Data() = delete;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A fixed-sized array with elements of type Data.
|
|
61
|
+
*/
|
|
62
|
+
class V8_EXPORT FixedArray : public Data {
|
|
63
|
+
public:
|
|
64
|
+
int Length() const;
|
|
65
|
+
Local<Data> Get(Local<Context> context, int i) const;
|
|
66
|
+
|
|
67
|
+
V8_INLINE static FixedArray* Cast(Data* data) {
|
|
68
|
+
#ifdef V8_ENABLE_CHECKS
|
|
69
|
+
CheckCast(data);
|
|
70
|
+
#endif
|
|
71
|
+
return reinterpret_cast<FixedArray*>(data);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private:
|
|
75
|
+
static void CheckCast(Data* obj);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
} // namespace v8
|
|
79
|
+
|
|
80
|
+
#endif // INCLUDE_V8_DATA_H_
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright 2021 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_DATE_H_
|
|
6
|
+
#define INCLUDE_V8_DATE_H_
|
|
7
|
+
|
|
8
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
|
9
|
+
#include "v8-object.h" // NOLINT(build/include_directory)
|
|
10
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
11
|
+
|
|
12
|
+
namespace v8 {
|
|
13
|
+
|
|
14
|
+
class Context;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* An instance of the built-in Date constructor (ECMA-262, 15.9).
|
|
18
|
+
*/
|
|
19
|
+
class V8_EXPORT Date : public Object {
|
|
20
|
+
public:
|
|
21
|
+
static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context,
|
|
22
|
+
double time);
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A specialization of Value::NumberValue that is more efficient
|
|
26
|
+
* because we know the structure of this object.
|
|
27
|
+
*/
|
|
28
|
+
double ValueOf() const;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Generates ISO string representation.
|
|
32
|
+
*/
|
|
33
|
+
v8::Local<v8::String> ToISOString() const;
|
|
34
|
+
|
|
35
|
+
V8_INLINE static Date* Cast(Value* value) {
|
|
36
|
+
#ifdef V8_ENABLE_CHECKS
|
|
37
|
+
CheckCast(value);
|
|
38
|
+
#endif
|
|
39
|
+
return static_cast<Date*>(value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private:
|
|
43
|
+
static void CheckCast(Value* obj);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace v8
|
|
47
|
+
|
|
48
|
+
#endif // INCLUDE_V8_DATE_H_
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Copyright 2021 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_DEBUG_H_
|
|
6
|
+
#define INCLUDE_V8_DEBUG_H_
|
|
7
|
+
|
|
8
|
+
#include <stdint.h>
|
|
9
|
+
|
|
10
|
+
#include "v8-script.h" // NOLINT(build/include_directory)
|
|
11
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
12
|
+
|
|
13
|
+
namespace v8 {
|
|
14
|
+
|
|
15
|
+
class Isolate;
|
|
16
|
+
class String;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A single JavaScript stack frame.
|
|
20
|
+
*/
|
|
21
|
+
class V8_EXPORT StackFrame {
|
|
22
|
+
public:
|
|
23
|
+
/**
|
|
24
|
+
* Returns the source location, 0-based, for the associated function call.
|
|
25
|
+
*/
|
|
26
|
+
Location GetLocation() const;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns the number, 1-based, of the line for the associate function call.
|
|
30
|
+
* This method will return Message::kNoLineNumberInfo if it is unable to
|
|
31
|
+
* retrieve the line number, or if kLineNumber was not passed as an option
|
|
32
|
+
* when capturing the StackTrace.
|
|
33
|
+
*/
|
|
34
|
+
int GetLineNumber() const { return GetLocation().GetLineNumber() + 1; }
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns the 1-based column offset on the line for the associated function
|
|
38
|
+
* call.
|
|
39
|
+
* This method will return Message::kNoColumnInfo if it is unable to retrieve
|
|
40
|
+
* the column number, or if kColumnOffset was not passed as an option when
|
|
41
|
+
* capturing the StackTrace.
|
|
42
|
+
*/
|
|
43
|
+
int GetColumn() const { return GetLocation().GetColumnNumber() + 1; }
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns the id of the script for the function for this StackFrame.
|
|
47
|
+
* This method will return Message::kNoScriptIdInfo if it is unable to
|
|
48
|
+
* retrieve the script id, or if kScriptId was not passed as an option when
|
|
49
|
+
* capturing the StackTrace.
|
|
50
|
+
*/
|
|
51
|
+
int GetScriptId() const;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Returns the name of the resource that contains the script for the
|
|
55
|
+
* function for this StackFrame.
|
|
56
|
+
*/
|
|
57
|
+
Local<String> GetScriptName() const;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Returns the name of the resource that contains the script for the
|
|
61
|
+
* function for this StackFrame or sourceURL value if the script name
|
|
62
|
+
* is undefined and its source ends with //# sourceURL=... string or
|
|
63
|
+
* deprecated //@ sourceURL=... string.
|
|
64
|
+
*/
|
|
65
|
+
Local<String> GetScriptNameOrSourceURL() const;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns the source of the script for the function for this StackFrame.
|
|
69
|
+
*/
|
|
70
|
+
Local<String> GetScriptSource() const;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Returns the source mapping URL (if one is present) of the script for
|
|
74
|
+
* the function for this StackFrame.
|
|
75
|
+
*/
|
|
76
|
+
Local<String> GetScriptSourceMappingURL() const;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Returns the name of the function associated with this stack frame.
|
|
80
|
+
*/
|
|
81
|
+
Local<String> GetFunctionName() const;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns whether or not the associated function is compiled via a call to
|
|
85
|
+
* eval().
|
|
86
|
+
*/
|
|
87
|
+
bool IsEval() const;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Returns whether or not the associated function is called as a
|
|
91
|
+
* constructor via "new".
|
|
92
|
+
*/
|
|
93
|
+
bool IsConstructor() const;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Returns whether or not the associated functions is defined in wasm.
|
|
97
|
+
*/
|
|
98
|
+
bool IsWasm() const;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Returns whether or not the associated function is defined by the user.
|
|
102
|
+
*/
|
|
103
|
+
bool IsUserJavaScript() const;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Representation of a JavaScript stack trace. The information collected is a
|
|
108
|
+
* snapshot of the execution stack and the information remains valid after
|
|
109
|
+
* execution continues.
|
|
110
|
+
*/
|
|
111
|
+
class V8_EXPORT StackTrace {
|
|
112
|
+
public:
|
|
113
|
+
/**
|
|
114
|
+
* Flags that determine what information is placed captured for each
|
|
115
|
+
* StackFrame when grabbing the current stack trace.
|
|
116
|
+
* Note: these options are deprecated and we always collect all available
|
|
117
|
+
* information (kDetailed).
|
|
118
|
+
*/
|
|
119
|
+
enum StackTraceOptions {
|
|
120
|
+
kLineNumber = 1,
|
|
121
|
+
kColumnOffset = 1 << 1 | kLineNumber,
|
|
122
|
+
kScriptName = 1 << 2,
|
|
123
|
+
kFunctionName = 1 << 3,
|
|
124
|
+
kIsEval = 1 << 4,
|
|
125
|
+
kIsConstructor = 1 << 5,
|
|
126
|
+
kScriptNameOrSourceURL = 1 << 6,
|
|
127
|
+
kScriptId = 1 << 7,
|
|
128
|
+
kExposeFramesAcrossSecurityOrigins = 1 << 8,
|
|
129
|
+
kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
|
|
130
|
+
kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Returns a StackFrame at a particular index.
|
|
135
|
+
*/
|
|
136
|
+
Local<StackFrame> GetFrame(Isolate* isolate, uint32_t index) const;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Returns the number of StackFrames.
|
|
140
|
+
*/
|
|
141
|
+
int GetFrameCount() const;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Grab a snapshot of the current JavaScript execution stack.
|
|
145
|
+
*
|
|
146
|
+
* \param frame_limit The maximum number of stack frames we want to capture.
|
|
147
|
+
* \param options Enumerates the set of things we will capture for each
|
|
148
|
+
* StackFrame.
|
|
149
|
+
*/
|
|
150
|
+
static Local<StackTrace> CurrentStackTrace(
|
|
151
|
+
Isolate* isolate, int frame_limit, StackTraceOptions options = kDetailed);
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Returns the first valid script name or source URL starting at the top of
|
|
155
|
+
* the JS stack. The returned string is either an empty handle if no script
|
|
156
|
+
* name/url was found or a non-zero-length string.
|
|
157
|
+
*
|
|
158
|
+
* This method is equivalent to calling StackTrace::CurrentStackTrace and
|
|
159
|
+
* walking the resulting frames from the beginning until a non-empty script
|
|
160
|
+
* name/url is found. The difference is that this method won't allocate
|
|
161
|
+
* a stack trace.
|
|
162
|
+
*/
|
|
163
|
+
static Local<String> CurrentScriptNameOrSourceURL(Isolate* isolate);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
} // namespace v8
|
|
167
|
+
|
|
168
|
+
#endif // INCLUDE_V8_DEBUG_H_
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Copyright 2021 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_EMBEDDER_HEAP_H_
|
|
6
|
+
#define INCLUDE_V8_EMBEDDER_HEAP_H_
|
|
7
|
+
|
|
8
|
+
#include "v8-traced-handle.h" // NOLINT(build/include_directory)
|
|
9
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
10
|
+
|
|
11
|
+
namespace v8 {
|
|
12
|
+
namespace internal {
|
|
13
|
+
class TracedHandles;
|
|
14
|
+
} // namespace internal
|
|
15
|
+
|
|
16
|
+
class Isolate;
|
|
17
|
+
class Value;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Handler for embedder roots on non-unified heap garbage collections.
|
|
21
|
+
*/
|
|
22
|
+
class V8_EXPORT EmbedderRootsHandler {
|
|
23
|
+
public:
|
|
24
|
+
enum class RootHandling {
|
|
25
|
+
kQueryEmbedderForNonDroppableReferences,
|
|
26
|
+
kDontQueryEmbedderForAnyReference,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
virtual ~EmbedderRootsHandler() = default;
|
|
30
|
+
|
|
31
|
+
EmbedderRootsHandler() = default;
|
|
32
|
+
explicit EmbedderRootsHandler(RootHandling default_traced_reference_handling)
|
|
33
|
+
: default_traced_reference_handling_(default_traced_reference_handling) {}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns true if the |TracedReference| handle should be considered as root
|
|
37
|
+
* for the currently running non-tracing garbage collection and false
|
|
38
|
+
* otherwise. The default implementation will keep all |TracedReference|
|
|
39
|
+
* references as roots.
|
|
40
|
+
*
|
|
41
|
+
* If this returns false, then V8 may decide that the object referred to by
|
|
42
|
+
* such a handle is reclaimed. In that case, V8 calls |ResetRoot()| for the
|
|
43
|
+
* |TracedReference|.
|
|
44
|
+
*
|
|
45
|
+
* Note that the `handle` is different from the handle that the embedder holds
|
|
46
|
+
* for retaining the object.
|
|
47
|
+
*
|
|
48
|
+
* The concrete implementations must be thread-safe.
|
|
49
|
+
*/
|
|
50
|
+
virtual bool IsRoot(const v8::TracedReference<v8::Value>& handle) = 0;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Used in combination with |IsRoot|. Called by V8 when an
|
|
54
|
+
* object that is backed by a handle is reclaimed by a non-tracing garbage
|
|
55
|
+
* collection. It is up to the embedder to reset the original handle.
|
|
56
|
+
*
|
|
57
|
+
* Note that the |handle| is different from the handle that the embedder holds
|
|
58
|
+
* for retaining the object. It is up to the embedder to find the original
|
|
59
|
+
* handle via the object or class id.
|
|
60
|
+
*/
|
|
61
|
+
virtual void ResetRoot(const v8::TracedReference<v8::Value>& handle) = 0;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Similar to |ResetRoot()|, but opportunistic. The function is called in
|
|
65
|
+
* parallel for different handles and as such must be thread-safe. In case,
|
|
66
|
+
* |false| is returned, |ResetRoot()| will be recalled for the same handle.
|
|
67
|
+
*/
|
|
68
|
+
virtual bool TryResetRoot(const v8::TracedReference<v8::Value>& handle) {
|
|
69
|
+
ResetRoot(handle);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private:
|
|
74
|
+
const RootHandling default_traced_reference_handling_ =
|
|
75
|
+
RootHandling::kQueryEmbedderForNonDroppableReferences;
|
|
76
|
+
|
|
77
|
+
friend class internal::TracedHandles;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace v8
|
|
81
|
+
|
|
82
|
+
#endif // INCLUDE_V8_EMBEDDER_HEAP_H_
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Copyright 2021 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_EMBEDDER_STATE_SCOPE_H_
|
|
6
|
+
#define INCLUDE_V8_EMBEDDER_STATE_SCOPE_H_
|
|
7
|
+
|
|
8
|
+
#include <memory>
|
|
9
|
+
|
|
10
|
+
#include "v8-internal.h" // NOLINT(build/include_directory)
|
|
11
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
|
12
|
+
|
|
13
|
+
namespace v8 {
|
|
14
|
+
|
|
15
|
+
class Context;
|
|
16
|
+
|
|
17
|
+
namespace internal {
|
|
18
|
+
class EmbedderState;
|
|
19
|
+
} // namespace internal
|
|
20
|
+
|
|
21
|
+
// A StateTag represents a possible state of the embedder.
|
|
22
|
+
enum class EmbedderStateTag : uint8_t {
|
|
23
|
+
// reserved
|
|
24
|
+
EMPTY = 0,
|
|
25
|
+
OTHER = 1,
|
|
26
|
+
// embedder can define any state after
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// A stack-allocated class that manages an embedder state on the isolate.
|
|
30
|
+
// After an EmbedderState scope has been created, a new embedder state will be
|
|
31
|
+
// pushed on the isolate stack.
|
|
32
|
+
class V8_EXPORT EmbedderStateScope {
|
|
33
|
+
public:
|
|
34
|
+
EmbedderStateScope(Isolate* isolate, Local<v8::Context> context,
|
|
35
|
+
EmbedderStateTag tag);
|
|
36
|
+
|
|
37
|
+
~EmbedderStateScope();
|
|
38
|
+
|
|
39
|
+
private:
|
|
40
|
+
// Declaring operator new and delete as deleted is not spec compliant.
|
|
41
|
+
// Therefore declare them private instead to disable dynamic alloc
|
|
42
|
+
void* operator new(size_t size);
|
|
43
|
+
void* operator new[](size_t size);
|
|
44
|
+
void operator delete(void*, size_t);
|
|
45
|
+
void operator delete[](void*, size_t);
|
|
46
|
+
|
|
47
|
+
std::unique_ptr<internal::EmbedderState> embedder_state_;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
} // namespace v8
|
|
51
|
+
|
|
52
|
+
#endif // INCLUDE_V8_EMBEDDER_STATE_SCOPE_H_
|