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 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 "dispatchTraceWrappers in WrapperVisitor.h"); | 98 "dispatchTraceWrappers in WrapperVisitor.h"); |
99 | 99 |
100 if (!traceable) { | 100 if (!traceable) { |
101 return; | 101 return; |
102 } | 102 } |
103 | 103 |
104 if (TraceTrait<T>::heapObjectHeader(traceable)->isWrapperHeaderMarked()) { | 104 if (TraceTrait<T>::heapObjectHeader(traceable)->isWrapperHeaderMarked()) { |
105 return; | 105 return; |
106 } | 106 } |
107 | 107 |
108 if (pushToMarkingDeque(TraceTrait<T>::traceMarkedWrapper, | 108 markAndPushToMarkingDeque(traceable); |
109 TraceTrait<T>::heapObjectHeader, traceable)) { | |
110 TraceTrait<T>::markWrapperNoTracing(this, traceable); | |
111 } | |
112 } | 109 } |
113 | 110 |
114 /** | 111 /** |
115 * Trace all wrappers of |t|. | 112 * Trace all wrappers of |t|. |
116 * | 113 * |
117 * If you cannot use TraceWrapperMember & the corresponding traceWrappers() | 114 * If you cannot use TraceWrapperMember & the corresponding traceWrappers() |
118 * for some reason (e.g., due to sizeof(TraceWrapperMember)), you can use | 115 * for some reason (e.g., due to sizeof(TraceWrapperMember)), you can use |
119 * Member and |traceWrappersWithManualWriteBarrier()|. See below. | 116 * Member and |traceWrappersWithManualWriteBarrier()|. See below. |
120 */ | 117 */ |
121 template <typename T> | 118 template <typename T> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 154 |
158 virtual bool markWrapperHeader(HeapObjectHeader*) const = 0; | 155 virtual bool markWrapperHeader(HeapObjectHeader*) const = 0; |
159 | 156 |
160 virtual void markWrappersInAllWorlds(const ScriptWrappable*) const = 0; | 157 virtual void markWrappersInAllWorlds(const ScriptWrappable*) const = 0; |
161 | 158 |
162 void markWrappersInAllWorlds(const void*) const { | 159 void markWrappersInAllWorlds(const void*) const { |
163 // Empty handler used for WRAPPER_VISITOR_SPECIAL_CLASSES. These types | 160 // Empty handler used for WRAPPER_VISITOR_SPECIAL_CLASSES. These types |
164 // don't require marking wrappers in all worlds, so just nop on those. | 161 // don't require marking wrappers in all worlds, so just nop on those. |
165 } | 162 } |
166 | 163 |
| 164 template <typename T> |
| 165 void markAndPushToMarkingDeque(const T* traceable) const { |
| 166 if (pushToMarkingDeque(TraceTrait<T>::traceMarkedWrapper, |
| 167 TraceTrait<T>::heapObjectHeader, traceable)) { |
| 168 TraceTrait<T>::markWrapperNoTracing(this, traceable); |
| 169 } |
| 170 } |
| 171 |
| 172 protected: |
167 // Returns true if pushing to the marking deque was successful. | 173 // Returns true if pushing to the marking deque was successful. |
168 virtual bool pushToMarkingDeque( | 174 virtual bool pushToMarkingDeque( |
169 void (*traceWrappersCallback)(const WrapperVisitor*, const void*), | 175 void (*traceWrappersCallback)(const WrapperVisitor*, const void*), |
170 HeapObjectHeader* (*heapObjectHeaderCallback)(const void*), | 176 HeapObjectHeader* (*heapObjectHeaderCallback)(const void*), |
171 const void*) const = 0; | 177 const void*) const = 0; |
172 }; | 178 }; |
173 | 179 |
174 #define SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT(ClassName) \ | 180 #define SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT(ClassName) \ |
175 template <> \ | 181 template <> \ |
176 class CanTraceWrappers<ClassName, false> { \ | 182 class CanTraceWrappers<ClassName, false> { \ |
177 public: \ | 183 public: \ |
178 static const bool value = true; \ | 184 static const bool value = true; \ |
179 }; | 185 }; |
180 | 186 |
181 WRAPPER_VISITOR_SPECIAL_CLASSES(SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT) | 187 WRAPPER_VISITOR_SPECIAL_CLASSES(SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT) |
182 | 188 |
183 #undef SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT | 189 #undef SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT |
184 | 190 |
185 } // namespace blink | 191 } // namespace blink |
186 | 192 |
187 #endif // WrapperVisitor_h | 193 #endif // WrapperVisitor_h |
OLD | NEW |