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/slots-buffer.h" | 9 #include "src/heap/slots-buffer.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 void CodeFlusher::SetNextCandidate(SharedFunctionInfo* candidate, | 133 void CodeFlusher::SetNextCandidate(SharedFunctionInfo* candidate, |
134 SharedFunctionInfo* next_candidate) { | 134 SharedFunctionInfo* next_candidate) { |
135 candidate->code()->set_gc_metadata(next_candidate); | 135 candidate->code()->set_gc_metadata(next_candidate); |
136 } | 136 } |
137 | 137 |
138 | 138 |
139 void CodeFlusher::ClearNextCandidate(SharedFunctionInfo* candidate) { | 139 void CodeFlusher::ClearNextCandidate(SharedFunctionInfo* candidate) { |
140 candidate->code()->set_gc_metadata(NULL, SKIP_WRITE_BARRIER); | 140 candidate->code()->set_gc_metadata(NULL, SKIP_WRITE_BARRIER); |
141 } | 141 } |
142 | 142 |
| 143 |
| 144 template <LiveObjectIterationMode T> |
| 145 HeapObject* LiveObjectIterator<T>::Next() { |
| 146 while (!it_.Done()) { |
| 147 HeapObject* object = nullptr; |
| 148 while (current_cell_ != 0) { |
| 149 uint32_t trailing_zeros = base::bits::CountTrailingZeros32(current_cell_); |
| 150 Address addr = cell_base_ + trailing_zeros * kPointerSize; |
| 151 |
| 152 // Clear the first bit of the found object.. |
| 153 current_cell_ &= ~(1u << trailing_zeros); |
| 154 |
| 155 uint32_t second_bit_index = 0; |
| 156 if (trailing_zeros < Bitmap::kBitIndexMask) { |
| 157 second_bit_index = 1u << (trailing_zeros + 1); |
| 158 } else { |
| 159 second_bit_index = 0x1; |
| 160 // The overlapping case; there has to exist a cell after the current |
| 161 // cell. |
| 162 DCHECK(!it_.Done()); |
| 163 it_.Advance(); |
| 164 cell_base_ = it_.CurrentCellBase(); |
| 165 current_cell_ = *it_.CurrentCell(); |
| 166 } |
| 167 if (T == kBlackObjects && (current_cell_ & second_bit_index)) { |
| 168 object = HeapObject::FromAddress(addr); |
| 169 } else if (T == kGreyObjects && !(current_cell_ & second_bit_index)) { |
| 170 object = HeapObject::FromAddress(addr); |
| 171 } else if (T == kAllLiveObjects) { |
| 172 object = HeapObject::FromAddress(addr); |
| 173 } |
| 174 // Clear the second bit of the found object. |
| 175 current_cell_ &= ~second_bit_index; |
| 176 |
| 177 // We found a live object. |
| 178 if (object != nullptr) break; |
| 179 } |
| 180 if (current_cell_ == 0) { |
| 181 if (!it_.Done()) { |
| 182 it_.Advance(); |
| 183 cell_base_ = it_.CurrentCellBase(); |
| 184 current_cell_ = *it_.CurrentCell(); |
| 185 } |
| 186 } |
| 187 if (object != nullptr) return object; |
| 188 } |
| 189 return nullptr; |
| 190 } |
| 191 |
143 } // namespace internal | 192 } // namespace internal |
144 } // namespace v8 | 193 } // namespace v8 |
145 | 194 |
146 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 195 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
OLD | NEW |