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

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: 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 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 #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) {
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.
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();
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.
1228 }
1229 size_t needed = static_cast<size_t>(snapshot_requires) - memory_served;
1230 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.
1231 if (needed >= static_cast<size_t>(area_size)) return area_size;
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);
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.
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 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after
3132 object->ShortPrint(); 3154 object->ShortPrint();
3133 PrintF("\n"); 3155 PrintF("\n");
3134 } 3156 }
3135 printf(" --------------------------------------\n"); 3157 printf(" --------------------------------------\n");
3136 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3158 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3137 } 3159 }
3138 3160
3139 #endif // DEBUG 3161 #endif // DEBUG
3140 } // namespace internal 3162 } // namespace internal
3141 } // namespace v8 3163 } // namespace v8
OLDNEW
« 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