Coverage Report

Created: 2025-10-31 09:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/node/deps/v8/include/v8-embedder-heap.h
Line
Count
Source
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
  virtual ~EmbedderRootsHandler() = default;
25
26
  EmbedderRootsHandler() = default;
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
0
  virtual bool TryResetRoot(const v8::TracedReference<v8::Value>& handle) {
45
0
    return false;
46
0
  }
47
48
 private:
49
  friend class internal::TracedHandles;
50
};
51
52
}  // namespace v8
53
54
#endif  // INCLUDE_V8_EMBEDDER_HEAP_H_