Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(685)

Unified Diff: src/heap/mark-compact-inl.h

Issue 1517993003: [heap] Black is encoded with 11, grey with 10. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/ia32/macro-assembler-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/mark-compact-inl.h
diff --git a/src/heap/mark-compact-inl.h b/src/heap/mark-compact-inl.h
index a539c64b1408bb4b881c80154028d480e64aaa02..a59d36bfa1c463a4ecdd23caa683c98ec14dd7d9 100644
--- a/src/heap/mark-compact-inl.h
+++ b/src/heap/mark-compact-inl.h
@@ -140,6 +140,55 @@ void CodeFlusher::ClearNextCandidate(SharedFunctionInfo* candidate) {
candidate->code()->set_gc_metadata(NULL, SKIP_WRITE_BARRIER);
}
+
+template <LiveObjectIterationMode T>
+HeapObject* LiveObjectIterator<T>::Next() {
+ while (!it_.Done()) {
+ HeapObject* object = nullptr;
+ while (current_cell_ != 0) {
+ uint32_t trailing_zeros = base::bits::CountTrailingZeros32(current_cell_);
+ Address addr = cell_base_ + trailing_zeros * kPointerSize;
+
+ // Clear the first bit of the found object..
+ current_cell_ &= ~(1u << trailing_zeros);
+
+ uint32_t second_bit_index = 0;
+ if (trailing_zeros < Bitmap::kBitIndexMask) {
+ second_bit_index = 1u << (trailing_zeros + 1);
+ } else {
+ second_bit_index = 0x1;
+ // The overlapping case; there has to exist a cell after the current
+ // cell.
+ DCHECK(!it_.Done());
+ it_.Advance();
+ cell_base_ = it_.CurrentCellBase();
+ current_cell_ = *it_.CurrentCell();
+ }
+ if (T == kBlackObjects && (current_cell_ & second_bit_index)) {
+ object = HeapObject::FromAddress(addr);
+ } else if (T == kGreyObjects && !(current_cell_ & second_bit_index)) {
+ object = HeapObject::FromAddress(addr);
+ } else if (T == kAllLiveObjects) {
+ object = HeapObject::FromAddress(addr);
+ }
+ // Clear the second bit of the found object.
+ current_cell_ &= ~second_bit_index;
+
+ // We found a live object.
+ if (object != nullptr) break;
+ }
+ if (current_cell_ == 0) {
+ if (!it_.Done()) {
+ it_.Advance();
+ cell_base_ = it_.CurrentCellBase();
+ current_cell_ = *it_.CurrentCell();
+ }
+ }
+ if (object != nullptr) return object;
+ }
+ return nullptr;
+}
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/ia32/macro-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698