OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 InlinedGlobalMarkingVisitor_h | 5 #ifndef InlinedGlobalMarkingVisitor_h |
6 #define InlinedGlobalMarkingVisitor_h | 6 #define InlinedGlobalMarkingVisitor_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 InlinedGlobalMarkingVisitor final | 12 class InlinedGlobalMarkingVisitor final |
13 : public VisitorHelper<InlinedGlobalMarkingVisitor>, | 13 : public VisitorHelper<InlinedGlobalMarkingVisitor>, |
14 public MarkingVisitorImpl<InlinedGlobalMarkingVisitor> { | 14 public MarkingVisitorImpl<InlinedGlobalMarkingVisitor> { |
15 public: | 15 public: |
16 friend class VisitorHelper<InlinedGlobalMarkingVisitor>; | 16 friend class VisitorHelper<InlinedGlobalMarkingVisitor>; |
17 using Helper = VisitorHelper<InlinedGlobalMarkingVisitor>; | 17 using Helper = VisitorHelper<InlinedGlobalMarkingVisitor>; |
18 friend class MarkingVisitorImpl<InlinedGlobalMarkingVisitor>; | 18 friend class MarkingVisitorImpl<InlinedGlobalMarkingVisitor>; |
19 using Impl = MarkingVisitorImpl<InlinedGlobalMarkingVisitor>; | 19 using Impl = MarkingVisitorImpl<InlinedGlobalMarkingVisitor>; |
20 | 20 |
21 explicit InlinedGlobalMarkingVisitor(ThreadState* state) | 21 InlinedGlobalMarkingVisitor(ThreadState* state, |
22 : VisitorHelper(state) {} | 22 Visitor::MarkingMode markingMode) |
| 23 : VisitorHelper(state), m_markingMode(markingMode) {} |
23 | 24 |
24 // Hack to unify interface to visitor->trace(). | 25 // Hack to unify interface to visitor->trace(). |
25 // Without this hack, we need to use visitor.trace() for | 26 // Without this hack, we need to use visitor.trace() for |
26 // trace(InlinedGlobalMarkingVisitor) and visitor->trace() for | 27 // trace(InlinedGlobalMarkingVisitor) and visitor->trace() for |
27 // trace(Visitor*). | 28 // trace(Visitor*). |
28 InlinedGlobalMarkingVisitor* operator->() { return this; } | 29 InlinedGlobalMarkingVisitor* operator->() { return this; } |
29 | 30 |
30 using Impl::mark; | 31 using Impl::mark; |
31 using Impl::ensureMarked; | 32 using Impl::ensureMarked; |
32 using Impl::registerDelayedMarkNoTracing; | 33 using Impl::registerDelayedMarkNoTracing; |
(...skipping 14 matching lines...) Expand all Loading... |
47 } | 48 } |
48 | 49 |
49 protected: | 50 protected: |
50 // Methods to be called from MarkingVisitorImpl. | 51 // Methods to be called from MarkingVisitorImpl. |
51 | 52 |
52 inline bool shouldMarkObject(const void*) const { | 53 inline bool shouldMarkObject(const void*) const { |
53 // As this is global marking visitor, we need to mark all objects. | 54 // As this is global marking visitor, we need to mark all objects. |
54 return true; | 55 return true; |
55 } | 56 } |
56 | 57 |
57 inline Visitor::MarkingMode getMarkingMode() const { | 58 inline Visitor::MarkingMode getMarkingMode() const { return m_markingMode; } |
58 return Visitor::GlobalMarking; | |
59 } | |
60 | 59 |
61 private: | 60 private: |
62 static InlinedGlobalMarkingVisitor fromHelper(Helper* helper) { | 61 static InlinedGlobalMarkingVisitor fromHelper(Helper* helper) { |
63 return *static_cast<InlinedGlobalMarkingVisitor*>(helper); | 62 return *static_cast<InlinedGlobalMarkingVisitor*>(helper); |
64 } | 63 } |
| 64 |
| 65 // TODO(sof): attempt to unify this field with Visitor::m_markingMode. |
| 66 const Visitor::MarkingMode m_markingMode; |
65 }; | 67 }; |
66 | 68 |
67 inline void GarbageCollectedMixin::trace(InlinedGlobalMarkingVisitor) {} | 69 inline void GarbageCollectedMixin::trace(InlinedGlobalMarkingVisitor) {} |
68 | 70 |
69 } // namespace blink | 71 } // namespace blink |
70 | 72 |
71 #endif | 73 #endif |
OLD | NEW |