| OLD | NEW |
| 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/full-codegen/full-codegen.h" | 9 #include "src/full-codegen/full-codegen.h" |
| 10 #include "src/heap/slot-set.h" | 10 #include "src/heap/slot-set.h" |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 | 1189 |
| 1190 Page* p = heap()->isolate()->memory_allocator()->AllocatePage(size, this, | 1190 Page* p = heap()->isolate()->memory_allocator()->AllocatePage(size, this, |
| 1191 executable()); | 1191 executable()); |
| 1192 if (p == NULL) return false; | 1192 if (p == NULL) return false; |
| 1193 | 1193 |
| 1194 AccountCommitted(static_cast<intptr_t>(p->size())); | 1194 AccountCommitted(static_cast<intptr_t>(p->size())); |
| 1195 | 1195 |
| 1196 // Pages created during bootstrapping may contain immortal immovable objects. | 1196 // Pages created during bootstrapping may contain immortal immovable objects. |
| 1197 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate(); | 1197 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate(); |
| 1198 | 1198 |
| 1199 // When incremental marking was activated, old generation pages are allocated |
| 1200 // black. |
| 1201 if (heap()->incremental_marking()->black_allocation()) { |
| 1202 Bitmap::SetAllBits(p); |
| 1203 p->SetFlag(Page::BLACK_PAGE); |
| 1204 if (FLAG_trace_incremental_marking) { |
| 1205 PrintIsolate(heap()->isolate(), "Added black page %p\n", p); |
| 1206 } |
| 1207 } |
| 1208 |
| 1199 DCHECK(Capacity() <= heap()->MaxOldGenerationSize()); | 1209 DCHECK(Capacity() <= heap()->MaxOldGenerationSize()); |
| 1200 | 1210 |
| 1201 p->InsertAfter(anchor_.prev_page()); | 1211 p->InsertAfter(anchor_.prev_page()); |
| 1202 | 1212 |
| 1203 return true; | 1213 return true; |
| 1204 } | 1214 } |
| 1205 | 1215 |
| 1206 | 1216 |
| 1207 int PagedSpace::CountTotalPages() { | 1217 int PagedSpace::CountTotalPages() { |
| 1208 PageIterator it(this); | 1218 PageIterator it(this); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 | 1300 |
| 1291 // Perform space-specific object verification. | 1301 // Perform space-specific object verification. |
| 1292 VerifyObject(object); | 1302 VerifyObject(object); |
| 1293 | 1303 |
| 1294 // The object itself should look OK. | 1304 // The object itself should look OK. |
| 1295 object->ObjectVerify(); | 1305 object->ObjectVerify(); |
| 1296 | 1306 |
| 1297 // All the interior pointers should be contained in the heap. | 1307 // All the interior pointers should be contained in the heap. |
| 1298 int size = object->Size(); | 1308 int size = object->Size(); |
| 1299 object->IterateBody(map->instance_type(), size, visitor); | 1309 object->IterateBody(map->instance_type(), size, visitor); |
| 1300 if (Marking::IsBlack(Marking::MarkBitFrom(object))) { | 1310 if (!page->IsFlagSet(Page::BLACK_PAGE) && |
| 1311 Marking::IsBlack(Marking::MarkBitFrom(object))) { |
| 1301 black_size += size; | 1312 black_size += size; |
| 1302 } | 1313 } |
| 1303 | 1314 |
| 1304 CHECK(object->address() + size <= top); | 1315 CHECK(object->address() + size <= top); |
| 1305 end_of_previous_object = object->address() + size; | 1316 end_of_previous_object = object->address() + size; |
| 1306 } | 1317 } |
| 1307 CHECK_LE(black_size, page->LiveBytes()); | 1318 CHECK_LE(black_size, page->LiveBytes()); |
| 1308 } | 1319 } |
| 1309 CHECK(allocation_pointer_found_in_space); | 1320 CHECK(allocation_pointer_found_in_space); |
| 1310 } | 1321 } |
| (...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3004 uintptr_t base = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment; | 3015 uintptr_t base = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment; |
| 3005 uintptr_t limit = base + (page->size() - 1) / MemoryChunk::kAlignment; | 3016 uintptr_t limit = base + (page->size() - 1) / MemoryChunk::kAlignment; |
| 3006 for (uintptr_t key = base; key <= limit; key++) { | 3017 for (uintptr_t key = base; key <= limit; key++) { |
| 3007 HashMap::Entry* entry = chunk_map_.LookupOrInsert( | 3018 HashMap::Entry* entry = chunk_map_.LookupOrInsert( |
| 3008 reinterpret_cast<void*>(key), static_cast<uint32_t>(key)); | 3019 reinterpret_cast<void*>(key), static_cast<uint32_t>(key)); |
| 3009 DCHECK(entry != NULL); | 3020 DCHECK(entry != NULL); |
| 3010 entry->value = page; | 3021 entry->value = page; |
| 3011 } | 3022 } |
| 3012 | 3023 |
| 3013 HeapObject* object = page->GetObject(); | 3024 HeapObject* object = page->GetObject(); |
| 3014 | 3025 if (heap()->incremental_marking()->black_allocation()) { |
| 3026 MarkBit mark_bit = Marking::MarkBitFrom(object); |
| 3027 Marking::MarkBlack(mark_bit); |
| 3028 page->SetFlag(Page::BLACK_PAGE); |
| 3029 } |
| 3015 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); | 3030 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); |
| 3016 | 3031 |
| 3017 if (Heap::ShouldZapGarbage()) { | 3032 if (Heap::ShouldZapGarbage()) { |
| 3018 // Make the object consistent so the heap can be verified in OldSpaceStep. | 3033 // Make the object consistent so the heap can be verified in OldSpaceStep. |
| 3019 // We only need to do this in debug builds or if verify_heap is on. | 3034 // We only need to do this in debug builds or if verify_heap is on. |
| 3020 reinterpret_cast<Object**>(object->address())[0] = | 3035 reinterpret_cast<Object**>(object->address())[0] = |
| 3021 heap()->fixed_array_map(); | 3036 heap()->fixed_array_map(); |
| 3022 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); | 3037 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); |
| 3023 } | 3038 } |
| 3024 | 3039 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3241 object->ShortPrint(); | 3256 object->ShortPrint(); |
| 3242 PrintF("\n"); | 3257 PrintF("\n"); |
| 3243 } | 3258 } |
| 3244 printf(" --------------------------------------\n"); | 3259 printf(" --------------------------------------\n"); |
| 3245 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3260 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3246 } | 3261 } |
| 3247 | 3262 |
| 3248 #endif // DEBUG | 3263 #endif // DEBUG |
| 3249 } // namespace internal | 3264 } // namespace internal |
| 3250 } // namespace v8 | 3265 } // namespace v8 |
| OLD | NEW |