Chromium Code Reviews| Index: src/heap/mark-compact-inl.h |
| diff --git a/src/heap/mark-compact-inl.h b/src/heap/mark-compact-inl.h |
| index ceca4c4d8ce7c1ccd5b3c04486aca391b157dfc9..d3b8ab927f695b294fa1d08784097c89fa8ea245 100644 |
| --- a/src/heap/mark-compact-inl.h |
| +++ b/src/heap/mark-compact-inl.h |
| @@ -153,20 +153,36 @@ HeapObject* LiveObjectIterator<T>::Next() { |
| cell_base_ = it_.CurrentCellBase(); |
| current_cell_ = *it_.CurrentCell(); |
| } |
| - if (T == kBlackObjects && (current_cell_ & second_bit_index)) { |
| - object = HeapObject::FromAddress(addr); |
| - } else if (T == kGreyObjects && !(current_cell_ & second_bit_index)) { |
| - object = HeapObject::FromAddress(addr); |
| - } else if (T == kAllLiveObjects) { |
| + |
| + if (current_cell_ & second_bit_index) { |
| + // We found a black object. If the black object is within a black area, |
| + // make sure that we skip all set bits in the black area until the |
| + // object ends. |
| + HeapObject* black_object = HeapObject::FromAddress(addr); |
| + Address end = addr + black_object->Size() - kPointerSize; |
| + MemoryChunk* chunk = MemoryChunk::FromAddress(end); |
|
ulan
2016/07/19 13:23:32
DCHECK_EQ(chunk_, MemoryChunk::FromAddress(end));
Hannes Payer (out of office)
2016/07/19 14:42:53
Done.
|
| + uint32_t end_mark_bit_index = chunk->AddressToMarkbitIndex(end); |
| + unsigned int end_cell_index = |
| + end_mark_bit_index >> Bitmap::kBitsPerCellLog2; |
| + MarkBit::CellType end_index_mask = |
| + 1u << Bitmap::IndexInCell(end_mark_bit_index); |
| + if (it_.Advance(end_cell_index)) { |
| + cell_base_ = it_.CurrentCellBase(); |
| + current_cell_ = *it_.CurrentCell(); |
| + } |
|
ulan
2016/07/19 13:23:32
Let's add a comment, something like: Clear all bit
Hannes Payer (out of office)
2016/07/19 14:42:53
Done.
|
| + current_cell_ &= ~(end_index_mask + end_index_mask - 1); |
| + |
| + if (T == kBlackObjects || T == kAllLiveObjects) { |
| + object = black_object; |
| + } |
| + } else if ((T == kGreyObjects || T == kAllLiveObjects)) { |
| object = HeapObject::FromAddress(addr); |
| } |
| - // Clear the second bit of the found object. |
| - current_cell_ &= ~second_bit_index; |
| - |
| // We found a live object. |
| if (object != nullptr) break; |
| } |
| + |
| if (current_cell_ == 0) { |
| if (!it_.Done()) { |
| it_.Advance(); |