v8 14.1.146 (node 25.0.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
v8-embedder-heap.h
Go to the documentation of this file.
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
11namespace v8 {
12namespace internal {
13class TracedHandles;
14} // namespace internal
15
16class Isolate;
17class Value;
18
19/**
20 * Handler for embedder roots on non-unified heap garbage collections.
21 */
23 public:
24 virtual ~EmbedderRootsHandler() = default;
25
27
28 /**
29 * Used in combination with |IsRoot|. Called by V8 when an
30 * object that is backed by a handle is reclaimed by a non-tracing garbage
31 * collection. It is up to the embedder to reset the original handle.
32 *
33 * Note that the |handle| is different from the handle that the embedder holds
34 * for retaining the object. It is up to the embedder to find the original
35 * handle via the object or class id.
36 */
37 virtual void ResetRoot(const v8::TracedReference<v8::Value>& handle) = 0;
38
39 /**
40 * Similar to |ResetRoot()|, but opportunistic. The function is called in
41 * parallel for different handles and as such must be thread-safe. In case,
42 * |false| is returned, |ResetRoot()| will be recalled for the same handle.
43 */
44 virtual bool TryResetRoot(const v8::TracedReference<v8::Value>& handle) {
45 return false;
46 }
47
48 private:
49 friend class internal::TracedHandles;
50};
51
52} // namespace v8
53
54#endif // INCLUDE_V8_EMBEDDER_HEAP_H_
virtual bool TryResetRoot(const v8::TracedReference< v8::Value > &handle)
virtual ~EmbedderRootsHandler()=default
virtual void ResetRoot(const v8::TracedReference< v8::Value > &handle)=0
#define V8_EXPORT
Definition v8config.h:860