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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 void CodeFlusher::ClearNextCandidate(SharedFunctionInfo* candidate) { | 137 void CodeFlusher::ClearNextCandidate(SharedFunctionInfo* candidate) { |
138 candidate->code()->set_gc_metadata(NULL, SKIP_WRITE_BARRIER); | 138 candidate->code()->set_gc_metadata(NULL, SKIP_WRITE_BARRIER); |
139 } | 139 } |
140 | 140 |
141 | 141 |
142 template <LiveObjectIterationMode T> | 142 template <LiveObjectIterationMode T> |
143 HeapObject* LiveObjectIterator<T>::Next() { | 143 HeapObject* LiveObjectIterator<T>::Next() { |
144 while (!it_.Done()) { | 144 while (!it_.Done()) { |
145 HeapObject* object = nullptr; | 145 HeapObject* object = nullptr; |
| 146 if (T == kGreyObjectsOnBlackPage) { |
| 147 // Black objects will have most of the mark bits set to 1. If we invert |
| 148 // the mark bits, grey objects will be left but the mark bit is moved by |
| 149 // one position. We can just substract one word from the found location |
| 150 // to obtain the grey object. |
| 151 current_cell_ = ~current_cell_; |
| 152 } |
146 while (current_cell_ != 0) { | 153 while (current_cell_ != 0) { |
147 uint32_t trailing_zeros = base::bits::CountTrailingZeros32(current_cell_); | 154 uint32_t trailing_zeros = base::bits::CountTrailingZeros32(current_cell_); |
148 Address addr = cell_base_ + trailing_zeros * kPointerSize; | 155 Address addr = cell_base_ + trailing_zeros * kPointerSize; |
149 | 156 |
| 157 if (T == kGreyObjectsOnBlackPage) { |
| 158 addr -= kPointerSize; |
| 159 } |
| 160 |
150 // Clear the first bit of the found object.. | 161 // Clear the first bit of the found object.. |
151 current_cell_ &= ~(1u << trailing_zeros); | 162 current_cell_ &= ~(1u << trailing_zeros); |
152 | 163 |
153 uint32_t second_bit_index = 0; | 164 uint32_t second_bit_index = 0; |
154 if (trailing_zeros < Bitmap::kBitIndexMask) { | 165 if (trailing_zeros < Bitmap::kBitIndexMask) { |
155 second_bit_index = 1u << (trailing_zeros + 1); | 166 second_bit_index = 1u << (trailing_zeros + 1); |
156 } else { | 167 } else { |
157 second_bit_index = 0x1; | 168 second_bit_index = 0x1; |
158 // The overlapping case; there has to exist a cell after the current | 169 // The overlapping case; there has to exist a cell after the current |
159 // cell. | 170 // cell. |
160 DCHECK(!it_.Done()); | 171 DCHECK(!it_.Done()); |
161 it_.Advance(); | 172 it_.Advance(); |
162 cell_base_ = it_.CurrentCellBase(); | 173 cell_base_ = it_.CurrentCellBase(); |
163 current_cell_ = *it_.CurrentCell(); | 174 current_cell_ = *it_.CurrentCell(); |
164 } | 175 } |
165 if (T == kBlackObjects && (current_cell_ & second_bit_index)) { | 176 if (T == kBlackObjects && (current_cell_ & second_bit_index)) { |
166 object = HeapObject::FromAddress(addr); | 177 object = HeapObject::FromAddress(addr); |
167 } else if (T == kGreyObjects && !(current_cell_ & second_bit_index)) { | 178 } else if (T == kGreyObjects && !(current_cell_ & second_bit_index)) { |
168 object = HeapObject::FromAddress(addr); | 179 object = HeapObject::FromAddress(addr); |
169 } else if (T == kAllLiveObjects) { | 180 } else if (T == kAllLiveObjects) { |
170 object = HeapObject::FromAddress(addr); | 181 object = HeapObject::FromAddress(addr); |
| 182 } else if (T == kGreyObjectsOnBlackPage) { |
| 183 object = HeapObject::FromAddress(addr); |
171 } | 184 } |
172 // Clear the second bit of the found object. | 185 // Clear the second bit of the found object. |
173 current_cell_ &= ~second_bit_index; | 186 current_cell_ &= ~second_bit_index; |
174 | 187 |
175 // We found a live object. | 188 // We found a live object. |
176 if (object != nullptr) break; | 189 if (object != nullptr) break; |
177 } | 190 } |
178 if (current_cell_ == 0) { | 191 if (current_cell_ == 0) { |
179 if (!it_.Done()) { | 192 if (!it_.Done()) { |
180 it_.Advance(); | 193 it_.Advance(); |
181 cell_base_ = it_.CurrentCellBase(); | 194 cell_base_ = it_.CurrentCellBase(); |
182 current_cell_ = *it_.CurrentCell(); | 195 current_cell_ = *it_.CurrentCell(); |
183 } | 196 } |
184 } | 197 } |
185 if (object != nullptr) return object; | 198 if (object != nullptr) return object; |
186 } | 199 } |
187 return nullptr; | 200 return nullptr; |
188 } | 201 } |
189 | 202 |
190 } // namespace internal | 203 } // namespace internal |
191 } // namespace v8 | 204 } // namespace v8 |
192 | 205 |
193 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 206 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
OLD | NEW |