Chromium Code Reviews| 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 const Visitor::MarkingMode m_markingMode; | |
|
haraken
2016/12/02 12:43:20
Would you help me understand why you need to add t
sof
2016/12/04 14:55:38
InlinedGlobalMarkingVisitor isn't a Visitor, and t
haraken
2016/12/09 07:25:54
Maybe can we move m_markingMode to VisitorHelper?
sof
2016/12/09 21:44:03
Possibly, but it's a more complex than that given
| |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 inline void GarbageCollectedMixin::trace(InlinedGlobalMarkingVisitor) {} | 68 inline void GarbageCollectedMixin::trace(InlinedGlobalMarkingVisitor) {} |
| 68 | 69 |
| 69 } // namespace blink | 70 } // namespace blink |
| 70 | 71 |
| 71 #endif | 72 #endif |
| OLD | NEW |