| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 WrapperVisitor_h | 5 #ifndef WrapperVisitor_h |
| 6 #define WrapperVisitor_h | 6 #define WrapperVisitor_h |
| 7 | 7 |
| 8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 class Value; | 12 class Value; |
| 13 template <class T> | 13 template <class T> |
| 14 class PersistentBase; | 14 class PersistentBase; |
| 15 } | 15 } |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 template <typename T> | 19 template <typename T> |
| 20 class TraceTrait; | 20 class TraceTrait; |
| 21 template <typename T> | 21 template <typename T> |
| 22 class Member; | 22 class Member; |
| 23 class ScriptWrappable; | 23 class ScriptWrappable; |
| 24 template <typename T> | 24 template <typename T> |
| 25 class TraceWrapperV8Reference; | 25 class TraceWrapperV8Reference; |
| 26 class TraceWrapperBase; | 26 class TraceWrapperBase; |
| 27 template <typename T> | 27 template <typename T> |
| 28 class TraceWrapperMember; | 28 class TraceWrapperMember; |
| 29 | 29 |
| 30 // Only add a special class here if the class cannot derive from | |
| 31 // TraceWrapperBase. | |
| 32 #define WRAPPER_VISITOR_SPECIAL_CLASSES(V) \ | |
| 33 V(ElementRareData) \ | |
| 34 V(NodeListsNodeData) \ | |
| 35 V(NodeMutationObserverData) \ | |
| 36 V(NodeRareData) | |
| 37 | |
| 38 #define FORWARD_DECLARE_SPECIAL_CLASSES(className) class className; | |
| 39 | |
| 40 WRAPPER_VISITOR_SPECIAL_CLASSES(FORWARD_DECLARE_SPECIAL_CLASSES); | |
| 41 | |
| 42 #undef FORWARD_DECLARE_SPECIAL_CLASSES | |
| 43 | |
| 44 /** | 30 /** |
| 45 * Declares non-virtual traceWrappers method. Should be used on | 31 * Declares non-virtual traceWrappers method. Should be used on |
| 46 * non-ScriptWrappable classes which should participate in wrapper tracing (e.g. | 32 * non-ScriptWrappable classes which should participate in wrapper tracing (e.g. |
| 47 * NodeRareData): | 33 * NodeRareData): |
| 48 * | 34 * |
| 49 * class NodeRareData { | 35 * class NodeRareData { |
| 50 * public: | 36 * public: |
| 51 * DECLARE_TRACE_WRAPPERS(); | 37 * DECLARE_TRACE_WRAPPERS(); |
| 52 * } | 38 * } |
| 53 */ | 39 */ |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 template <typename T> | 129 template <typename T> |
| 144 void traceWrappersWithManualWriteBarrier(const T* traceable) const { | 130 void traceWrappersWithManualWriteBarrier(const T* traceable) const { |
| 145 traceWrappers(traceable); | 131 traceWrappers(traceable); |
| 146 } | 132 } |
| 147 | 133 |
| 148 virtual void traceWrappers( | 134 virtual void traceWrappers( |
| 149 const TraceWrapperV8Reference<v8::Value>&) const = 0; | 135 const TraceWrapperV8Reference<v8::Value>&) const = 0; |
| 150 virtual void markWrapper(const v8::PersistentBase<v8::Value>*) const = 0; | 136 virtual void markWrapper(const v8::PersistentBase<v8::Value>*) const = 0; |
| 151 | 137 |
| 152 virtual void dispatchTraceWrappers(const TraceWrapperBase*) const = 0; | 138 virtual void dispatchTraceWrappers(const TraceWrapperBase*) const = 0; |
| 153 #define DECLARE_DISPATCH_TRACE_WRAPPERS(ClassName) \ | |
| 154 virtual void dispatchTraceWrappers(const ClassName*) const = 0; | |
| 155 | |
| 156 WRAPPER_VISITOR_SPECIAL_CLASSES(DECLARE_DISPATCH_TRACE_WRAPPERS); | |
| 157 | |
| 158 #undef DECLARE_DISPATCH_TRACE_WRAPPERS | |
| 159 | 139 |
| 160 virtual bool markWrapperHeader(HeapObjectHeader*) const = 0; | 140 virtual bool markWrapperHeader(HeapObjectHeader*) const = 0; |
| 161 | 141 |
| 162 virtual void markWrappersInAllWorlds(const ScriptWrappable*) const = 0; | 142 virtual void markWrappersInAllWorlds(const ScriptWrappable*) const = 0; |
| 163 | 143 |
| 164 void markWrappersInAllWorlds(const void*) const { | |
| 165 // Empty handler used for WRAPPER_VISITOR_SPECIAL_CLASSES. These types | |
| 166 // don't require marking wrappers in all worlds, so just nop on those. | |
| 167 } | |
| 168 | |
| 169 template <typename T> | 144 template <typename T> |
| 170 ALWAYS_INLINE void markAndPushToMarkingDeque(const T* traceable) const { | 145 ALWAYS_INLINE void markAndPushToMarkingDeque(const T* traceable) const { |
| 171 if (pushToMarkingDeque(TraceTrait<T>::traceMarkedWrapper, | 146 if (pushToMarkingDeque(TraceTrait<T>::traceMarkedWrapper, |
| 172 TraceTrait<T>::heapObjectHeader, | 147 TraceTrait<T>::heapObjectHeader, |
| 173 WrapperVisitor::missedWriteBarrier<T>, traceable)) { | 148 WrapperVisitor::missedWriteBarrier<T>, traceable)) { |
| 174 TraceTrait<T>::markWrapperNoTracing(this, traceable); | 149 TraceTrait<T>::markWrapperNoTracing(this, traceable); |
| 175 } | 150 } |
| 176 } | 151 } |
| 177 | 152 |
| 178 protected: | 153 protected: |
| 179 // Returns true if pushing to the marking deque was successful. | 154 // Returns true if pushing to the marking deque was successful. |
| 180 virtual bool pushToMarkingDeque( | 155 virtual bool pushToMarkingDeque( |
| 181 void (*traceWrappersCallback)(const WrapperVisitor*, const void*), | 156 void (*traceWrappersCallback)(const WrapperVisitor*, const void*), |
| 182 HeapObjectHeader* (*heapObjectHeaderCallback)(const void*), | 157 HeapObjectHeader* (*heapObjectHeaderCallback)(const void*), |
| 183 void (*missedWriteBarrierCallback)(void), | 158 void (*missedWriteBarrierCallback)(void), |
| 184 const void*) const = 0; | 159 const void*) const = 0; |
| 185 }; | 160 }; |
| 186 | 161 |
| 187 #define SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT(ClassName) \ | |
| 188 template <> \ | |
| 189 class CanTraceWrappers<ClassName, false> { \ | |
| 190 public: \ | |
| 191 static const bool value = true; \ | |
| 192 }; | |
| 193 | |
| 194 WRAPPER_VISITOR_SPECIAL_CLASSES(SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT) | |
| 195 | |
| 196 #undef SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT | |
| 197 | |
| 198 } // namespace blink | 162 } // namespace blink |
| 199 | 163 |
| 200 #endif // WrapperVisitor_h | 164 #endif // WrapperVisitor_h |
| OLD | NEW |