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 DCHECK(!it_.Done()); | 151 // However, if there is a black area at the end of the page, and the |
| 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 } |
152 it_.Advance(); | 161 it_.Advance(); |
153 cell_base_ = it_.CurrentCellBase(); | 162 cell_base_ = it_.CurrentCellBase(); |
154 current_cell_ = *it_.CurrentCell(); | 163 current_cell_ = *it_.CurrentCell(); |
155 } | 164 } |
156 if (T == kBlackObjects && (current_cell_ & second_bit_index)) { | 165 |
157 object = HeapObject::FromAddress(addr); | 166 if (current_cell_ & second_bit_index) { |
158 } else if (T == kGreyObjects && !(current_cell_ & second_bit_index)) { | 167 // We found a black object. If the black object is within a black area, |
159 object = HeapObject::FromAddress(addr); | 168 // make sure that we skip all set bits in the black area until the |
160 } else if (T == kAllLiveObjects) { | 169 // object ends. |
| 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)) { |
161 object = HeapObject::FromAddress(addr); | 196 object = HeapObject::FromAddress(addr); |
162 } | 197 } |
163 | 198 |
164 // Clear the second bit of the found object. | 199 // We found a live object. |
165 current_cell_ &= ~second_bit_index; | 200 if (object != nullptr) { |
| 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 } |
166 | 210 |
167 // We found a live object. | |
168 if (object != nullptr) break; | |
169 } | |
170 if (current_cell_ == 0) { | 211 if (current_cell_ == 0) { |
171 if (!it_.Done()) { | 212 if (!it_.Done()) { |
172 it_.Advance(); | 213 it_.Advance(); |
173 cell_base_ = it_.CurrentCellBase(); | 214 cell_base_ = it_.CurrentCellBase(); |
174 current_cell_ = *it_.CurrentCell(); | 215 current_cell_ = *it_.CurrentCell(); |
175 } | 216 } |
176 } | 217 } |
177 if (object != nullptr) return object; | 218 if (object != nullptr) return object; |
178 } | 219 } |
179 return nullptr; | 220 return nullptr; |
180 } | 221 } |
181 | 222 |
182 } // namespace internal | 223 } // namespace internal |
183 } // namespace v8 | 224 } // namespace v8 |
184 | 225 |
185 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 226 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
OLD | NEW |