OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium 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 MarkingVisitor_h | 5 #ifndef MarkingVisitor_h |
6 #define MarkingVisitor_h | 6 #define MarkingVisitor_h |
7 | 7 |
8 #include "platform/heap/MarkingVisitorImpl.h" | 8 #include "platform/heap/MarkingVisitorImpl.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 class MarkingVisitor final : public Visitor, | 12 class MarkingVisitor final : public Visitor, |
13 public MarkingVisitorImpl<MarkingVisitor> { | 13 public MarkingVisitorImpl<MarkingVisitor> { |
14 public: | 14 public: |
15 using Impl = MarkingVisitorImpl<MarkingVisitor>; | 15 using Impl = MarkingVisitorImpl<MarkingVisitor>; |
16 friend class MarkingVisitorImpl<MarkingVisitor>; | |
17 | 16 |
18 explicit MarkingVisitor(ThreadState* state, Visitor::MarkingMode mode) | 17 MarkingVisitor(ThreadState* state, Visitor::MarkingMode mode) |
19 : Visitor(state, mode) {} | 18 : Visitor(state, mode) {} |
20 | 19 |
21 void markHeader(HeapObjectHeader* header, TraceCallback callback) override { | 20 void markHeader(HeapObjectHeader* header, TraceCallback callback) override { |
22 Impl::markHeader(header, header->payload(), callback); | 21 Impl::markHeader(header, header->payload(), callback); |
23 } | 22 } |
24 | 23 |
25 void mark(const void* objectPointer, TraceCallback callback) override { | 24 void mark(const void* objectPointer, TraceCallback callback) override { |
26 Impl::mark(objectPointer, callback); | 25 Impl::mark(objectPointer, callback); |
27 } | 26 } |
28 | 27 |
(...skipping 30 matching lines...) Expand all Loading... |
59 } | 58 } |
60 | 59 |
61 bool ensureMarked(const void* objectPointer) override { | 60 bool ensureMarked(const void* objectPointer) override { |
62 return Impl::ensureMarked(objectPointer); | 61 return Impl::ensureMarked(objectPointer); |
63 } | 62 } |
64 | 63 |
65 void registerWeakCellWithCallback(void** cell, | 64 void registerWeakCellWithCallback(void** cell, |
66 WeakCallback callback) override { | 65 WeakCallback callback) override { |
67 Impl::registerWeakCellWithCallback(cell, callback); | 66 Impl::registerWeakCellWithCallback(cell, callback); |
68 } | 67 } |
69 | |
70 protected: | |
71 inline bool shouldMarkObject(const void* objectPointer) const { | |
72 if (getMarkingMode() != ThreadLocalMarking) | |
73 return true; | |
74 | |
75 BasePage* page = pageFromObject(objectPointer); | |
76 ASSERT(!page->orphaned()); | |
77 // When doing a thread local GC, the marker checks if | |
78 // the object resides in another thread's heap. If it | |
79 // does, the object should not be marked & traced. | |
80 return page->terminating(); | |
81 } | |
82 }; | 68 }; |
83 | 69 |
84 } // namespace blink | 70 } // namespace blink |
85 | 71 |
86 #endif | 72 #endif |
OLD | NEW |