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

Side by Side Diff: src/heap/remembered-set.cc

Issue 1735523002: Reland "Replace slots buffer with remembered set. (patchset #14 id:250001 of https://codereview.chr… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: one more int->size_t Created 4 years, 9 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/remembered-set.h ('k') | src/heap/slot-set.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/remembered-set.h" 5 #include "src/heap/remembered-set.h"
6 #include "src/heap/heap-inl.h" 6 #include "src/heap/heap-inl.h"
7 #include "src/heap/heap.h" 7 #include "src/heap/heap.h"
8 #include "src/heap/mark-compact.h" 8 #include "src/heap/mark-compact.h"
9 #include "src/heap/slot-set.h" 9 #include "src/heap/slot-set.h"
10 #include "src/heap/spaces.h" 10 #include "src/heap/spaces.h"
11 #include "src/heap/store-buffer.h" 11 #include "src/heap/store-buffer.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 template <PointerDirection direction> 16 template <PointerDirection direction>
17 void RememberedSet<direction>::ClearInvalidSlots(Heap* heap) { 17 void RememberedSet<direction>::ClearInvalidSlots(Heap* heap) {
18 STATIC_ASSERT(direction == OLD_TO_NEW); 18 STATIC_ASSERT(direction == OLD_TO_NEW);
19 PageIterator it(heap->old_space()); 19 PageIterator it(heap->old_space());
20 MemoryChunk* chunk; 20 MemoryChunk* chunk;
21 while (it.has_next()) { 21 while (it.has_next()) {
22 chunk = it.next(); 22 chunk = it.next();
23 SlotSet* slots = GetSlotSet(chunk); 23 SlotSet* slots = GetSlotSet(chunk);
24 if (slots != nullptr) { 24 if (slots != nullptr) {
25 slots->Iterate([heap](Address addr) { 25 slots->Iterate([heap](Address addr) {
26 Object** slot = reinterpret_cast<Object**>(addr); 26 Object** slot = reinterpret_cast<Object**>(addr);
27 return IsValidSlot(heap, slot) ? SlotSet::KEEP_SLOT 27 return IsValidSlot(heap, slot) ? KEEP_SLOT : REMOVE_SLOT;
28 : SlotSet::REMOVE_SLOT;
29 }); 28 });
30 } 29 }
31 } 30 }
32 } 31 }
33 32
34 template <PointerDirection direction> 33 template <PointerDirection direction>
35 void RememberedSet<direction>::VerifyValidSlots(Heap* heap) { 34 void RememberedSet<direction>::VerifyValidSlots(Heap* heap) {
36 STATIC_ASSERT(direction == OLD_TO_NEW);
37 Iterate(heap, [heap](Address addr) { 35 Iterate(heap, [heap](Address addr) {
38 Object** slot = reinterpret_cast<Object**>(addr); 36 HeapObject* obj =
39 Object* object = *slot; 37 heap->mark_compact_collector()->FindBlackObjectBySlotSlow(addr);
40 if (Page::FromAddress(addr)->owner() != nullptr && 38 if (obj == nullptr) {
41 Page::FromAddress(addr)->owner()->identity() == OLD_SPACE) { 39 // The slot is in dead object.
42 CHECK(IsValidSlot(heap, slot)); 40 MemoryChunk* chunk = MemoryChunk::FromAnyPointerAddress(heap, addr);
43 heap->mark_compact_collector()->VerifyIsSlotInLiveObject( 41 AllocationSpace owner = chunk->owner()->identity();
44 reinterpret_cast<Address>(slot), HeapObject::cast(object)); 42 // The old to old remembered set should not have dead slots.
43 CHECK_NE(direction, OLD_TO_OLD);
44 // The old to new remembered set is allowed to have slots in dead
45 // objects only in map and large object space because these spaces cannot
46 // have raw untaged pointers.
47 CHECK(owner == MAP_SPACE || owner == LO_SPACE);
48 } else {
49 int offset = static_cast<int>(addr - obj->address());
50 CHECK(obj->IsValidSlot(offset));
45 } 51 }
46 return SlotSet::KEEP_SLOT; 52 return KEEP_SLOT;
47 }); 53 });
48 } 54 }
49 55
50 template <PointerDirection direction> 56 template <PointerDirection direction>
51 bool RememberedSet<direction>::IsValidSlot(Heap* heap, Object** slot) { 57 bool RememberedSet<direction>::IsValidSlot(Heap* heap, Object** slot) {
52 STATIC_ASSERT(direction == OLD_TO_NEW); 58 STATIC_ASSERT(direction == OLD_TO_NEW);
53 Object* object = *slot; 59 Object* object = *slot;
54 if (!heap->InNewSpace(object)) { 60 if (!heap->InNewSpace(object)) {
55 return false; 61 return false;
56 } 62 }
57 HeapObject* heap_object = HeapObject::cast(object); 63 HeapObject* heap_object = HeapObject::cast(object);
58 // If the target object is not black, the source slot must be part 64 // If the target object is not black, the source slot must be part
59 // of a non-black (dead) object. 65 // of a non-black (dead) object.
60 return Marking::IsBlack(Marking::MarkBitFrom(heap_object)) && 66 return Marking::IsBlack(Marking::MarkBitFrom(heap_object)) &&
61 heap->mark_compact_collector()->IsSlotInLiveObject( 67 heap->mark_compact_collector()->IsSlotInLiveObject(
62 reinterpret_cast<Address>(slot)); 68 reinterpret_cast<Address>(slot));
63 } 69 }
64 70
65 template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap); 71 template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap);
66 template void RememberedSet<OLD_TO_NEW>::VerifyValidSlots(Heap* heap); 72 template void RememberedSet<OLD_TO_NEW>::VerifyValidSlots(Heap* heap);
73 template void RememberedSet<OLD_TO_OLD>::VerifyValidSlots(Heap* heap);
67 74
68 } // namespace internal 75 } // namespace internal
69 } // namespace v8 76 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/remembered-set.h ('k') | src/heap/slot-set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698