v8  9.0.257(node16.0.0)
V8 is Google's open source JavaScript engine
caged-heap-local-data.h
Go to the documentation of this file.
1 // Copyright 2020 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_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_
6 #define INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_
7 
8 #include <array>
9 
10 #include "cppgc/internal/api-constants.h"
11 #include "cppgc/internal/logging.h"
12 #include "cppgc/platform.h"
13 #include "v8config.h" // NOLINT(build/include_directory)
14 
15 namespace cppgc {
16 namespace internal {
17 
18 class HeapBase;
19 
20 #if defined(CPPGC_YOUNG_GENERATION)
21 
22 // AgeTable contains entries that correspond to 4KB memory regions. Each entry
23 // can be in one of three states: kOld, kYoung or kUnknown.
24 class AgeTable final {
25  static constexpr size_t kGranularityBits = 12; // 4KiB per byte.
26 
27  public:
28  enum class Age : uint8_t { kOld, kYoung, kUnknown };
29 
30  static constexpr size_t kEntrySizeInBytes = 1 << kGranularityBits;
31 
32  Age& operator[](uintptr_t offset) { return table_[entry(offset)]; }
33  Age operator[](uintptr_t offset) const { return table_[entry(offset)]; }
34 
36 
37  private:
38  static constexpr size_t kAgeTableSize =
40 
41  size_t entry(uintptr_t offset) const {
44  return entry;
45  }
46 
48 };
49 
50 static_assert(sizeof(AgeTable) == 1 * api_constants::kMB,
51  "Size of AgeTable is 1MB");
52 
53 #endif // CPPGC_YOUNG_GENERATION
54 
55 struct CagedHeapLocalData final {
56  explicit CagedHeapLocalData(HeapBase* heap_base) : heap_base(heap_base) {}
57 
59  HeapBase* heap_base = nullptr;
60 #if defined(CPPGC_YOUNG_GENERATION)
61  AgeTable age_table;
62 #endif
63 };
64 
65 } // namespace internal
66 } // namespace cppgc
67 
68 #endif // INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_
cppgc::internal::CagedHeapLocalData::is_incremental_marking_in_progress
bool is_incremental_marking_in_progress
Definition: caged-heap-local-data.h:58
cppgc
Definition: allocation.h:17
cppgc::internal::CagedHeapLocalData::CagedHeapLocalData
CagedHeapLocalData(HeapBase *heap_base)
Definition: caged-heap-local-data.h:56
cppgc::internal::CagedHeapLocalData::heap_base
HeapBase * heap_base
Definition: caged-heap-local-data.h:59
cppgc::internal
Definition: allocation.h:22