Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: src/heap/spaces-inl.h

Issue 1863983002: 🏄 [heap] Add page evacuation mode for new->old (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase on master Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HEAP_SPACES_INL_H_ 5 #ifndef V8_HEAP_SPACES_INL_H_
6 #define V8_HEAP_SPACES_INL_H_ 6 #define V8_HEAP_SPACES_INL_H_
7 7
8 #include "src/heap/incremental-marking.h" 8 #include "src/heap/incremental-marking.h"
9 #include "src/heap/spaces.h" 9 #include "src/heap/spaces.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 DCHECK(!chunk->IsFlagSet(in_to_space ? MemoryChunk::IN_FROM_SPACE 261 DCHECK(!chunk->IsFlagSet(in_to_space ? MemoryChunk::IN_FROM_SPACE
262 : MemoryChunk::IN_TO_SPACE)); 262 : MemoryChunk::IN_TO_SPACE));
263 NewSpacePage* page = static_cast<NewSpacePage*>(chunk); 263 NewSpacePage* page = static_cast<NewSpacePage*>(chunk);
264 heap->incremental_marking()->SetNewSpacePageFlags(page); 264 heap->incremental_marking()->SetNewSpacePageFlags(page);
265 return page; 265 return page;
266 } 266 }
267 267
268 // -------------------------------------------------------------------------- 268 // --------------------------------------------------------------------------
269 // PagedSpace 269 // PagedSpace
270 270
271 template <Page::InitializationMode mode>
271 Page* Page::Initialize(Heap* heap, MemoryChunk* chunk, Executability executable, 272 Page* Page::Initialize(Heap* heap, MemoryChunk* chunk, Executability executable,
272 PagedSpace* owner) { 273 PagedSpace* owner) {
273 Page* page = reinterpret_cast<Page*>(chunk); 274 Page* page = reinterpret_cast<Page*>(chunk);
274 page->mutex_ = new base::Mutex(); 275 page->mutex_ = new base::Mutex();
275 DCHECK(page->area_size() <= kAllocatableMemory); 276 DCHECK(page->area_size() <= kAllocatableMemory);
276 DCHECK(chunk->owner() == owner); 277 DCHECK(chunk->owner() == owner);
277 278
278 owner->IncreaseCapacity(page->area_size()); 279 owner->IncreaseCapacity(page->area_size());
279 heap->incremental_marking()->SetOldSpacePageFlags(chunk); 280 heap->incremental_marking()->SetOldSpacePageFlags(chunk);
280 281
281 // Make sure that categories are initialized before freeing the area. 282 // Make sure that categories are initialized before freeing the area.
282 page->InitializeFreeListCategories(); 283 page->InitializeFreeListCategories();
283 owner->Free(page->area_start(), page->area_size()); 284 // In the case we do not free the memory, we effectively account for the whole
285 // page as allocated memory that cannot be used for further allocations.
286 if (mode == kFreeMemory) {
287 owner->Free(page->area_start(), page->area_size());
288 }
284 289
285 return page; 290 return page;
286 } 291 }
287 292
293 Page* Page::Convert(NewSpacePage* old_page, PagedSpace* new_owner) {
294 old_page->set_owner(new_owner);
295 old_page->SetFlags(0, ~0);
296 new_owner->AccountCommitted(old_page->size());
297 Page* new_page = Page::Initialize<kDoNotFreeMemory>(
298 old_page->heap(), old_page, NOT_EXECUTABLE, new_owner);
299 new_page->InsertAfter(new_owner->anchor()->prev_page());
300 return new_page;
301 }
302
288 void Page::InitializeFreeListCategories() { 303 void Page::InitializeFreeListCategories() {
289 for (int i = kFirstCategory; i < kNumberOfCategories; i++) { 304 for (int i = kFirstCategory; i < kNumberOfCategories; i++) {
290 categories_[i].Initialize(static_cast<FreeListCategoryType>(i)); 305 categories_[i].Initialize(static_cast<FreeListCategoryType>(i));
291 } 306 }
292 } 307 }
293 308
294 void MemoryChunk::IncrementLiveBytesFromGC(HeapObject* object, int by) { 309 void MemoryChunk::IncrementLiveBytesFromGC(HeapObject* object, int by) {
295 MemoryChunk::FromAddress(object->address())->IncrementLiveBytes(by); 310 MemoryChunk::FromAddress(object->address())->IncrementLiveBytes(by);
296 } 311 }
297 312
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 other->allocation_info_.Reset(nullptr, nullptr); 725 other->allocation_info_.Reset(nullptr, nullptr);
711 return true; 726 return true;
712 } 727 }
713 return false; 728 return false;
714 } 729 }
715 730
716 } // namespace internal 731 } // namespace internal
717 } // namespace v8 732 } // namespace v8
718 733
719 #endif // V8_HEAP_SPACES_INL_H_ 734 #endif // V8_HEAP_SPACES_INL_H_
OLDNEW
« src/heap/spaces.h ('K') | « src/heap/spaces.cc ('k') | test/cctest/heap/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698