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 #include "src/heap/cppgc/raw-heap.h" 6 7 #include "src/heap/cppgc/heap-space.h" 8 9 namespace cppgc { 10 namespace internal { 11 12 // static 13 constexpr size_t RawHeap::kNumberOfRegularSpaces; 14 RawHeap(HeapBase * heap,const std::vector<std::unique_ptr<CustomSpaceBase>> & custom_spaces)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 32 RawHeap::~RawHeap() = default; 33 34 } // namespace internal 35 } // namespace cppgc 36