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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 115 } |
116 | 116 |
117 | 117 |
118 void CodeFlusher::ClearNextCandidate(SharedFunctionInfo* candidate) { | 118 void CodeFlusher::ClearNextCandidate(SharedFunctionInfo* candidate) { |
119 candidate->code()->set_gc_metadata(NULL, SKIP_WRITE_BARRIER); | 119 candidate->code()->set_gc_metadata(NULL, SKIP_WRITE_BARRIER); |
120 } | 120 } |
121 | 121 |
122 | 122 |
123 template <LiveObjectIterationMode T> | 123 template <LiveObjectIterationMode T> |
124 HeapObject* LiveObjectIterator<T>::Next() { | 124 HeapObject* LiveObjectIterator<T>::Next() { |
| 125 Map* one_word_filler = heap()->one_pointer_filler_map(); |
| 126 Map* two_word_filler = heap()->two_pointer_filler_map(); |
| 127 Map* free_space_map = heap()->free_space_map(); |
125 while (!it_.Done()) { | 128 while (!it_.Done()) { |
126 HeapObject* object = nullptr; | 129 HeapObject* object = nullptr; |
127 while (current_cell_ != 0) { | 130 while (current_cell_ != 0) { |
128 uint32_t trailing_zeros = base::bits::CountTrailingZeros32(current_cell_); | 131 uint32_t trailing_zeros = base::bits::CountTrailingZeros32(current_cell_); |
129 Address addr = cell_base_ + trailing_zeros * kPointerSize; | 132 Address addr = cell_base_ + trailing_zeros * kPointerSize; |
130 | 133 |
131 // Clear the first bit of the found object.. | 134 // Clear the first bit of the found object.. |
132 current_cell_ &= ~(1u << trailing_zeros); | 135 current_cell_ &= ~(1u << trailing_zeros); |
133 | 136 |
134 uint32_t second_bit_index = 0; | 137 uint32_t second_bit_index = 0; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 if (T == kBlackObjects || T == kAllLiveObjects) { | 189 if (T == kBlackObjects || T == kAllLiveObjects) { |
187 object = black_object; | 190 object = black_object; |
188 } | 191 } |
189 } else if ((T == kGreyObjects || T == kAllLiveObjects)) { | 192 } else if ((T == kGreyObjects || T == kAllLiveObjects)) { |
190 map = base::NoBarrierAtomicValue<Map*>::FromAddress(addr)->Value(); | 193 map = base::NoBarrierAtomicValue<Map*>::FromAddress(addr)->Value(); |
191 object = HeapObject::FromAddress(addr); | 194 object = HeapObject::FromAddress(addr); |
192 } | 195 } |
193 | 196 |
194 // We found a live object. | 197 // We found a live object. |
195 if (object != nullptr) { | 198 if (object != nullptr) { |
196 if (object->IsFiller()) { | 199 // Do not use IsFiller() here. This may cause a data race for reading |
| 200 // out the instance type when a new map concurrently is written into |
| 201 // this object while iterating over the object. |
| 202 if (map == one_word_filler || map == two_word_filler || |
| 203 map == free_space_map) { |
197 // There are two reasons why we can get black or grey fillers: | 204 // There are two reasons why we can get black or grey fillers: |
198 // 1) Black areas together with slack tracking may result in black one | 205 // 1) Black areas together with slack tracking may result in black one |
199 // word filler objects. | 206 // word filler objects. |
200 // 2) Left trimming may leave black or grey fillers behind because we | 207 // 2) Left trimming may leave black or grey fillers behind because we |
201 // do not clear the old location of the object start. | 208 // do not clear the old location of the object start. |
202 // We filter these objects out in the iterator. | 209 // We filter these objects out in the iterator. |
203 object = nullptr; | 210 object = nullptr; |
204 } else { | 211 } else { |
205 break; | 212 break; |
206 } | 213 } |
207 } | 214 } |
208 } | 215 } |
209 | 216 |
210 if (current_cell_ == 0) { | 217 if (current_cell_ == 0) { |
211 if (!it_.Done() && it_.Advance()) { | 218 if (!it_.Done() && it_.Advance()) { |
212 cell_base_ = it_.CurrentCellBase(); | 219 cell_base_ = it_.CurrentCellBase(); |
213 current_cell_ = *it_.CurrentCell(); | 220 current_cell_ = *it_.CurrentCell(); |
214 } | 221 } |
215 } | 222 } |
216 if (object != nullptr) return object; | 223 if (object != nullptr) return object; |
217 } | 224 } |
218 return nullptr; | 225 return nullptr; |
219 } | 226 } |
220 | 227 |
221 } // namespace internal | 228 } // namespace internal |
222 } // namespace v8 | 229 } // namespace v8 |
223 | 230 |
224 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 231 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
OLD | NEW |