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 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 | 1452 |
1453 // Perform space-specific object verification. | 1453 // Perform space-specific object verification. |
1454 VerifyObject(object); | 1454 VerifyObject(object); |
1455 | 1455 |
1456 // The object itself should look OK. | 1456 // The object itself should look OK. |
1457 object->ObjectVerify(); | 1457 object->ObjectVerify(); |
1458 | 1458 |
1459 // All the interior pointers should be contained in the heap. | 1459 // All the interior pointers should be contained in the heap. |
1460 int size = object->Size(); | 1460 int size = object->Size(); |
1461 object->IterateBody(map->instance_type(), size, visitor); | 1461 object->IterateBody(map->instance_type(), size, visitor); |
1462 if (ObjectMarking::IsBlack(object)) { | 1462 if (Marking::IsBlack(ObjectMarking::MarkBitFrom(object))) { |
1463 black_size += size; | 1463 black_size += size; |
1464 } | 1464 } |
1465 | 1465 |
1466 CHECK(object->address() + size <= top); | 1466 CHECK(object->address() + size <= top); |
1467 end_of_previous_object = object->address() + size; | 1467 end_of_previous_object = object->address() + size; |
1468 } | 1468 } |
1469 CHECK_LE(black_size, page->LiveBytes()); | 1469 CHECK_LE(black_size, page->LiveBytes()); |
1470 } | 1470 } |
1471 CHECK(allocation_pointer_found_in_space); | 1471 CHECK(allocation_pointer_found_in_space); |
1472 } | 1472 } |
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2983 reinterpret_cast<Object**>(object->address())[0] = | 2983 reinterpret_cast<Object**>(object->address())[0] = |
2984 heap()->fixed_array_map(); | 2984 heap()->fixed_array_map(); |
2985 reinterpret_cast<Object**>(object->address())[1] = Smi::kZero; | 2985 reinterpret_cast<Object**>(object->address())[1] = Smi::kZero; |
2986 } | 2986 } |
2987 | 2987 |
2988 heap()->StartIncrementalMarkingIfAllocationLimitIsReached(Heap::kNoGCFlags, | 2988 heap()->StartIncrementalMarkingIfAllocationLimitIsReached(Heap::kNoGCFlags, |
2989 kNoGCCallbackFlags); | 2989 kNoGCCallbackFlags); |
2990 AllocationStep(object->address(), object_size); | 2990 AllocationStep(object->address(), object_size); |
2991 | 2991 |
2992 if (heap()->incremental_marking()->black_allocation()) { | 2992 if (heap()->incremental_marking()->black_allocation()) { |
2993 // We cannot use ObjectMarking here as the object still lacks a size. | 2993 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); |
2994 Marking::WhiteToBlack(ObjectMarking::MarkBitFrom(object)); | |
2995 MemoryChunk::IncrementLiveBytes(object, object_size); | 2994 MemoryChunk::IncrementLiveBytes(object, object_size); |
2996 } | 2995 } |
2997 return object; | 2996 return object; |
2998 } | 2997 } |
2999 | 2998 |
3000 | 2999 |
3001 size_t LargeObjectSpace::CommittedPhysicalMemory() { | 3000 size_t LargeObjectSpace::CommittedPhysicalMemory() { |
3002 // On a platform that provides lazy committing of memory, we over-account | 3001 // On a platform that provides lazy committing of memory, we over-account |
3003 // the actually committed memory. There is no easy way right now to support | 3002 // the actually committed memory. There is no easy way right now to support |
3004 // precise accounting of committed memory in large object space. | 3003 // precise accounting of committed memory in large object space. |
(...skipping 28 matching lines...) Expand all Loading... |
3033 } | 3032 } |
3034 } | 3033 } |
3035 return NULL; | 3034 return NULL; |
3036 } | 3035 } |
3037 | 3036 |
3038 | 3037 |
3039 void LargeObjectSpace::ClearMarkingStateOfLiveObjects() { | 3038 void LargeObjectSpace::ClearMarkingStateOfLiveObjects() { |
3040 LargePage* current = first_page_; | 3039 LargePage* current = first_page_; |
3041 while (current != NULL) { | 3040 while (current != NULL) { |
3042 HeapObject* object = current->GetObject(); | 3041 HeapObject* object = current->GetObject(); |
3043 DCHECK(ObjectMarking::IsBlack(object)); | 3042 MarkBit mark_bit = ObjectMarking::MarkBitFrom(object); |
3044 ObjectMarking::BlackToWhite(object); | 3043 DCHECK(Marking::IsBlack(mark_bit)); |
| 3044 Marking::BlackToWhite(mark_bit); |
3045 Page::FromAddress(object->address())->ResetProgressBar(); | 3045 Page::FromAddress(object->address())->ResetProgressBar(); |
3046 Page::FromAddress(object->address())->ResetLiveBytes(); | 3046 Page::FromAddress(object->address())->ResetLiveBytes(); |
3047 current = current->next_page(); | 3047 current = current->next_page(); |
3048 } | 3048 } |
3049 } | 3049 } |
3050 | 3050 |
3051 void LargeObjectSpace::InsertChunkMapEntries(LargePage* page) { | 3051 void LargeObjectSpace::InsertChunkMapEntries(LargePage* page) { |
3052 // Register all MemoryChunk::kAlignment-aligned chunks covered by | 3052 // Register all MemoryChunk::kAlignment-aligned chunks covered by |
3053 // this large page in the chunk map. | 3053 // this large page in the chunk map. |
3054 uintptr_t start = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment; | 3054 uintptr_t start = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment; |
(...skipping 24 matching lines...) Expand all Loading... |
3079 for (uintptr_t key = start; key <= limit; key++) { | 3079 for (uintptr_t key = start; key <= limit; key++) { |
3080 chunk_map_.Remove(reinterpret_cast<void*>(key), static_cast<uint32_t>(key)); | 3080 chunk_map_.Remove(reinterpret_cast<void*>(key), static_cast<uint32_t>(key)); |
3081 } | 3081 } |
3082 } | 3082 } |
3083 | 3083 |
3084 void LargeObjectSpace::FreeUnmarkedObjects() { | 3084 void LargeObjectSpace::FreeUnmarkedObjects() { |
3085 LargePage* previous = NULL; | 3085 LargePage* previous = NULL; |
3086 LargePage* current = first_page_; | 3086 LargePage* current = first_page_; |
3087 while (current != NULL) { | 3087 while (current != NULL) { |
3088 HeapObject* object = current->GetObject(); | 3088 HeapObject* object = current->GetObject(); |
3089 DCHECK(!ObjectMarking::IsGrey(object)); | 3089 MarkBit mark_bit = ObjectMarking::MarkBitFrom(object); |
3090 if (ObjectMarking::IsBlack(object)) { | 3090 DCHECK(!Marking::IsGrey(mark_bit)); |
| 3091 if (Marking::IsBlack(mark_bit)) { |
3091 Address free_start; | 3092 Address free_start; |
3092 if ((free_start = current->GetAddressToShrink()) != 0) { | 3093 if ((free_start = current->GetAddressToShrink()) != 0) { |
3093 // TODO(hpayer): Perform partial free concurrently. | 3094 // TODO(hpayer): Perform partial free concurrently. |
3094 current->ClearOutOfLiveRangeSlots(free_start); | 3095 current->ClearOutOfLiveRangeSlots(free_start); |
3095 RemoveChunkMapEntries(current, free_start); | 3096 RemoveChunkMapEntries(current, free_start); |
3096 heap()->memory_allocator()->PartialFreeMemory(current, free_start); | 3097 heap()->memory_allocator()->PartialFreeMemory(current, free_start); |
3097 } | 3098 } |
3098 previous = current; | 3099 previous = current; |
3099 current = current->next_page(); | 3100 current = current->next_page(); |
3100 } else { | 3101 } else { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3215 | 3216 |
3216 void Page::Print() { | 3217 void Page::Print() { |
3217 // Make a best-effort to print the objects in the page. | 3218 // Make a best-effort to print the objects in the page. |
3218 PrintF("Page@%p in %s\n", static_cast<void*>(this->address()), | 3219 PrintF("Page@%p in %s\n", static_cast<void*>(this->address()), |
3219 AllocationSpaceName(this->owner()->identity())); | 3220 AllocationSpaceName(this->owner()->identity())); |
3220 printf(" --------------------------------------\n"); | 3221 printf(" --------------------------------------\n"); |
3221 HeapObjectIterator objects(this); | 3222 HeapObjectIterator objects(this); |
3222 unsigned mark_size = 0; | 3223 unsigned mark_size = 0; |
3223 for (HeapObject* object = objects.Next(); object != NULL; | 3224 for (HeapObject* object = objects.Next(); object != NULL; |
3224 object = objects.Next()) { | 3225 object = objects.Next()) { |
3225 bool is_marked = ObjectMarking::IsBlackOrGrey(object); | 3226 bool is_marked = Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(object)); |
3226 PrintF(" %c ", (is_marked ? '!' : ' ')); // Indent a little. | 3227 PrintF(" %c ", (is_marked ? '!' : ' ')); // Indent a little. |
3227 if (is_marked) { | 3228 if (is_marked) { |
3228 mark_size += object->Size(); | 3229 mark_size += object->Size(); |
3229 } | 3230 } |
3230 object->ShortPrint(); | 3231 object->ShortPrint(); |
3231 PrintF("\n"); | 3232 PrintF("\n"); |
3232 } | 3233 } |
3233 printf(" --------------------------------------\n"); | 3234 printf(" --------------------------------------\n"); |
3234 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3235 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3235 } | 3236 } |
3236 | 3237 |
3237 #endif // DEBUG | 3238 #endif // DEBUG |
3238 } // namespace internal | 3239 } // namespace internal |
3239 } // namespace v8 | 3240 } // namespace v8 |
OLD | NEW |