v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
heap.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_HEAP_H_
6#define INCLUDE_CPPGC_HEAP_H_
7
8#include <cstddef>
9#include <cstdint>
10#include <memory>
11#include <vector>
12
13#include "cppgc/common.h"
14#include "cppgc/custom-space.h"
15#include "cppgc/platform.h"
16#include "v8config.h" // NOLINT(build/include_directory)
17
21namespace cppgc {
22
23class AllocationHandle;
24class HeapHandle;
25
31namespace internal {
32class Heap;
33} // namespace internal
34
36 public:
41
45 enum class StackSupport : uint8_t {
49 kSupportsConservativeStackScan,
54 kNoConservativeStackScan,
55 };
56
60 enum class MarkingType : uint8_t {
65 kAtomic,
70 kIncremental,
74 kIncrementalAndConcurrent
75 };
76
80 enum class SweepingType : uint8_t {
84 kAtomic,
89 kIncremental,
94 kIncrementalAndConcurrent
95 };
96
107 size_t initial_heap_size_bytes = 0;
108 };
109
114 struct HeapOptions {
120 static HeapOptions Default() { return {}; }
121
127 std::vector<std::unique_ptr<CustomSpaceBase>> custom_spaces;
128
137 StackSupport stack_support = StackSupport::kSupportsConservativeStackScan;
138
142 MarkingType marking_support = MarkingType::kIncrementalAndConcurrent;
143
147 SweepingType sweeping_support = SweepingType::kIncrementalAndConcurrent;
148
154 };
155
163 static std::unique_ptr<Heap> Create(
164 std::shared_ptr<Platform> platform,
165 HeapOptions options = HeapOptions::Default());
166
167 virtual ~Heap() = default;
168
179 const char* source, const char* reason,
180 StackState stack_state = StackState::kMayContainHeapPointers);
181
186 AllocationHandle& GetAllocationHandle();
187
193
194 private:
195 Heap() = default;
196
197 friend class internal::Heap;
198};
199
200} // namespace cppgc
201
202#endif // INCLUDE_CPPGC_HEAP_H_
HeapHandle & GetHeapHandle()
MarkingType
Definition heap.h:60
StackSupport
Definition heap.h:45
AllocationHandle & GetAllocationHandle()
static std::unique_ptr< Heap > Create(std::shared_ptr< Platform > platform, HeapOptions options=HeapOptions::Default())
void ForceGarbageCollectionSlow(const char *source, const char *reason, StackState stack_state=StackState::kMayContainHeapPointers)
virtual ~Heap()=default
SweepingType
Definition heap.h:80
EmbedderStackState
Definition common.h:15
std::vector< std::unique_ptr< CustomSpaceBase > > custom_spaces
Definition heap.h:127
static HeapOptions Default()
Definition heap.h:120
ResourceConstraints resource_constraints
Definition heap.h:153
#define V8_EXPORT
Definition v8config.h:753