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

Unified Diff: src/heap/spaces.cc

Issue 2013713003: [heap] Switch to 500k pages (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix ReleaseOverReservedPages for no snapshot builds Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index b31aaf3998fd98a370b3a329dcfb992c12f9e112..18d8e228fbbee6659e950ecd8048a479f575b55e 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -1213,17 +1213,39 @@ Object* PagedSpace::FindObject(Address addr) {
return Smi::FromInt(0);
}
-bool PagedSpace::Expand() {
- int size = AreaSize();
- if (snapshotable() && !HasPages()) {
- size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity());
+int PagedSpace::AreaSizeDuringDeserialization() {
+ // Try to keep the memory as compact as possible for a snapshot. This way the
+ // heap stays small for small/empty scripts.
+ DCHECK(snapshotable());
+ DCHECK(!heap()->deserialization_complete());
+ uint32_t snapshot_requires =
+ Snapshot::SizeOfSnapshot(heap()->isolate(), identity());
+ if (snapshot_requires > 0) {
Hannes Payer (out of office) 2016/08/08 16:25:02 I think this if case should be a DCHECK and the el
Michael Lippautz 2016/08/09 11:30:25 Obsolete.
+ // Count how much we have served already.
+ size_t memory_served = 0;
+ for (Page* page : *this) {
+ memory_served += page->area_size();
Hannes Payer (out of office) 2016/08/08 16:25:02 size of actual objects would be more precise here.
Michael Lippautz 2016/08/09 11:30:25 Obsolete.
+ }
+ size_t needed = static_cast<size_t>(snapshot_requires) - memory_served;
+ const int area_size = MemoryAllocator::PageAreaSize(identity());
Hannes Payer (out of office) 2016/08/08 16:25:02 Just call AreaSize() here.
Michael Lippautz 2016/08/09 11:30:25 Obsolete.
+ if (needed >= static_cast<size_t>(area_size)) return area_size;
+ // Less than a page of memory needed. We need to allocate at least
+ // kMaxRegularHeapObjectSize of space.
+ if (needed < Page::kMaxRegularHeapObjectSize)
+ return Page::kMaxRegularHeapObjectSize;
+ return static_cast<int>(needed);
Hannes Payer (out of office) 2016/08/08 16:25:02 Maybe we should do a different approach here: How
Michael Lippautz 2016/08/09 11:30:25 Done.
}
+ return AreaSize();
+}
- if (!heap()->CanExpandOldGeneration(size)) return false;
+bool PagedSpace::Expand() {
+ int size = heap()->deserialization_complete()
+ ? AreaSize()
+ : AreaSizeDuringDeserialization();
+ if (!heap()->CanExpandOldGeneration(size)) return false;
Page* p = heap()->memory_allocator()->AllocatePage(size, this, executable());
if (p == nullptr) return false;
-
AccountCommitted(static_cast<intptr_t>(p->size()));
// Pages created during bootstrapping may contain immortal immovable objects.
« src/base/build_config.h ('K') | « src/heap/spaces.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698