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

Side by Side Diff: src/heap/mark-compact-inl.h

Issue 2477823003: [heap] Make LiveObjectIterator concurrency safe (Closed)
Patch Set: Fix condition Created 4 years, 1 month 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.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_HEAP_MARK_COMPACT_INL_H_ 5 #ifndef V8_HEAP_MARK_COMPACT_INL_H_
6 #define V8_HEAP_MARK_COMPACT_INL_H_ 6 #define V8_HEAP_MARK_COMPACT_INL_H_
7 7
8 #include "src/heap/mark-compact.h" 8 #include "src/heap/mark-compact.h"
9 #include "src/heap/remembered-set.h" 9 #include "src/heap/remembered-set.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 HeapObject::FromAddress(addr) 156 HeapObject::FromAddress(addr)
157 ->GetHeap() 157 ->GetHeap()
158 ->one_pointer_filler_map()); 158 ->one_pointer_filler_map());
159 return nullptr; 159 return nullptr;
160 } 160 }
161 it_.Advance(); 161 it_.Advance();
162 cell_base_ = it_.CurrentCellBase(); 162 cell_base_ = it_.CurrentCellBase();
163 current_cell_ = *it_.CurrentCell(); 163 current_cell_ = *it_.CurrentCell();
164 } 164 }
165 165
166 Map* map = nullptr;
166 if (current_cell_ & second_bit_index) { 167 if (current_cell_ & second_bit_index) {
167 // We found a black object. If the black object is within a black area, 168 // We found a black object. If the black object is within a black area,
168 // make sure that we skip all set bits in the black area until the 169 // make sure that we skip all set bits in the black area until the
169 // object ends. 170 // object ends.
170 HeapObject* black_object = HeapObject::FromAddress(addr); 171 HeapObject* black_object = HeapObject::FromAddress(addr);
171 Address end = addr + black_object->Size() - kPointerSize; 172 map = base::NoBarrierAtomicValue<Map*>::FromAddress(addr)->Value();
173 Address end = addr + black_object->SizeFromMap(map) - kPointerSize;
172 // One word filler objects do not borrow the second mark bit. We have 174 // One word filler objects do not borrow the second mark bit. We have
173 // to jump over the advancing and clearing part. 175 // to jump over the advancing and clearing part.
174 // Note that we know that we are at a one word filler when 176 // Note that we know that we are at a one word filler when
175 // object_start + object_size - kPointerSize == object_start. 177 // object_start + object_size - kPointerSize == object_start.
176 if (addr != end) { 178 if (addr != end) {
177 DCHECK_EQ(chunk_, MemoryChunk::FromAddress(end)); 179 DCHECK_EQ(chunk_, MemoryChunk::FromAddress(end));
178 uint32_t end_mark_bit_index = chunk_->AddressToMarkbitIndex(end); 180 uint32_t end_mark_bit_index = chunk_->AddressToMarkbitIndex(end);
179 unsigned int end_cell_index = 181 unsigned int end_cell_index =
180 end_mark_bit_index >> Bitmap::kBitsPerCellLog2; 182 end_mark_bit_index >> Bitmap::kBitsPerCellLog2;
181 MarkBit::CellType end_index_mask = 183 MarkBit::CellType end_index_mask =
182 1u << Bitmap::IndexInCell(end_mark_bit_index); 184 1u << Bitmap::IndexInCell(end_mark_bit_index);
183 if (it_.Advance(end_cell_index)) { 185 if (it_.Advance(end_cell_index)) {
184 cell_base_ = it_.CurrentCellBase(); 186 cell_base_ = it_.CurrentCellBase();
185 current_cell_ = *it_.CurrentCell(); 187 current_cell_ = *it_.CurrentCell();
186 } 188 }
187 189
188 // Clear all bits in current_cell, including the end index. 190 // Clear all bits in current_cell, including the end index.
189 current_cell_ &= ~(end_index_mask + end_index_mask - 1); 191 current_cell_ &= ~(end_index_mask + end_index_mask - 1);
190 } 192 }
191 193
192 if (T == kBlackObjects || T == kAllLiveObjects) { 194 if (T == kBlackObjects || T == kAllLiveObjects) {
193 object = black_object; 195 object = black_object;
194 } 196 }
195 } else if ((T == kGreyObjects || T == kAllLiveObjects)) { 197 } else if ((T == kGreyObjects || T == kAllLiveObjects)) {
196 object = HeapObject::FromAddress(addr); 198 object = HeapObject::FromAddress(addr);
197 } 199 }
198 200
199 // We found a live object. 201 // We found a live object.
200 if (object != nullptr) { 202 if (object != nullptr) {
201 if (object->IsFiller()) { 203 if (map != nullptr && map == heap()->one_pointer_filler_map()) {
202 // Black areas together with slack tracking may result in black filler 204 // Black areas together with slack tracking may result in black one
203 // objects. We filter these objects out in the iterator. 205 // word filler objects. We filter these objects out in the iterator.
204 object = nullptr; 206 object = nullptr;
205 } else { 207 } else {
206 break; 208 break;
207 } 209 }
208 } 210 }
209 } 211 }
210 212
211 if (current_cell_ == 0) { 213 if (current_cell_ == 0) {
212 if (!it_.Done()) { 214 if (!it_.Done()) {
213 it_.Advance(); 215 it_.Advance();
214 cell_base_ = it_.CurrentCellBase(); 216 cell_base_ = it_.CurrentCellBase();
215 current_cell_ = *it_.CurrentCell(); 217 current_cell_ = *it_.CurrentCell();
216 } 218 }
217 } 219 }
218 if (object != nullptr) return object; 220 if (object != nullptr) return object;
219 } 221 }
220 return nullptr; 222 return nullptr;
221 } 223 }
222 224
223 } // namespace internal 225 } // namespace internal
224 } // namespace v8 226 } // namespace v8
225 227
226 #endif // V8_HEAP_MARK_COMPACT_INL_H_ 228 #endif // V8_HEAP_MARK_COMPACT_INL_H_
OLDNEW
« no previous file with comments | « src/heap/mark-compact.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698