Commit 7adbb4a2 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[heap] MC: Go through marking deque when marking roots

Bug: chromium:750084
Change-Id: I3c0059f1e986b5e4400f84f44b7f179e7232eae1
Reviewed-on: https://chromium-review.googlesource.com/610781
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47292}
parent 774c6413
...@@ -28,6 +28,15 @@ void MarkCompactCollector::MarkObject(HeapObject* host, HeapObject* obj) { ...@@ -28,6 +28,15 @@ void MarkCompactCollector::MarkObject(HeapObject* host, HeapObject* obj) {
} }
} }
void MarkCompactCollector::MarkRootObject(Root root, HeapObject* obj) {
if (non_atomic_marking_state()->WhiteToBlack(obj)) {
PushBlack(obj);
if (V8_UNLIKELY(FLAG_track_retaining_path)) {
heap_->AddRetainingRoot(root, obj);
}
}
}
void MarkCompactCollector::MarkExternallyReferencedObject(HeapObject* obj) { void MarkCompactCollector::MarkExternallyReferencedObject(HeapObject* obj) {
if (non_atomic_marking_state()->WhiteToBlack(obj)) { if (non_atomic_marking_state()->WhiteToBlack(obj)) {
PushBlack(obj); PushBlack(obj);
......
...@@ -1197,50 +1197,28 @@ void MinorMarkCompactCollector::CleanupSweepToIteratePages() { ...@@ -1197,50 +1197,28 @@ void MinorMarkCompactCollector::CleanupSweepToIteratePages() {
sweep_to_iterate_pages_.clear(); sweep_to_iterate_pages_.clear();
} }
class MarkCompactCollector::RootMarkingVisitor : public RootVisitor { class MarkCompactCollector::RootMarkingVisitor final : public RootVisitor {
public: public:
explicit RootMarkingVisitor(MarkCompactCollector* collector) explicit RootMarkingVisitor(MarkCompactCollector* collector)
: collector_(collector), : collector_(collector) {}
marking_state_(collector->non_atomic_marking_state()),
visitor_(collector_) {}
void VisitRootPointer(Root root, Object** p) override { void VisitRootPointer(Root root, Object** p) final {
MarkObjectByPointer(nullptr, p, root); MarkObjectByPointer(root, p);
} }
void VisitRootPointers(Root root, Object** start, Object** end) override { void VisitRootPointers(Root root, Object** start, Object** end) final {
for (Object** p = start; p < end; p++) for (Object** p = start; p < end; p++) MarkObjectByPointer(root, p);
MarkObjectByPointer(nullptr, p, root);
} }
private: private:
void MarkObjectByPointer(HeapObject* host, Object** p, V8_INLINE void MarkObjectByPointer(Root root, Object** p) {
Root root = Root::kUnknown) {
if (!(*p)->IsHeapObject()) return; if (!(*p)->IsHeapObject()) return;
HeapObject* object = HeapObject::cast(*p); collector_->MarkRootObject(root, HeapObject::cast(*p));
collector_->EmptyMarkingWorklist();
if (marking_state_->WhiteToBlack(object)) {
if (V8_UNLIKELY(FLAG_track_retaining_path)) {
if (host) {
object->GetHeap()->AddRetainer(host, object);
} else {
object->GetHeap()->AddRetainingRoot(root, object);
}
}
Map* map = object->map();
// Mark the map pointer and body, and push them on the marking stack.
collector_->MarkObject(object, map);
visitor_.Visit(map, object);
// Mark all the objects reachable from the map and body. May leave
// overflowed objects in the heap.
collector_->EmptyMarkingWorklist();
}
} }
MarkCompactCollector* const collector_; MarkCompactCollector* const collector_;
MarkCompactCollector::NonAtomicMarkingState* marking_state_;
MarkCompactMarkingVisitor visitor_;
}; };
// This visitor is used to visit the body of special objects held alive by // This visitor is used to visit the body of special objects held alive by
......
...@@ -776,14 +776,17 @@ class MarkCompactCollector final : public MarkCompactCollectorBase { ...@@ -776,14 +776,17 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
void MarkLiveObjects() override; void MarkLiveObjects() override;
// Pushes a black object onto the marking stack and accounts for live bytes. // Pushes a black object onto the marking work list.
// Note that this assumes live bytes have not yet been counted.
V8_INLINE void PushBlack(HeapObject* obj); V8_INLINE void PushBlack(HeapObject* obj);
// Marks the object black and pushes it on the marking stack. // Marks the object black and adds it to the marking work list.
// This is for non-incremental marking only. // This is for non-incremental marking only.
V8_INLINE void MarkObject(HeapObject* host, HeapObject* obj); V8_INLINE void MarkObject(HeapObject* host, HeapObject* obj);
// Marks the object black and adds it to the marking work list.
// This is for non-incremental marking only.
V8_INLINE void MarkRootObject(Root root, HeapObject* obj);
// Used by wrapper tracing. // Used by wrapper tracing.
V8_INLINE void MarkExternallyReferencedObject(HeapObject* obj); V8_INLINE void MarkExternallyReferencedObject(HeapObject* obj);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment