blob: f45039c8703b015a7b49b142135ef6513c1a3c70 [file] [log] [blame]
Rubin Xu7bc1b612021-02-16 09:38:50 +00001// 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#include "src/heap/cppgc/raw-heap.h"
6
7#include "src/heap/cppgc/heap-space.h"
8
9namespace cppgc {
10namespace internal {
11
12// static
13constexpr size_t RawHeap::kNumberOfRegularSpaces;
14
15RawHeap::RawHeap(
16 HeapBase* heap,
17 const std::vector<std::unique_ptr<CustomSpaceBase>>& custom_spaces)
18 : main_heap_(heap) {
19 size_t i = 0;
20 for (; i < static_cast<size_t>(RegularSpaceType::kLarge); ++i) {
21 spaces_.push_back(std::make_unique<NormalPageSpace>(this, i, false));
22 }
23 spaces_.push_back(std::make_unique<LargePageSpace>(
24 this, static_cast<size_t>(RegularSpaceType::kLarge)));
25 DCHECK_EQ(kNumberOfRegularSpaces, spaces_.size());
26 for (size_t j = 0; j < custom_spaces.size(); j++) {
27 spaces_.push_back(std::make_unique<NormalPageSpace>(
28 this, kNumberOfRegularSpaces + j, custom_spaces[j]->IsCompactable()));
29 }
30}
31
32RawHeap::~RawHeap() = default;
33
34} // namespace internal
35} // namespace cppgc