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