OLD | NEW |
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 second_bit_index = 1u << (trailing_zeros + 1); | 146 second_bit_index = 1u << (trailing_zeros + 1); |
147 } else { | 147 } else { |
148 second_bit_index = 0x1; | 148 second_bit_index = 0x1; |
149 // The overlapping case; there has to exist a cell after the current | 149 // The overlapping case; there has to exist a cell after the current |
150 // cell. | 150 // cell. |
151 DCHECK(!it_.Done()); | 151 DCHECK(!it_.Done()); |
152 it_.Advance(); | 152 it_.Advance(); |
153 cell_base_ = it_.CurrentCellBase(); | 153 cell_base_ = it_.CurrentCellBase(); |
154 current_cell_ = *it_.CurrentCell(); | 154 current_cell_ = *it_.CurrentCell(); |
155 } | 155 } |
156 if (T == kBlackObjects && (current_cell_ & second_bit_index)) { | 156 |
157 object = HeapObject::FromAddress(addr); | 157 if (current_cell_ & second_bit_index) { |
158 } else if (T == kGreyObjects && !(current_cell_ & second_bit_index)) { | 158 // We found a black object. If the black object is within a black area, |
159 object = HeapObject::FromAddress(addr); | 159 // make sure that we skip all set bits in the black area until the |
160 } else if (T == kAllLiveObjects) { | 160 // object ends. |
| 161 HeapObject* black_object = HeapObject::FromAddress(addr); |
| 162 Address end = addr + black_object->Size() - kPointerSize; |
| 163 DCHECK_EQ(chunk_, MemoryChunk::FromAddress(end)); |
| 164 uint32_t end_mark_bit_index = chunk_->AddressToMarkbitIndex(end); |
| 165 unsigned int end_cell_index = |
| 166 end_mark_bit_index >> Bitmap::kBitsPerCellLog2; |
| 167 MarkBit::CellType end_index_mask = |
| 168 1u << Bitmap::IndexInCell(end_mark_bit_index); |
| 169 if (it_.Advance(end_cell_index)) { |
| 170 cell_base_ = it_.CurrentCellBase(); |
| 171 current_cell_ = *it_.CurrentCell(); |
| 172 } |
| 173 |
| 174 // Clear all bits in current_cell, including the end index. |
| 175 current_cell_ &= ~(end_index_mask + end_index_mask - 1); |
| 176 |
| 177 if (T == kBlackObjects || T == kAllLiveObjects) { |
| 178 object = black_object; |
| 179 } |
| 180 } else if ((T == kGreyObjects || T == kAllLiveObjects)) { |
161 object = HeapObject::FromAddress(addr); | 181 object = HeapObject::FromAddress(addr); |
162 } | 182 } |
163 | 183 |
164 // Clear the second bit of the found object. | 184 // We found a live object. |
165 current_cell_ &= ~second_bit_index; | 185 if (object != nullptr) { |
| 186 if (object->IsFiller()) { |
| 187 // Black areas together with slack tracking may result in black filler |
| 188 // objects. We filter these objects out in the iterator. |
| 189 object = nullptr; |
| 190 } else { |
| 191 break; |
| 192 } |
| 193 } |
| 194 } |
166 | 195 |
167 // We found a live object. | |
168 if (object != nullptr) break; | |
169 } | |
170 if (current_cell_ == 0) { | 196 if (current_cell_ == 0) { |
171 if (!it_.Done()) { | 197 if (!it_.Done()) { |
172 it_.Advance(); | 198 it_.Advance(); |
173 cell_base_ = it_.CurrentCellBase(); | 199 cell_base_ = it_.CurrentCellBase(); |
174 current_cell_ = *it_.CurrentCell(); | 200 current_cell_ = *it_.CurrentCell(); |
175 } | 201 } |
176 } | 202 } |
177 if (object != nullptr) return object; | 203 if (object != nullptr) return object; |
178 } | 204 } |
179 return nullptr; | 205 return nullptr; |
180 } | 206 } |
181 | 207 |
182 } // namespace internal | 208 } // namespace internal |
183 } // namespace v8 | 209 } // namespace v8 |
184 | 210 |
185 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 211 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
OLD | NEW |