| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 // ########################################################################### | 87 // ########################################################################### |
| 88 // TODO(hlopko): Get rid of virtual calls using CRTP | 88 // TODO(hlopko): Get rid of virtual calls using CRTP |
| 89 class PLATFORM_EXPORT WrapperVisitor { | 89 class PLATFORM_EXPORT WrapperVisitor { |
| 90 USING_FAST_MALLOC(WrapperVisitor); | 90 USING_FAST_MALLOC(WrapperVisitor); |
| 91 | 91 |
| 92 public: | 92 public: |
| 93 template <typename T> | 93 template <typename T> |
| 94 void traceWrappers(const T* traceable) const { | 94 void traceWrappers(const T* traceable) const { |
| 95 static_assert(sizeof(T), "T must be fully defined"); | 95 static_assert(sizeof(T), "T must be fully defined"); |
| 96 // Ideally, we'd assert that we can cast to TraceWrapperBase here. | 96 static_assert(CanTraceWrappers<T>::value, |
| 97 static_assert( | 97 "T should be able to trace wrappers. See " |
| 98 IsGarbageCollectedType<T>::value, | 98 "dispatchTraceWrappers in WrapperVisitor.h"); |
| 99 "Only garbage collected objects can be used in traceWrappers()."); | |
| 100 | 99 |
| 101 if (!traceable) { | 100 if (!traceable) { |
| 102 return; | 101 return; |
| 103 } | 102 } |
| 104 | 103 |
| 105 if (TraceTrait<T>::heapObjectHeader(traceable)->isWrapperHeaderMarked()) { | 104 if (TraceTrait<T>::heapObjectHeader(traceable)->isWrapperHeaderMarked()) { |
| 106 return; | 105 return; |
| 107 } | 106 } |
| 108 | 107 |
| 109 pushToMarkingDeque(TraceTrait<T>::markWrapper, | 108 TraceTrait<T>::markWrapperNoTracing(this, traceable); |
| 109 pushToMarkingDeque(TraceTrait<T>::traceMarkedWrapper, |
| 110 TraceTrait<T>::heapObjectHeader, traceable); | 110 TraceTrait<T>::heapObjectHeader, traceable); |
| 111 } | 111 } |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * Trace all wrappers of |t|. | 114 * Trace all wrappers of |t|. |
| 115 * | 115 * |
| 116 * If you cannot use TraceWrapperMember & the corresponding traceWrappers() | 116 * If you cannot use TraceWrapperMember & the corresponding traceWrappers() |
| 117 * for some reason (e.g., due to sizeof(TraceWrapperMember)), you can use | 117 * for some reason (e.g., due to sizeof(TraceWrapperMember)), you can use |
| 118 * Member and |traceWrappersWithManualWriteBarrier()|. See below. | 118 * Member and |traceWrappersWithManualWriteBarrier()|. See below. |
| 119 */ | 119 */ |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 static const bool value = true; \ | 184 static const bool value = true; \ |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 WRAPPER_VISITOR_SPECIAL_CLASSES(SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT) | 187 WRAPPER_VISITOR_SPECIAL_CLASSES(SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT) |
| 188 | 188 |
| 189 #undef SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT | 189 #undef SPECIALIZE_WRAPPER_TRACING_MARK_TRAIT |
| 190 | 190 |
| 191 } // namespace blink | 191 } // namespace blink |
| 192 | 192 |
| 193 #endif // WrapperVisitor_h | 193 #endif // WrapperVisitor_h |
| OLD | NEW |