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/slots-buffer.h" | 10 #include "src/heap/slots-buffer.h" |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 | 1137 |
1138 Page* p = heap()->isolate()->memory_allocator()->AllocatePage(size, this, | 1138 Page* p = heap()->isolate()->memory_allocator()->AllocatePage(size, this, |
1139 executable()); | 1139 executable()); |
1140 if (p == NULL) return false; | 1140 if (p == NULL) return false; |
1141 | 1141 |
1142 AccountCommitted(static_cast<intptr_t>(p->size())); | 1142 AccountCommitted(static_cast<intptr_t>(p->size())); |
1143 | 1143 |
1144 // Pages created during bootstrapping may contain immortal immovable objects. | 1144 // Pages created during bootstrapping may contain immortal immovable objects. |
1145 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate(); | 1145 if (!heap()->deserialization_complete()) p->MarkNeverEvacuate(); |
1146 | 1146 |
| 1147 // When incremental marking was activated, old generation pages are allocated |
| 1148 // black. |
| 1149 if (heap()->incremental_marking()->black_allocation()) { |
| 1150 Bitmap::SetAllBits(p); |
| 1151 p->SetFlag(Page::BLACK_PAGE); |
| 1152 if (FLAG_trace_incremental_marking) { |
| 1153 PrintIsolate(heap()->isolate(), "Added black page %p\n", p); |
| 1154 } |
| 1155 } |
| 1156 |
1147 DCHECK(Capacity() <= heap()->MaxOldGenerationSize()); | 1157 DCHECK(Capacity() <= heap()->MaxOldGenerationSize()); |
1148 | 1158 |
1149 p->InsertAfter(anchor_.prev_page()); | 1159 p->InsertAfter(anchor_.prev_page()); |
1150 | 1160 |
1151 return true; | 1161 return true; |
1152 } | 1162 } |
1153 | 1163 |
1154 | 1164 |
1155 int PagedSpace::CountTotalPages() { | 1165 int PagedSpace::CountTotalPages() { |
1156 PageIterator it(this); | 1166 PageIterator it(this); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 | 1253 |
1244 // Perform space-specific object verification. | 1254 // Perform space-specific object verification. |
1245 VerifyObject(object); | 1255 VerifyObject(object); |
1246 | 1256 |
1247 // The object itself should look OK. | 1257 // The object itself should look OK. |
1248 object->ObjectVerify(); | 1258 object->ObjectVerify(); |
1249 | 1259 |
1250 // All the interior pointers should be contained in the heap. | 1260 // All the interior pointers should be contained in the heap. |
1251 int size = object->Size(); | 1261 int size = object->Size(); |
1252 object->IterateBody(map->instance_type(), size, visitor); | 1262 object->IterateBody(map->instance_type(), size, visitor); |
1253 if (Marking::IsBlack(Marking::MarkBitFrom(object))) { | 1263 if (!page->IsFlagSet(Page::BLACK_PAGE) && |
| 1264 Marking::IsBlack(Marking::MarkBitFrom(object))) { |
1254 black_size += size; | 1265 black_size += size; |
1255 } | 1266 } |
1256 | 1267 |
1257 CHECK(object->address() + size <= top); | 1268 CHECK(object->address() + size <= top); |
1258 end_of_previous_object = object->address() + size; | 1269 end_of_previous_object = object->address() + size; |
1259 } | 1270 } |
1260 CHECK_LE(black_size, page->LiveBytes()); | 1271 CHECK_LE(black_size, page->LiveBytes()); |
1261 } | 1272 } |
1262 CHECK(allocation_pointer_found_in_space); | 1273 CHECK(allocation_pointer_found_in_space); |
1263 } | 1274 } |
(...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2995 uintptr_t base = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment; | 3006 uintptr_t base = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment; |
2996 uintptr_t limit = base + (page->size() - 1) / MemoryChunk::kAlignment; | 3007 uintptr_t limit = base + (page->size() - 1) / MemoryChunk::kAlignment; |
2997 for (uintptr_t key = base; key <= limit; key++) { | 3008 for (uintptr_t key = base; key <= limit; key++) { |
2998 HashMap::Entry* entry = chunk_map_.LookupOrInsert( | 3009 HashMap::Entry* entry = chunk_map_.LookupOrInsert( |
2999 reinterpret_cast<void*>(key), static_cast<uint32_t>(key)); | 3010 reinterpret_cast<void*>(key), static_cast<uint32_t>(key)); |
3000 DCHECK(entry != NULL); | 3011 DCHECK(entry != NULL); |
3001 entry->value = page; | 3012 entry->value = page; |
3002 } | 3013 } |
3003 | 3014 |
3004 HeapObject* object = page->GetObject(); | 3015 HeapObject* object = page->GetObject(); |
3005 | 3016 if (heap()->incremental_marking()->black_allocation()) { |
| 3017 MarkBit mark_bit = Marking::MarkBitFrom(object); |
| 3018 Marking::MarkBlack(mark_bit); |
| 3019 page->SetFlag(Page::BLACK_PAGE); |
| 3020 } |
3006 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); | 3021 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); |
3007 | 3022 |
3008 if (Heap::ShouldZapGarbage()) { | 3023 if (Heap::ShouldZapGarbage()) { |
3009 // Make the object consistent so the heap can be verified in OldSpaceStep. | 3024 // Make the object consistent so the heap can be verified in OldSpaceStep. |
3010 // We only need to do this in debug builds or if verify_heap is on. | 3025 // We only need to do this in debug builds or if verify_heap is on. |
3011 reinterpret_cast<Object**>(object->address())[0] = | 3026 reinterpret_cast<Object**>(object->address())[0] = |
3012 heap()->fixed_array_map(); | 3027 heap()->fixed_array_map(); |
3013 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); | 3028 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); |
3014 } | 3029 } |
3015 | 3030 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3238 object->ShortPrint(); | 3253 object->ShortPrint(); |
3239 PrintF("\n"); | 3254 PrintF("\n"); |
3240 } | 3255 } |
3241 printf(" --------------------------------------\n"); | 3256 printf(" --------------------------------------\n"); |
3242 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3257 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3243 } | 3258 } |
3244 | 3259 |
3245 #endif // DEBUG | 3260 #endif // DEBUG |
3246 } // namespace internal | 3261 } // namespace internal |
3247 } // namespace v8 | 3262 } // namespace v8 |
OLD | NEW |