v8  9.0.257(node16.0.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  private:
53  HeapState() = delete;
54 };
55 
56 } // namespace subtle
57 } // namespace cppgc
58 
59 #endif // INCLUDE_CPPGC_HEAP_STATE_H_
cppgc::subtle::HeapState::IsMarking
static bool IsMarking(const HeapHandle &heap_handle)
cppgc::subtle::HeapState::IsInAtomicPause
static bool IsInAtomicPause(const HeapHandle &heap_handle)
cppgc::subtle
Definition: cross-thread-persistent.h:310
cppgc
Definition: allocation.h:17
V8_EXPORT
#define V8_EXPORT
Definition: v8config.h:512
cppgc::subtle::HeapState::IsSweeping
static bool IsSweeping(const HeapHandle &heap_handle)