Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: third_party/WebKit/Source/platform/heap/WrapperVisitor.h

Issue 2474693002: [wrapper-tracing] Support for incrementally tracing ScopedPersistent (Closed)
Patch Set: Added tests Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 class Object; 13 class Object;
14 template <class T> 14 template <class T>
15 class PersistentBase; 15 class PersistentBase;
16 } 16 }
17 17
18 namespace blink { 18 namespace blink {
19 19
20 template <typename T> 20 template <typename T>
21 class TraceTrait; 21 class TraceTrait;
22 template <typename T> 22 template <typename T>
23 class Member; 23 class Member;
24 class ScriptWrappable; 24 class ScriptWrappable;
25 template <typename T> 25 template <typename T>
26 class ScopedPersistent; 26 class TraceWrapperV8Reference;
27 class TraceWrapperBase; 27 class TraceWrapperBase;
28 template <typename T> 28 template <typename T>
29 class TraceWrapperMember; 29 class TraceWrapperMember;
30 30
31 // Only add a special class here if the class cannot derive from 31 // Only add a special class here if the class cannot derive from
32 // TraceWrapperBase. 32 // TraceWrapperBase.
33 #define WRAPPER_VISITOR_SPECIAL_CLASSES(V) \ 33 #define WRAPPER_VISITOR_SPECIAL_CLASSES(V) \
34 V(ElementRareData) \ 34 V(ElementRareData) \
35 V(NodeListsNodeData) \ 35 V(NodeListsNodeData) \
36 V(NodeMutationObserverData) \ 36 V(NodeMutationObserverData) \
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 #define DEFINE_INLINE_TRACE_WRAPPERS() DECLARE_TRACE_WRAPPERS() 85 #define DEFINE_INLINE_TRACE_WRAPPERS() DECLARE_TRACE_WRAPPERS()
86 #define DEFINE_INLINE_VIRTUAL_TRACE_WRAPPERS() DECLARE_VIRTUAL_TRACE_WRAPPERS() 86 #define DEFINE_INLINE_VIRTUAL_TRACE_WRAPPERS() DECLARE_VIRTUAL_TRACE_WRAPPERS()
87 87
88 // ########################################################################### 88 // ###########################################################################
89 // TODO(hlopko): Get rid of virtual calls using CRTP 89 // TODO(hlopko): Get rid of virtual calls using CRTP
90 class PLATFORM_EXPORT WrapperVisitor { 90 class PLATFORM_EXPORT WrapperVisitor {
91 USING_FAST_MALLOC(WrapperVisitor); 91 USING_FAST_MALLOC(WrapperVisitor);
92 92
93 public: 93 public:
94 template <typename T> 94 template <typename T>
95 void traceWrappers(const T* traceable) const { 95 void traceWrappers(const T* traceable) const {
haraken 2016/11/03 14:25:04 Would you help me understand who uses this method?
Michael Lippautz 2016/11/03 14:53:41 Yes, one has to be careful with traceWrappers over
96 static_assert(sizeof(T), "T must be fully defined"); 96 static_assert(sizeof(T), "T must be fully defined");
97 // Ideally, we'd assert that we can cast to TraceWrapperBase here.
98 static_assert(IsGarbageCollectedType<T>::value,
99 "only garbage collected objects can be");
haraken 2016/11/03 14:25:04 Only garbage collected objects can be used in trac
Michael Lippautz 2016/11/03 14:53:41 Done.
97 100
98 if (!traceable) { 101 if (!traceable) {
99 return; 102 return;
100 } 103 }
101 104
102 if (TraceTrait<T>::heapObjectHeader(traceable)->isWrapperHeaderMarked()) { 105 if (TraceTrait<T>::heapObjectHeader(traceable)->isWrapperHeaderMarked()) {
103 return; 106 return;
104 } 107 }
105 108
106 pushToMarkingDeque(TraceTrait<T>::markWrapper, 109 pushToMarkingDeque(TraceTrait<T>::markWrapper,
(...skipping 22 matching lines...) Expand all
129 template <typename T> 132 template <typename T>
130 void traceWrappersWithManualWriteBarrier(const Member<T>& t) const { 133 void traceWrappersWithManualWriteBarrier(const Member<T>& t) const {
131 traceWrappers(t.get()); 134 traceWrappers(t.get());
132 } 135 }
133 template <typename T> 136 template <typename T>
134 void traceWrappersWithManualWriteBarrier(const WeakMember<T>& t) const { 137 void traceWrappersWithManualWriteBarrier(const WeakMember<T>& t) const {
135 traceWrappers(t.get()); 138 traceWrappers(t.get());
136 } 139 }
137 140
138 virtual void traceWrappers( 141 virtual void traceWrappers(
139 const ScopedPersistent<v8::Value>* persistent) const = 0; 142 const TraceWrapperV8Reference<v8::Value>*) const = 0;
haraken 2016/11/03 14:25:04 It's inconsistent that traceWrappers(const TraceWr
Michael Lippautz 2016/11/03 14:53:41 Done.
140 virtual void traceWrappers( 143 virtual void markWrapper(const v8::PersistentBase<v8::Value>*) const = 0;
141 const ScopedPersistent<v8::Object>* persistent) const = 0;
142 virtual void markWrapper(
143 const v8::PersistentBase<v8::Object>* persistent) const = 0;
144 144
145 virtual void dispatchTraceWrappers(const TraceWrapperBase*) const = 0; 145 virtual void dispatchTraceWrappers(const TraceWrapperBase*) const = 0;
146 #define DECLARE_DISPATCH_TRACE_WRAPPERS(ClassName) \ 146 #define DECLARE_DISPATCH_TRACE_WRAPPERS(ClassName) \
147 virtual void dispatchTraceWrappers(const ClassName*) const = 0; 147 virtual void dispatchTraceWrappers(const ClassName*) const = 0;
148 148
149 WRAPPER_VISITOR_SPECIAL_CLASSES(DECLARE_DISPATCH_TRACE_WRAPPERS); 149 WRAPPER_VISITOR_SPECIAL_CLASSES(DECLARE_DISPATCH_TRACE_WRAPPERS);
150 150
151 #undef DECLARE_DISPATCH_TRACE_WRAPPERS 151 #undef DECLARE_DISPATCH_TRACE_WRAPPERS
152 virtual void dispatchTraceWrappers(const void*) const = 0; 152 virtual void dispatchTraceWrappers(const void*) const = 0;
153 153
154 virtual bool markWrapperHeader(HeapObjectHeader*) const = 0; 154 virtual bool markWrapperHeader(HeapObjectHeader*) const = 0;
155 virtual void markWrappersInAllWorlds(const ScriptWrappable*) const = 0; 155 virtual void markWrappersInAllWorlds(const ScriptWrappable*) const = 0;
156 virtual void markWrappersInAllWorlds(const void*) const = 0; 156 virtual void markWrappersInAllWorlds(const void*) const = 0;
157 virtual void pushToMarkingDeque( 157 virtual void pushToMarkingDeque(
158 void (*traceWrappersCallback)(const WrapperVisitor*, const void*), 158 void (*traceWrappersCallback)(const WrapperVisitor*, const void*),
159 HeapObjectHeader* (*heapObjectHeaderCallback)(const void*), 159 HeapObjectHeader* (*heapObjectHeaderCallback)(const void*),
160 const void*) const = 0; 160 const void*) const = 0;
161 }; 161 };
162 162
163 } // namespace blink 163 } // namespace blink
164 164
165 #endif // WrapperVisitor_h 165 #endif // WrapperVisitor_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698