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

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

Issue 2025833002: [heap] Store the host address in the typed remembered set. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase. Created 4 years, 6 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/mark-compact.cc ('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 #ifndef V8_REMEMBERED_SET_H 5 #ifndef V8_REMEMBERED_SET_H
6 #define V8_REMEMBERED_SET_H 6 #define V8_REMEMBERED_SET_H
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/heap/heap.h" 9 #include "src/heap/heap.h"
10 #include "src/heap/slot-set.h" 10 #include "src/heap/slot-set.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 new_count += slots[page].Iterate(callback); 93 new_count += slots[page].Iterate(callback);
94 } 94 }
95 if (new_count == 0) { 95 if (new_count == 0) {
96 ReleaseSlotSet(chunk); 96 ReleaseSlotSet(chunk);
97 } 97 }
98 } 98 }
99 } 99 }
100 100
101 // Given a page and a typed slot in that page, this function adds the slot 101 // Given a page and a typed slot in that page, this function adds the slot
102 // to the remembered set. 102 // to the remembered set.
103 static void InsertTyped(Page* page, SlotType slot_type, Address slot_addr) { 103 static void InsertTyped(Page* page, Address host_addr, SlotType slot_type,
104 Address slot_addr) {
104 TypedSlotSet* slot_set = GetTypedSlotSet(page); 105 TypedSlotSet* slot_set = GetTypedSlotSet(page);
105 if (slot_set == nullptr) { 106 if (slot_set == nullptr) {
106 AllocateTypedSlotSet(page); 107 AllocateTypedSlotSet(page);
107 slot_set = GetTypedSlotSet(page); 108 slot_set = GetTypedSlotSet(page);
108 } 109 }
110 if (host_addr == nullptr) {
111 host_addr = page->address();
112 }
109 uintptr_t offset = slot_addr - page->address(); 113 uintptr_t offset = slot_addr - page->address();
114 uintptr_t host_offset = host_addr - page->address();
110 DCHECK_LT(offset, static_cast<uintptr_t>(TypedSlotSet::kMaxOffset)); 115 DCHECK_LT(offset, static_cast<uintptr_t>(TypedSlotSet::kMaxOffset));
111 slot_set->Insert(slot_type, static_cast<uint32_t>(offset)); 116 DCHECK_LT(host_offset, static_cast<uintptr_t>(TypedSlotSet::kMaxOffset));
117 slot_set->Insert(slot_type, static_cast<uint32_t>(host_offset),
118 static_cast<uint32_t>(offset));
112 } 119 }
113 120
114 // Given a page and a range of typed slots in that page, this function removes 121 // Given a page and a range of typed slots in that page, this function removes
115 // the slots from the remembered set. 122 // the slots from the remembered set.
116 static void RemoveRangeTyped(Page* page, Address start, Address end) { 123 static void RemoveRangeTyped(Page* page, Address start, Address end) {
117 TypedSlotSet* slots = GetTypedSlotSet(page); 124 TypedSlotSet* slots = GetTypedSlotSet(page);
118 if (slots != nullptr) { 125 if (slots != nullptr) {
119 slots->Iterate([start, end](SlotType slot_type, Address slot_addr) { 126 slots->Iterate([start, end](SlotType slot_type, Address host_addr,
127 Address slot_addr) {
120 return start <= slot_addr && slot_addr < end ? REMOVE_SLOT : KEEP_SLOT; 128 return start <= slot_addr && slot_addr < end ? REMOVE_SLOT : KEEP_SLOT;
121 }); 129 });
122 } 130 }
123 } 131 }
124 132
125 // Iterates and filters the remembered set with the given callback. 133 // Iterates and filters the remembered set with the given callback.
126 // The callback should take (SlotType slot_type, SlotAddress slot) and return 134 // The callback should take (SlotType slot_type, SlotAddress slot) and return
127 // SlotCallbackResult. 135 // SlotCallbackResult.
128 template <typename Callback> 136 template <typename Callback>
129 static void IterateTyped(Heap* heap, Callback callback) { 137 static void IterateTyped(Heap* heap, Callback callback) {
130 IterateMemoryChunks(heap, [callback](MemoryChunk* chunk) { 138 IterateMemoryChunks(heap, [callback](MemoryChunk* chunk) {
131 IterateTyped(chunk, callback); 139 IterateTyped(chunk, callback);
132 }); 140 });
133 } 141 }
134 142
135 // Iterates and filters typed old to old pointers in the given memory chunk 143 // Iterates and filters typed old to old pointers in the given memory chunk
136 // with the given callback. The callback should take (SlotType slot_type, 144 // with the given callback. The callback should take (SlotType slot_type,
137 // Address slot_addr) and return SlotCallbackResult. 145 // Address slot_addr) and return SlotCallbackResult.
138 template <typename Callback> 146 template <typename Callback>
139 static void IterateTyped(MemoryChunk* chunk, Callback callback) { 147 static void IterateTyped(MemoryChunk* chunk, Callback callback) {
140 TypedSlotSet* slots = GetTypedSlotSet(chunk); 148 TypedSlotSet* slots = GetTypedSlotSet(chunk);
141 if (slots != nullptr) { 149 if (slots != nullptr) {
142 int new_count = slots->Iterate(callback); 150 int new_count = slots->Iterate(callback);
143 if (new_count == 0) { 151 if (new_count == 0) {
144 ReleaseTypedSlotSet(chunk); 152 ReleaseTypedSlotSet(chunk);
145 chunk->ReleaseTypedOldToOldSlots();
146 } 153 }
147 } 154 }
148 } 155 }
149 156
150 // Clear all old to old slots from the remembered set. 157 // Clear all old to old slots from the remembered set.
151 static void ClearAll(Heap* heap) { 158 static void ClearAll(Heap* heap) {
152 STATIC_ASSERT(direction == OLD_TO_OLD); 159 STATIC_ASSERT(direction == OLD_TO_OLD);
153 MemoryChunkIterator it(heap); 160 MemoryChunkIterator it(heap);
154 MemoryChunk* chunk; 161 MemoryChunk* chunk;
155 while ((chunk = it.next()) != nullptr) { 162 while ((chunk = it.next()) != nullptr) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 342 }
336 UNREACHABLE(); 343 UNREACHABLE();
337 return REMOVE_SLOT; 344 return REMOVE_SLOT;
338 } 345 }
339 }; 346 };
340 347
341 } // namespace internal 348 } // namespace internal
342 } // namespace v8 349 } // namespace v8
343 350
344 #endif // V8_REMEMBERED_SET_H 351 #endif // V8_REMEMBERED_SET_H
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/slot-set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698