Index: src/heap/spaces-inl.h |
diff --git a/src/heap/spaces-inl.h b/src/heap/spaces-inl.h |
index 8a79ad027516270b3c9c921b6aa3eb24b11d9bbb..bdd779fc8a7e8ff57a98d0c8aebfd03eae47f9b1 100644 |
--- a/src/heap/spaces-inl.h |
+++ b/src/heap/spaces-inl.h |
@@ -169,6 +169,21 @@ LargePage* LargePageIterator::next() { |
// ----------------------------------------------------------------------------- |
// MemoryAllocator |
+template <typename PageType, MemoryAllocator::AllocationMode mode, |
+ typename SpaceType> |
+inline PageType* MemoryAllocator::AllocatePage(intptr_t size, SpaceType* owner, |
+ Executability executable) { |
+ MemoryChunk* chunk = nullptr; |
+ if (mode == kPooled) { |
+ chunk = AllocatePagePooled(owner, executable); |
+ } |
+ if (chunk == nullptr) { |
+ chunk = AllocateChunk(size, size, executable, owner); |
+ } |
+ if (chunk == nullptr) return nullptr; |
+ return PageType::Initialize(isolate_->heap(), chunk, executable, owner); |
+} |
+ |
#ifdef ENABLE_HEAP_PROTECTION |
void MemoryAllocator::Protect(Address start, size_t size) { |
@@ -251,6 +266,19 @@ AllocationSpace AllocationResult::RetrySpace() { |
return static_cast<AllocationSpace>(Smi::cast(object_)->value()); |
} |
+NewSpacePage* NewSpacePage::Initialize(Heap* heap, MemoryChunk* chunk, |
+ Executability executable, |
+ SemiSpace* owner) { |
+ DCHECK_EQ(executable, Executability::NOT_EXECUTABLE); |
+ bool in_to_space = (owner->id() != kFromSpace); |
+ chunk->SetFlag(in_to_space ? MemoryChunk::IN_TO_SPACE |
+ : MemoryChunk::IN_FROM_SPACE); |
+ DCHECK(!chunk->IsFlagSet(in_to_space ? MemoryChunk::IN_FROM_SPACE |
+ : MemoryChunk::IN_TO_SPACE)); |
+ NewSpacePage* page = static_cast<NewSpacePage*>(chunk); |
+ heap->incremental_marking()->SetNewSpacePageFlags(page); |
+ return page; |
+} |
// -------------------------------------------------------------------------- |
// PagedSpace |
@@ -261,6 +289,7 @@ Page* Page::Initialize(Heap* heap, MemoryChunk* chunk, Executability executable, |
page->mutex_ = new base::Mutex(); |
DCHECK(page->area_size() <= kAllocatableMemory); |
DCHECK(chunk->owner() == owner); |
+ |
owner->IncreaseCapacity(page->area_size()); |
heap->incremental_marking()->SetOldSpacePageFlags(chunk); |