v8 10.2.154 (node 18.16.0)
V8 is Google's open source JavaScript engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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;
24
30namespace internal {
31class Heap;
32} // namespace internal
33
37class HeapHandle;
38
40 public:
45
49 enum class StackSupport : uint8_t {
53 kSupportsConservativeStackScan,
58 kNoConservativeStackScan,
59 };
60
64 enum class MarkingType : uint8_t {
69 kAtomic,
74 kIncremental,
78 kIncrementalAndConcurrent
79 };
80
84 enum class SweepingType : uint8_t {
88 kAtomic,
93 kIncremental,
98 kIncrementalAndConcurrent
99 };
100
111 size_t initial_heap_size_bytes = 0;
112 };
113
118 struct HeapOptions {
124 static HeapOptions Default() { return {}; }
125
131 std::vector<std::unique_ptr<CustomSpaceBase>> custom_spaces;
132
141 StackSupport stack_support = StackSupport::kSupportsConservativeStackScan;
142
146 MarkingType marking_support = MarkingType::kIncrementalAndConcurrent;
147
151 SweepingType sweeping_support = SweepingType::kIncrementalAndConcurrent;
152
158 };
159
167 static std::unique_ptr<Heap> Create(
168 std::shared_ptr<Platform> platform,
169 HeapOptions options = HeapOptions::Default());
170
171 virtual ~Heap() = default;
172
183 const char* source, const char* reason,
184 StackState stack_state = StackState::kMayContainHeapPointers);
185
190 AllocationHandle& GetAllocationHandle();
191
196 HeapHandle& GetHeapHandle();
197
198 private:
199 Heap() = default;
200
201 friend class internal::Heap;
202};
203
204} // namespace cppgc
205
206#endif // INCLUDE_CPPGC_HEAP_H_
HeapHandle & GetHeapHandle()
MarkingType
Definition heap.h:64
StackSupport
Definition heap.h:49
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:84
EmbedderStackState
Definition common.h:16
std::vector< std::unique_ptr< CustomSpaceBase > > custom_spaces
Definition heap.h:131
static HeapOptions Default()
Definition heap.h:124
ResourceConstraints resource_constraints
Definition heap.h:157
#define V8_EXPORT
Definition v8config.h:578