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 | 156 if (T == kBlackObjects && (current_cell_ & second_bit_index)) { |
157 if (current_cell_ & second_bit_index) { | 157 object = HeapObject::FromAddress(addr); |
158 // We found a black object. If the black object is within a black area, | 158 } else if (T == kGreyObjects && !(current_cell_ & second_bit_index)) { |
159 // make sure that we skip all set bits in the black area until the | 159 object = HeapObject::FromAddress(addr); |
160 // object ends. | 160 } else if (T == kAllLiveObjects) { |
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)) { | |
181 object = HeapObject::FromAddress(addr); | 161 object = HeapObject::FromAddress(addr); |
182 } | 162 } |
183 | 163 |
| 164 // Clear the second bit of the found object. |
| 165 current_cell_ &= ~second_bit_index; |
| 166 |
184 // We found a live object. | 167 // We found a live object. |
185 if (object != nullptr) break; | 168 if (object != nullptr) break; |
186 } | 169 } |
187 | |
188 if (current_cell_ == 0) { | 170 if (current_cell_ == 0) { |
189 if (!it_.Done()) { | 171 if (!it_.Done()) { |
190 it_.Advance(); | 172 it_.Advance(); |
191 cell_base_ = it_.CurrentCellBase(); | 173 cell_base_ = it_.CurrentCellBase(); |
192 current_cell_ = *it_.CurrentCell(); | 174 current_cell_ = *it_.CurrentCell(); |
193 } | 175 } |
194 } | 176 } |
195 if (object != nullptr) return object; | 177 if (object != nullptr) return object; |
196 } | 178 } |
197 return nullptr; | 179 return nullptr; |
198 } | 180 } |
199 | 181 |
200 } // namespace internal | 182 } // namespace internal |
201 } // namespace v8 | 183 } // namespace v8 |
202 | 184 |
203 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 185 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
OLD | NEW |