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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // Clear the first bit of the found object.. | 141 // Clear the first bit of the found object.. |
142 current_cell_ &= ~(1u << trailing_zeros); | 142 current_cell_ &= ~(1u << trailing_zeros); |
143 | 143 |
144 uint32_t second_bit_index = 0; | 144 uint32_t second_bit_index = 0; |
145 if (trailing_zeros < Bitmap::kBitIndexMask) { | 145 if (trailing_zeros < Bitmap::kBitIndexMask) { |
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 // However, if there is a black area at the end of the page, and the | 151 DCHECK(!it_.Done()); |
152 // last word is a one word filler, we are not allowed to advance. In | |
153 // that case we can return immediately. | |
154 if (it_.Done()) { | |
155 DCHECK(HeapObject::FromAddress(addr)->map() == | |
156 HeapObject::FromAddress(addr) | |
157 ->GetHeap() | |
158 ->one_pointer_filler_map()); | |
159 return nullptr; | |
160 } | |
161 it_.Advance(); | 152 it_.Advance(); |
162 cell_base_ = it_.CurrentCellBase(); | 153 cell_base_ = it_.CurrentCellBase(); |
163 current_cell_ = *it_.CurrentCell(); | 154 current_cell_ = *it_.CurrentCell(); |
164 } | 155 } |
165 | 156 if (T == kBlackObjects && (current_cell_ & second_bit_index)) { |
166 if (current_cell_ & second_bit_index) { | 157 object = HeapObject::FromAddress(addr); |
167 // We found a black object. If the black object is within a black area, | 158 } else if (T == kGreyObjects && !(current_cell_ & second_bit_index)) { |
168 // make sure that we skip all set bits in the black area until the | 159 object = HeapObject::FromAddress(addr); |
169 // object ends. | 160 } else if (T == kAllLiveObjects) { |
170 HeapObject* black_object = HeapObject::FromAddress(addr); | |
171 Address end = addr + black_object->Size() - kPointerSize; | |
172 // One word filler objects do not borrow the second mark bit. We have | |
173 // to jump over the advancing and clearing part. | |
174 // Note that we know that we are at a one word filler when | |
175 // object_start + object_size - kPointerSize == object_start. | |
176 if (addr != end) { | |
177 DCHECK_EQ(chunk_, MemoryChunk::FromAddress(end)); | |
178 uint32_t end_mark_bit_index = chunk_->AddressToMarkbitIndex(end); | |
179 unsigned int end_cell_index = | |
180 end_mark_bit_index >> Bitmap::kBitsPerCellLog2; | |
181 MarkBit::CellType end_index_mask = | |
182 1u << Bitmap::IndexInCell(end_mark_bit_index); | |
183 if (it_.Advance(end_cell_index)) { | |
184 cell_base_ = it_.CurrentCellBase(); | |
185 current_cell_ = *it_.CurrentCell(); | |
186 } | |
187 | |
188 // Clear all bits in current_cell, including the end index. | |
189 current_cell_ &= ~(end_index_mask + end_index_mask - 1); | |
190 } | |
191 | |
192 if (T == kBlackObjects || T == kAllLiveObjects) { | |
193 object = black_object; | |
194 } | |
195 } else if ((T == kGreyObjects || T == kAllLiveObjects)) { | |
196 object = HeapObject::FromAddress(addr); | 161 object = HeapObject::FromAddress(addr); |
197 } | 162 } |
198 | 163 |
| 164 // Clear the second bit of the found object. |
| 165 current_cell_ &= ~second_bit_index; |
| 166 |
199 // We found a live object. | 167 // We found a live object. |
200 if (object != nullptr) { | 168 if (object != nullptr) break; |
201 if (object->IsFiller()) { | |
202 // Black areas together with slack tracking may result in black filler | |
203 // objects. We filter these objects out in the iterator. | |
204 object = nullptr; | |
205 } else { | |
206 break; | |
207 } | |
208 } | |
209 } | 169 } |
210 | |
211 if (current_cell_ == 0) { | 170 if (current_cell_ == 0) { |
212 if (!it_.Done()) { | 171 if (!it_.Done()) { |
213 it_.Advance(); | 172 it_.Advance(); |
214 cell_base_ = it_.CurrentCellBase(); | 173 cell_base_ = it_.CurrentCellBase(); |
215 current_cell_ = *it_.CurrentCell(); | 174 current_cell_ = *it_.CurrentCell(); |
216 } | 175 } |
217 } | 176 } |
218 if (object != nullptr) return object; | 177 if (object != nullptr) return object; |
219 } | 178 } |
220 return nullptr; | 179 return nullptr; |
221 } | 180 } |
222 | 181 |
223 } // namespace internal | 182 } // namespace internal |
224 } // namespace v8 | 183 } // namespace v8 |
225 | 184 |
226 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 185 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
OLD | NEW |