| 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
|
|
|