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

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: Updating the constant used for determining wanted tasks 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
« no previous file with comments | « src/heap/spaces.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index 238fc9b39318b583f1580642a0484dec2be7db66..3fb21691959ad383ec17b10481204112dd62884d 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) {
+ // Count how much we have served already.
+ size_t memory_served = 0;
+ for (Page* page : *this) {
+ memory_served += page->area_size();
+ }
+ size_t needed = static_cast<size_t>(snapshot_requires) - memory_served;
+ const int area_size = MemoryAllocator::PageAreaSize(identity());
+ if (needed / area_size > 0) return area_size;
ulan 2016/08/03 10:31:51 if (need >= area_size) return area_size
Michael Lippautz 2016/08/04 08:43:57 Done.
+ // 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);
}
+ 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.
« no previous file with comments | « src/heap/spaces.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698