1 // Copyright 2022 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_HANDLE_H_
6 #define INCLUDE_CPPGC_HEAP_HANDLE_H_
7 
8 #include "v8config.h"  // NOLINT(build/include_directory)
9 
10 namespace cppgc {
11 
12 namespace internal {
13 class HeapBase;
14 class WriteBarrierTypeForCagedHeapPolicy;
15 class WriteBarrierTypeForNonCagedHeapPolicy;
16 }  // namespace internal
17 
18 /**
19  * Opaque handle used for additional heap APIs.
20  */
21 class HeapHandle {
22  public:
23   // Deleted copy ctor to avoid treating the type by value.
24   HeapHandle(const HeapHandle&) = delete;
25   HeapHandle& operator=(const HeapHandle&) = delete;
26 
27  private:
28   HeapHandle() = default;
29 
is_incremental_marking_in_progress() const30   V8_INLINE bool is_incremental_marking_in_progress() const {
31     return is_incremental_marking_in_progress_;
32   }
33 
is_young_generation_enabled() const34   V8_INLINE bool is_young_generation_enabled() const {
35     return is_young_generation_enabled_;
36   }
37 
38   bool is_incremental_marking_in_progress_ = false;
39   bool is_young_generation_enabled_ = false;
40 
41   friend class internal::HeapBase;
42   friend class internal::WriteBarrierTypeForCagedHeapPolicy;
43   friend class internal::WriteBarrierTypeForNonCagedHeapPolicy;
44 };
45 
46 }  // namespace cppgc
47 
48 #endif  // INCLUDE_CPPGC_HEAP_HANDLE_H_
49