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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/heap/spaces.h ('k') | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "src/heap/spaces.h" 5 #include "src/heap/spaces.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/base/platform/semaphore.h" 9 #include "src/base/platform/semaphore.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { 1206 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
1207 Address cur = obj->address(); 1207 Address cur = obj->address();
1208 Address next = cur + obj->Size(); 1208 Address next = cur + obj->Size();
1209 if ((cur <= addr) && (addr < next)) return obj; 1209 if ((cur <= addr) && (addr < next)) return obj;
1210 } 1210 }
1211 1211
1212 UNREACHABLE(); 1212 UNREACHABLE();
1213 return Smi::FromInt(0); 1213 return Smi::FromInt(0);
1214 } 1214 }
1215 1215
1216 int PagedSpace::AreaSizeDuringDeserialization() {
1217 // Try to keep the memory as compact as possible for a snapshot. This way the
1218 // heap stays small for small/empty scripts.
1219 DCHECK(snapshotable());
1220 DCHECK(!heap()->deserialization_complete());
1221 uint32_t snapshot_requires =
1222 Snapshot::SizeOfSnapshot(heap()->isolate(), identity());
1223 if (snapshot_requires > 0) {
1224 // Count how much we have served already.
1225 size_t memory_served = 0;
1226 for (Page* page : *this) {
1227 memory_served += page->area_size();
1228 }
1229 size_t needed = static_cast<size_t>(snapshot_requires) - memory_served;
1230 const int area_size = MemoryAllocator::PageAreaSize(identity());
1231 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.
1232 // Less than a page of memory needed. We need to allocate at least
1233 // kMaxRegularHeapObjectSize of space.
1234 if (needed < Page::kMaxRegularHeapObjectSize)
1235 return Page::kMaxRegularHeapObjectSize;
1236 return static_cast<int>(needed);
1237 }
1238 return AreaSize();
1239 }
1240
1216 bool PagedSpace::Expand() { 1241 bool PagedSpace::Expand() {
1217 int size = AreaSize(); 1242 int size = heap()->deserialization_complete()
1218 if (snapshotable() && !HasPages()) { 1243 ? AreaSize()
1219 size = Snapshot::SizeOfFirstPage(heap()->isolate(), identity()); 1244 : AreaSizeDuringDeserialization();
1220 }
1221 1245
1222 if (!heap()->CanExpandOldGeneration(size)) return false; 1246 if (!heap()->CanExpandOldGeneration(size)) return false;
1223
1224 Page* p = heap()->memory_allocator()->AllocatePage(size, this, executable()); 1247 Page* p = heap()->memory_allocator()->AllocatePage(size, this, executable());
1225 if (p == nullptr) return false; 1248 if (p == nullptr) return false;
1226
1227 AccountCommitted(static_cast<intptr_t>(p->size())); 1249 AccountCommitted(static_cast<intptr_t>(p->size()));
1228 1250
1229 // Pages created during bootstrapping may contain immortal immovable objects. 1251 // Pages created during bootstrapping may contain immortal immovable objects.
1230 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate(); 1252 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate();
1231 1253
1232 DCHECK(Capacity() <= heap()->MaxOldGenerationSize()); 1254 DCHECK(Capacity() <= heap()->MaxOldGenerationSize());
1233 1255
1234 p->InsertAfter(anchor_.prev_page()); 1256 p->InsertAfter(anchor_.prev_page());
1235 1257
1236 return true; 1258 return true;
(...skipping 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after
3134 object->ShortPrint(); 3156 object->ShortPrint();
3135 PrintF("\n"); 3157 PrintF("\n");
3136 } 3158 }
3137 printf(" --------------------------------------\n"); 3159 printf(" --------------------------------------\n");
3138 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3160 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3139 } 3161 }
3140 3162
3141 #endif // DEBUG 3163 #endif // DEBUG
3142 } // namespace internal 3164 } // namespace internal
3143 } // namespace v8 3165 } // namespace v8
OLDNEW
« 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