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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 if (current_cell_ & second_bit_index) { | 166 if (current_cell_ & second_bit_index) { |
167 // We found a black object. If the black object is within a black area, | 167 // 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 | 168 // make sure that we skip all set bits in the black area until the |
169 // object ends. | 169 // object ends. |
170 HeapObject* black_object = HeapObject::FromAddress(addr); | 170 HeapObject* black_object = HeapObject::FromAddress(addr); |
171 Address end = addr + black_object->Size() - kPointerSize; | 171 Address end = addr + black_object->Size(); |
172 // One word filler objects do not borrow the second mark bit. We have | 172 // One word filler objects do not borrow the second mark bit. We have |
173 // to jump over the advancing and clearing part. | 173 // to jump over the advancing and clearing part. |
174 // Note that we know that we are at a one word filler when | 174 // Note that we know that we are at a one word filler when |
175 // object_start + object_size - kPointerSize == object_start. | 175 // object_start + object_size - kPointerSize == object_start. |
176 if (addr != end) { | 176 if (addr != end) { |
177 DCHECK_EQ(chunk_, MemoryChunk::FromAddress(end)); | 177 // Clear all bits from second_bit_index. |
178 uint32_t end_mark_bit_index = chunk_->AddressToMarkbitIndex(end); | 178 current_cell_ &= ~(second_bit_index | (second_bit_index - 1)); |
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 | 179 |
188 // Clear all bits in current_cell, including the end index. | 180 // Check that all bits corresponding to in object fields after the |
189 current_cell_ &= ~(end_index_mask | (end_index_mask - 1)); | 181 // two cleared bits in the beginning are indeed zero. |
| 182 CHECK(chunk_->markbits()->AllBitsClearInRange( |
| 183 chunk_->AddressToMarkbitIndex(addr + 2 * kPointerSize), |
| 184 chunk_->AddressToMarkbitIndex(end))); |
190 } | 185 } |
191 | 186 |
192 if (T == kBlackObjects || T == kAllLiveObjects) { | 187 if (T == kBlackObjects || T == kAllLiveObjects) { |
193 object = black_object; | 188 object = black_object; |
194 } | 189 } |
195 } else if ((T == kGreyObjects || T == kAllLiveObjects)) { | 190 } else if ((T == kGreyObjects || T == kAllLiveObjects)) { |
196 object = HeapObject::FromAddress(addr); | 191 object = HeapObject::FromAddress(addr); |
197 } | 192 } |
198 | 193 |
199 // We found a live object. | 194 // We found a live object. |
(...skipping 17 matching lines...) Expand all Loading... |
217 } | 212 } |
218 if (object != nullptr) return object; | 213 if (object != nullptr) return object; |
219 } | 214 } |
220 return nullptr; | 215 return nullptr; |
221 } | 216 } |
222 | 217 |
223 } // namespace internal | 218 } // namespace internal |
224 } // namespace v8 | 219 } // namespace v8 |
225 | 220 |
226 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 221 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
OLD | NEW |