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

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 bailout for tests when the flag is off 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
« no previous file with comments | « third_party/WebKit/Source/core/events/PromiseRejectionEvent.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {
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(
99 IsGarbageCollectedType<T>::value,
100 "Only garbage collected objects can be used in traceWrappers().");
97 101
98 if (!traceable) { 102 if (!traceable) {
99 return; 103 return;
100 } 104 }
101 105
102 if (TraceTrait<T>::heapObjectHeader(traceable)->isWrapperHeaderMarked()) { 106 if (TraceTrait<T>::heapObjectHeader(traceable)->isWrapperHeaderMarked()) {
103 return; 107 return;
104 } 108 }
105 109
106 pushToMarkingDeque(TraceTrait<T>::markWrapper, 110 pushToMarkingDeque(TraceTrait<T>::markWrapper,
(...skipping 22 matching lines...) Expand all
129 template <typename T> 133 template <typename T>
130 void traceWrappersWithManualWriteBarrier(const Member<T>& t) const { 134 void traceWrappersWithManualWriteBarrier(const Member<T>& t) const {
131 traceWrappers(t.get()); 135 traceWrappers(t.get());
132 } 136 }
133 template <typename T> 137 template <typename T>
134 void traceWrappersWithManualWriteBarrier(const WeakMember<T>& t) const { 138 void traceWrappersWithManualWriteBarrier(const WeakMember<T>& t) const {
135 traceWrappers(t.get()); 139 traceWrappers(t.get());
136 } 140 }
137 141
138 virtual void traceWrappers( 142 virtual void traceWrappers(
139 const ScopedPersistent<v8::Value>* persistent) const = 0; 143 const TraceWrapperV8Reference<v8::Value>&) const = 0;
140 virtual void traceWrappers( 144 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 145
145 virtual void dispatchTraceWrappers(const TraceWrapperBase*) const = 0; 146 virtual void dispatchTraceWrappers(const TraceWrapperBase*) const = 0;
146 #define DECLARE_DISPATCH_TRACE_WRAPPERS(ClassName) \ 147 #define DECLARE_DISPATCH_TRACE_WRAPPERS(ClassName) \
147 virtual void dispatchTraceWrappers(const ClassName*) const = 0; 148 virtual void dispatchTraceWrappers(const ClassName*) const = 0;
148 149
149 WRAPPER_VISITOR_SPECIAL_CLASSES(DECLARE_DISPATCH_TRACE_WRAPPERS); 150 WRAPPER_VISITOR_SPECIAL_CLASSES(DECLARE_DISPATCH_TRACE_WRAPPERS);
150 151
151 #undef DECLARE_DISPATCH_TRACE_WRAPPERS 152 #undef DECLARE_DISPATCH_TRACE_WRAPPERS
152 virtual void dispatchTraceWrappers(const void*) const = 0; 153 virtual void dispatchTraceWrappers(const void*) const = 0;
153 154
154 virtual bool markWrapperHeader(HeapObjectHeader*) const = 0; 155 virtual bool markWrapperHeader(HeapObjectHeader*) const = 0;
155 virtual void markWrappersInAllWorlds(const ScriptWrappable*) const = 0; 156 virtual void markWrappersInAllWorlds(const ScriptWrappable*) const = 0;
156 virtual void markWrappersInAllWorlds(const void*) const = 0; 157 virtual void markWrappersInAllWorlds(const void*) const = 0;
157 virtual void pushToMarkingDeque( 158 virtual void pushToMarkingDeque(
158 void (*traceWrappersCallback)(const WrapperVisitor*, const void*), 159 void (*traceWrappersCallback)(const WrapperVisitor*, const void*),
159 HeapObjectHeader* (*heapObjectHeaderCallback)(const void*), 160 HeapObjectHeader* (*heapObjectHeaderCallback)(const void*),
160 const void*) const = 0; 161 const void*) const = 0;
161 }; 162 };
162 163
163 } // namespace blink 164 } // namespace blink
164 165
165 #endif // WrapperVisitor_h 166 #endif // WrapperVisitor_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/PromiseRejectionEvent.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698