| 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 } | |
| 153 while (current_cell_ != 0) { | 146 while (current_cell_ != 0) { |
| 154 uint32_t trailing_zeros = base::bits::CountTrailingZeros32(current_cell_); | 147 uint32_t trailing_zeros = base::bits::CountTrailingZeros32(current_cell_); |
| 155 Address addr = cell_base_ + trailing_zeros * kPointerSize; | 148 Address addr = cell_base_ + trailing_zeros * kPointerSize; |
| 156 | 149 |
| 157 if (T == kGreyObjectsOnBlackPage) { | |
| 158 addr -= kPointerSize; | |
| 159 } | |
| 160 | |
| 161 // Clear the first bit of the found object.. | 150 // Clear the first bit of the found object.. |
| 162 current_cell_ &= ~(1u << trailing_zeros); | 151 current_cell_ &= ~(1u << trailing_zeros); |
| 163 | 152 |
| 164 uint32_t second_bit_index = 0; | 153 uint32_t second_bit_index = 0; |
| 165 if (trailing_zeros < Bitmap::kBitIndexMask) { | 154 if (trailing_zeros < Bitmap::kBitIndexMask) { |
| 166 second_bit_index = 1u << (trailing_zeros + 1); | 155 second_bit_index = 1u << (trailing_zeros + 1); |
| 167 } else { | 156 } else { |
| 168 second_bit_index = 0x1; | 157 second_bit_index = 0x1; |
| 169 // The overlapping case; there has to exist a cell after the current | 158 // The overlapping case; there has to exist a cell after the current |
| 170 // cell. | 159 // cell. |
| 171 DCHECK(!it_.Done()); | 160 DCHECK(!it_.Done()); |
| 172 it_.Advance(); | 161 it_.Advance(); |
| 173 cell_base_ = it_.CurrentCellBase(); | 162 cell_base_ = it_.CurrentCellBase(); |
| 174 current_cell_ = *it_.CurrentCell(); | 163 current_cell_ = *it_.CurrentCell(); |
| 175 } | 164 } |
| 176 if (T == kBlackObjects && (current_cell_ & second_bit_index)) { | 165 if (T == kBlackObjects && (current_cell_ & second_bit_index)) { |
| 177 object = HeapObject::FromAddress(addr); | 166 object = HeapObject::FromAddress(addr); |
| 178 } else if (T == kGreyObjects && !(current_cell_ & second_bit_index)) { | 167 } else if (T == kGreyObjects && !(current_cell_ & second_bit_index)) { |
| 179 object = HeapObject::FromAddress(addr); | 168 object = HeapObject::FromAddress(addr); |
| 180 } else if (T == kAllLiveObjects) { | 169 } else if (T == kAllLiveObjects) { |
| 181 object = HeapObject::FromAddress(addr); | 170 object = HeapObject::FromAddress(addr); |
| 182 } else if (T == kGreyObjectsOnBlackPage) { | |
| 183 object = HeapObject::FromAddress(addr); | |
| 184 } | 171 } |
| 185 | 172 |
| 186 if (T != kGreyObjectsOnBlackPage) { | 173 // Clear the second bit of the found object. |
| 187 // Clear the second bit of the found object. | 174 current_cell_ &= ~second_bit_index; |
| 188 current_cell_ &= ~second_bit_index; | |
| 189 } | |
| 190 | 175 |
| 191 // We found a live object. | 176 // We found a live object. |
| 192 if (object != nullptr) break; | 177 if (object != nullptr) break; |
| 193 } | 178 } |
| 194 if (current_cell_ == 0) { | 179 if (current_cell_ == 0) { |
| 195 if (!it_.Done()) { | 180 if (!it_.Done()) { |
| 196 it_.Advance(); | 181 it_.Advance(); |
| 197 cell_base_ = it_.CurrentCellBase(); | 182 cell_base_ = it_.CurrentCellBase(); |
| 198 current_cell_ = *it_.CurrentCell(); | 183 current_cell_ = *it_.CurrentCell(); |
| 199 } | 184 } |
| 200 } | 185 } |
| 201 if (object != nullptr) return object; | 186 if (object != nullptr) return object; |
| 202 } | 187 } |
| 203 return nullptr; | 188 return nullptr; |
| 204 } | 189 } |
| 205 | 190 |
| 206 } // namespace internal | 191 } // namespace internal |
| 207 } // namespace v8 | 192 } // namespace v8 |
| 208 | 193 |
| 209 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 194 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
| OLD | NEW |