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

Unified Diff: src/heap/sequential-marking-deque.h

Issue 2854063002: [heap] Refactor updating of marking deque after scavenge. (Closed)
Patch Set: Created 3 years, 8 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/incremental-marking.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/sequential-marking-deque.h
diff --git a/src/heap/sequential-marking-deque.h b/src/heap/sequential-marking-deque.h
index a72704817355aa06cd68d1382634697c16cc3ed9..bd579ba713daad719d206db73d5eef32d81871d3 100644
--- a/src/heap/sequential-marking-deque.h
+++ b/src/heap/sequential-marking-deque.h
@@ -95,11 +95,26 @@ class SequentialMarkingDeque {
}
}
- HeapObject** array() { return array_; }
- int bottom() { return bottom_; }
+ // Calls the specified callback on each element of the deque and replaces
+ // the element with the result of the callback. If the callback returns
+ // nullptr then the element is removed from the deque.
+ // The callback must accept HeapObject* and return HeapObject*.
+ template <typename Callback>
+ void Update(Callback callback) {
+ int i = bottom_;
+ int new_top = bottom_;
+ while (i != top_) {
+ HeapObject* object = callback(array_[i]);
+ if (object) {
+ array_[new_top] = object;
+ new_top = (new_top + 1) & mask_;
+ }
+ i = (i + 1) & mask_;
+ }
+ top_ = new_top;
+ }
+
int top() { return top_; }
- int mask() { return mask_; }
- void set_top(int top) { top_ = top; }
private:
// This task uncommits the marking_deque backing store if
« no previous file with comments | « src/heap/incremental-marking.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698