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

Side by Side Diff: src/heap/spaces.cc

Issue 2637403011: Reland "[heap] Provide ObjectMarking with marking transitions" (Closed)
Patch Set: Add comment Created 3 years, 11 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
« no previous file with comments | « src/heap/scavenger.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
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 (Marking::IsBlack(ObjectMarking::MarkBitFrom(object))) { 1462 if (ObjectMarking::IsBlack(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
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 Marking::MarkBlack(ObjectMarking::MarkBitFrom(object)); 2993 // We cannot use ObjectMarking here as the object still lacks a size.
2994 Marking::WhiteToBlack(ObjectMarking::MarkBitFrom(object));
2994 MemoryChunk::IncrementLiveBytes(object, object_size); 2995 MemoryChunk::IncrementLiveBytes(object, object_size);
2995 } 2996 }
2996 return object; 2997 return object;
2997 } 2998 }
2998 2999
2999 3000
3000 size_t LargeObjectSpace::CommittedPhysicalMemory() { 3001 size_t LargeObjectSpace::CommittedPhysicalMemory() {
3001 // On a platform that provides lazy committing of memory, we over-account 3002 // On a platform that provides lazy committing of memory, we over-account
3002 // the actually committed memory. There is no easy way right now to support 3003 // the actually committed memory. There is no easy way right now to support
3003 // precise accounting of committed memory in large object space. 3004 // precise accounting of committed memory in large object space.
(...skipping 28 matching lines...) Expand all
3032 } 3033 }
3033 } 3034 }
3034 return NULL; 3035 return NULL;
3035 } 3036 }
3036 3037
3037 3038
3038 void LargeObjectSpace::ClearMarkingStateOfLiveObjects() { 3039 void LargeObjectSpace::ClearMarkingStateOfLiveObjects() {
3039 LargePage* current = first_page_; 3040 LargePage* current = first_page_;
3040 while (current != NULL) { 3041 while (current != NULL) {
3041 HeapObject* object = current->GetObject(); 3042 HeapObject* object = current->GetObject();
3042 MarkBit mark_bit = ObjectMarking::MarkBitFrom(object); 3043 DCHECK(ObjectMarking::IsBlack(object));
3043 DCHECK(Marking::IsBlack(mark_bit)); 3044 ObjectMarking::BlackToWhite(object);
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
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 MarkBit mark_bit = ObjectMarking::MarkBitFrom(object); 3089 DCHECK(!ObjectMarking::IsGrey(object));
3090 DCHECK(!Marking::IsGrey(mark_bit)); 3090 if (ObjectMarking::IsBlack(object)) {
3091 if (Marking::IsBlack(mark_bit)) {
3092 Address free_start; 3091 Address free_start;
3093 if ((free_start = current->GetAddressToShrink()) != 0) { 3092 if ((free_start = current->GetAddressToShrink()) != 0) {
3094 // TODO(hpayer): Perform partial free concurrently. 3093 // TODO(hpayer): Perform partial free concurrently.
3095 current->ClearOutOfLiveRangeSlots(free_start); 3094 current->ClearOutOfLiveRangeSlots(free_start);
3096 RemoveChunkMapEntries(current, free_start); 3095 RemoveChunkMapEntries(current, free_start);
3097 heap()->memory_allocator()->PartialFreeMemory(current, free_start); 3096 heap()->memory_allocator()->PartialFreeMemory(current, free_start);
3098 } 3097 }
3099 previous = current; 3098 previous = current;
3100 current = current->next_page(); 3099 current = current->next_page();
3101 } else { 3100 } else {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3216 3215
3217 void Page::Print() { 3216 void Page::Print() {
3218 // Make a best-effort to print the objects in the page. 3217 // Make a best-effort to print the objects in the page.
3219 PrintF("Page@%p in %s\n", static_cast<void*>(this->address()), 3218 PrintF("Page@%p in %s\n", static_cast<void*>(this->address()),
3220 AllocationSpaceName(this->owner()->identity())); 3219 AllocationSpaceName(this->owner()->identity()));
3221 printf(" --------------------------------------\n"); 3220 printf(" --------------------------------------\n");
3222 HeapObjectIterator objects(this); 3221 HeapObjectIterator objects(this);
3223 unsigned mark_size = 0; 3222 unsigned mark_size = 0;
3224 for (HeapObject* object = objects.Next(); object != NULL; 3223 for (HeapObject* object = objects.Next(); object != NULL;
3225 object = objects.Next()) { 3224 object = objects.Next()) {
3226 bool is_marked = Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(object)); 3225 bool is_marked = ObjectMarking::IsBlackOrGrey(object);
3227 PrintF(" %c ", (is_marked ? '!' : ' ')); // Indent a little. 3226 PrintF(" %c ", (is_marked ? '!' : ' ')); // Indent a little.
3228 if (is_marked) { 3227 if (is_marked) {
3229 mark_size += object->Size(); 3228 mark_size += object->Size();
3230 } 3229 }
3231 object->ShortPrint(); 3230 object->ShortPrint();
3232 PrintF("\n"); 3231 PrintF("\n");
3233 } 3232 }
3234 printf(" --------------------------------------\n"); 3233 printf(" --------------------------------------\n");
3235 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); 3234 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes());
3236 } 3235 }
3237 3236
3238 #endif // DEBUG 3237 #endif // DEBUG
3239 } // namespace internal 3238 } // namespace internal
3240 } // namespace v8 3239 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/scavenger.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698