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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 if (page == p) return true; | 1270 if (page == p) return true; |
1271 } | 1271 } |
1272 return false; | 1272 return false; |
1273 } | 1273 } |
1274 | 1274 |
1275 | 1275 |
1276 Object* PagedSpace::FindObject(Address addr) { | 1276 Object* PagedSpace::FindObject(Address addr) { |
1277 // Note: this function can only be called on iterable spaces. | 1277 // Note: this function can only be called on iterable spaces. |
1278 DCHECK(!heap()->mark_compact_collector()->in_use()); | 1278 DCHECK(!heap()->mark_compact_collector()->in_use()); |
1279 | 1279 |
1280 if (!Contains(addr)) return Smi::FromInt(0); // Signaling not found. | 1280 if (!Contains(addr)) return Smi::kZero; // Signaling not found. |
1281 | 1281 |
1282 Page* p = Page::FromAddress(addr); | 1282 Page* p = Page::FromAddress(addr); |
1283 HeapObjectIterator it(p); | 1283 HeapObjectIterator it(p); |
1284 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 1284 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
1285 Address cur = obj->address(); | 1285 Address cur = obj->address(); |
1286 Address next = cur + obj->Size(); | 1286 Address next = cur + obj->Size(); |
1287 if ((cur <= addr) && (addr < next)) return obj; | 1287 if ((cur <= addr) && (addr < next)) return obj; |
1288 } | 1288 } |
1289 | 1289 |
1290 UNREACHABLE(); | 1290 UNREACHABLE(); |
1291 return Smi::FromInt(0); | 1291 return Smi::kZero; |
1292 } | 1292 } |
1293 | 1293 |
1294 void PagedSpace::ShrinkImmortalImmovablePages() { | 1294 void PagedSpace::ShrinkImmortalImmovablePages() { |
1295 DCHECK(!heap()->deserialization_complete()); | 1295 DCHECK(!heap()->deserialization_complete()); |
1296 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); | 1296 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); |
1297 EmptyAllocationInfo(); | 1297 EmptyAllocationInfo(); |
1298 ResetFreeList(); | 1298 ResetFreeList(); |
1299 | 1299 |
1300 for (Page* page : *this) { | 1300 for (Page* page : *this) { |
1301 DCHECK(page->IsFlagSet(Page::NEVER_EVACUATE)); | 1301 DCHECK(page->IsFlagSet(Page::NEVER_EVACUATE)); |
(...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2988 InsertChunkMapEntries(page); | 2988 InsertChunkMapEntries(page); |
2989 | 2989 |
2990 HeapObject* object = page->GetObject(); | 2990 HeapObject* object = page->GetObject(); |
2991 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); | 2991 MSAN_ALLOCATED_UNINITIALIZED_MEMORY(object->address(), object_size); |
2992 | 2992 |
2993 if (Heap::ShouldZapGarbage()) { | 2993 if (Heap::ShouldZapGarbage()) { |
2994 // Make the object consistent so the heap can be verified in OldSpaceStep. | 2994 // Make the object consistent so the heap can be verified in OldSpaceStep. |
2995 // We only need to do this in debug builds or if verify_heap is on. | 2995 // We only need to do this in debug builds or if verify_heap is on. |
2996 reinterpret_cast<Object**>(object->address())[0] = | 2996 reinterpret_cast<Object**>(object->address())[0] = |
2997 heap()->fixed_array_map(); | 2997 heap()->fixed_array_map(); |
2998 reinterpret_cast<Object**>(object->address())[1] = Smi::FromInt(0); | 2998 reinterpret_cast<Object**>(object->address())[1] = Smi::kZero; |
2999 } | 2999 } |
3000 | 3000 |
3001 heap()->StartIncrementalMarkingIfAllocationLimitIsReached(Heap::kNoGCFlags, | 3001 heap()->StartIncrementalMarkingIfAllocationLimitIsReached(Heap::kNoGCFlags, |
3002 kNoGCCallbackFlags); | 3002 kNoGCCallbackFlags); |
3003 AllocationStep(object->address(), object_size); | 3003 AllocationStep(object->address(), object_size); |
3004 | 3004 |
3005 if (heap()->incremental_marking()->black_allocation()) { | 3005 if (heap()->incremental_marking()->black_allocation()) { |
3006 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); | 3006 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); |
3007 MemoryChunk::IncrementLiveBytesFromGC(object, object_size); | 3007 MemoryChunk::IncrementLiveBytesFromGC(object, object_size); |
3008 } | 3008 } |
3009 return object; | 3009 return object; |
3010 } | 3010 } |
3011 | 3011 |
3012 | 3012 |
3013 size_t LargeObjectSpace::CommittedPhysicalMemory() { | 3013 size_t LargeObjectSpace::CommittedPhysicalMemory() { |
3014 // On a platform that provides lazy committing of memory, we over-account | 3014 // On a platform that provides lazy committing of memory, we over-account |
3015 // the actually committed memory. There is no easy way right now to support | 3015 // the actually committed memory. There is no easy way right now to support |
3016 // precise accounting of committed memory in large object space. | 3016 // precise accounting of committed memory in large object space. |
3017 return CommittedMemory(); | 3017 return CommittedMemory(); |
3018 } | 3018 } |
3019 | 3019 |
3020 | 3020 |
3021 // GC support | 3021 // GC support |
3022 Object* LargeObjectSpace::FindObject(Address a) { | 3022 Object* LargeObjectSpace::FindObject(Address a) { |
3023 LargePage* page = FindPage(a); | 3023 LargePage* page = FindPage(a); |
3024 if (page != NULL) { | 3024 if (page != NULL) { |
3025 return page->GetObject(); | 3025 return page->GetObject(); |
3026 } | 3026 } |
3027 return Smi::FromInt(0); // Signaling not found. | 3027 return Smi::kZero; // Signaling not found. |
3028 } | 3028 } |
3029 | 3029 |
3030 | 3030 |
3031 LargePage* LargeObjectSpace::FindPage(Address a) { | 3031 LargePage* LargeObjectSpace::FindPage(Address a) { |
3032 uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment; | 3032 uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment; |
3033 base::HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key), | 3033 base::HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key), |
3034 static_cast<uint32_t>(key)); | 3034 static_cast<uint32_t>(key)); |
3035 if (e != NULL) { | 3035 if (e != NULL) { |
3036 DCHECK(e->value != NULL); | 3036 DCHECK(e->value != NULL); |
3037 LargePage* page = reinterpret_cast<LargePage*>(e->value); | 3037 LargePage* page = reinterpret_cast<LargePage*>(e->value); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3235 object->ShortPrint(); | 3235 object->ShortPrint(); |
3236 PrintF("\n"); | 3236 PrintF("\n"); |
3237 } | 3237 } |
3238 printf(" --------------------------------------\n"); | 3238 printf(" --------------------------------------\n"); |
3239 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3239 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3240 } | 3240 } |
3241 | 3241 |
3242 #endif // DEBUG | 3242 #endif // DEBUG |
3243 } // namespace internal | 3243 } // namespace internal |
3244 } // namespace v8 | 3244 } // namespace v8 |
OLD | NEW |