v8  9.4.146 (node 16.13.0)
V8 is Google's open source JavaScript engine
heap-state.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_CPPGC_HEAP_STATE_H_
6 #define INCLUDE_CPPGC_HEAP_STATE_H_
7 
8 #include "v8config.h" // NOLINT(build/include_directory)
9 
10 namespace cppgc {
11 
12 class HeapHandle;
13 
14 namespace subtle {
15 
16 /**
17  * Helpers to peek into heap-internal state.
18  */
19 class V8_EXPORT HeapState final {
20  public:
21  /**
22  * Returns whether the garbage collector is marking. This API is experimental
23  * and is expected to be removed in future.
24  *
25  * \param heap_handle The corresponding heap.
26  * \returns true if the garbage collector is currently marking, and false
27  * otherwise.
28  */
29  static bool IsMarking(const HeapHandle& heap_handle);
30 
31  /*
32  * Returns whether the garbage collector is sweeping. This API is experimental
33  * and is expected to be removed in future.
34  *
35  * \param heap_handle The corresponding heap.
36  * \returns true if the garbage collector is currently sweeping, and false
37  * otherwise.
38  */
39  static bool IsSweeping(const HeapHandle& heap_handle);
40 
41  /**
42  * Returns whether the garbage collector is in the atomic pause, i.e., the
43  * mutator is stopped from running. This API is experimental and is expected
44  * to be removed in future.
45  *
46  * \param heap_handle The corresponding heap.
47  * \returns true if the garbage collector is currently in the atomic pause,
48  * and false otherwise.
49  */
50  static bool IsInAtomicPause(const HeapHandle& heap_handle);
51 
52  /**
53  * Returns whether the last garbage collection was finalized conservatively
54  * (i.e., with a non-empty stack). This API is experimental and is expected to
55  * be removed in future.
56  *
57  * \param heap_handle The corresponding heap.
58  * \returns true if the last garbage collection was finalized conservatively,
59  * and false otherwise.
60  */
61  static bool PreviousGCWasConservative(const HeapHandle& heap_handle);
62 
63  private:
64  HeapState() = delete;
65 };
66 
67 } // namespace subtle
68 } // namespace cppgc
69 
70 #endif // INCLUDE_CPPGC_HEAP_STATE_H_