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

Side by Side Diff: Source/platform/heap/Visitor.h

Issue 799453003: Oilpan: fix Windows build after r187674. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add needsTracing argument to TraceCompatibilityAdaptor<> Created 5 years, 12 months 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 | « Source/platform/heap/InlinedGlobalMarkingVisitor.h ('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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 namespace blink { 56 namespace blink {
57 57
58 template<typename T> class GarbageCollected; 58 template<typename T> class GarbageCollected;
59 template<typename T> class GarbageCollectedFinalized; 59 template<typename T> class GarbageCollectedFinalized;
60 class GarbageCollectedMixin; 60 class GarbageCollectedMixin;
61 class GeneralHeapObjectHeader; 61 class GeneralHeapObjectHeader;
62 class HeapObjectHeader; 62 class HeapObjectHeader;
63 class InlinedGlobalMarkingVisitor; 63 class InlinedGlobalMarkingVisitor;
64 template<typename T> class Member; 64 template<typename T> class Member;
65 template<typename T> class WeakMember; 65 template<typename T> class WeakMember;
66 template<typename ValueArg, size_t inlineCapacity> struct HeapListHashSetAllocat or;
66 class Visitor; 67 class Visitor;
67 68
69 } // namespace blink
70
71 namespace WTF {
72
73 template<typename ValueArg, typename Allocator> class ListHashSetNode;
74
75 template<typename T>
76 struct NeedsTracing<blink::Member<T>> {
77 static const bool value = true;
78 };
79
80 template<typename T>
81 struct IsWeak<blink::WeakMember<T>> {
82 static const bool value = true;
83 };
84
85 template<typename T, size_t inlineCapacity>
86 struct NeedsTracing<ListHashSetNode<T, blink::HeapListHashSetAllocator<T, inline Capacity>> *> {
87 // All heap allocated node pointers need visiting to keep the nodes alive,
88 // regardless of whether they contain pointers to other heap allocated
89 // objects.
90 static const bool value = true;
91 };
92
93 } // namespace WTF
94
95 namespace blink {
96
68 template <typename T> struct IsGarbageCollectedType; 97 template <typename T> struct IsGarbageCollectedType;
69 #define STATIC_ASSERT_IS_GARBAGE_COLLECTED(T, ErrorMessage) \ 98 #define STATIC_ASSERT_IS_GARBAGE_COLLECTED(T, ErrorMessage) \
70 static_assert(IsGarbageCollectedType<T>::value, ErrorMessage) 99 static_assert(IsGarbageCollectedType<T>::value, ErrorMessage)
71 #define STATIC_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, ErrorMessage) \ 100 #define STATIC_ASSERT_IS_NOT_GARBAGE_COLLECTED(T, ErrorMessage) \
72 static_assert(!IsGarbageCollectedType<T>::value, ErrorMessage) 101 static_assert(!IsGarbageCollectedType<T>::value, ErrorMessage)
73 102
74 template<bool needsTracing, WTF::WeakHandlingFlag weakHandlingFlag, WTF::ShouldW eakPointersBeMarkedStrongly strongify, typename T, typename Traits> struct Colle ctionBackingTraceTrait; 103 template<bool needsTracing, WTF::WeakHandlingFlag weakHandlingFlag, WTF::ShouldW eakPointersBeMarkedStrongly strongify, typename T, typename Traits> struct Colle ctionBackingTraceTrait;
75 104
76 // The TraceMethodDelegate is used to convert a trace method for type T to a Tra ceCallback. 105 // The TraceMethodDelegate is used to convert a trace method for type T to a Tra ceCallback.
77 // This allows us to pass a type's trace method as a parameter to the Persistent Node 106 // This allows us to pass a type's trace method as a parameter to the Persistent Node
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 public: 202 public:
174 static const bool value = false; 203 static const bool value = false;
175 }; 204 };
176 205
177 template <typename T> 206 template <typename T>
178 struct HasInlinedTraceMethod<T, typename T::HasInlinedTraceMethod> { 207 struct HasInlinedTraceMethod<T, typename T::HasInlinedTraceMethod> {
179 public: 208 public:
180 static const bool value = true; 209 static const bool value = true;
181 }; 210 };
182 211
183 template <typename T, bool = HasInlinedTraceMethod<T>::value> 212 template <typename T, bool needsTracing, bool = HasInlinedTraceMethod<T>::value>
184 struct TraceCompatibilityAdaptor; 213 struct TraceCompatibilityAdaptor;
185 214
186 // The TraceTrait is used to specify how to mark an object pointer and 215 // The TraceTrait is used to specify how to mark an object pointer and
187 // how to trace all of the pointers in the object. 216 // how to trace all of the pointers in the object.
188 // 217 //
189 // By default, the 'trace' method implemented on an object itself is 218 // By default, the 'trace' method implemented on an object itself is
190 // used to trace the pointers to other heap objects inside the object. 219 // used to trace the pointers to other heap objects inside the object.
191 // 220 //
192 // However, the TraceTrait can be specialized to use a different 221 // However, the TraceTrait can be specialized to use a different
193 // implementation. A common case where a TraceTrait specialization is 222 // implementation. A common case where a TraceTrait specialization is
194 // needed is when multiple inheritance leads to pointers that are not 223 // needed is when multiple inheritance leads to pointers that are not
195 // to the start of the object in the Blink garbage-collected heap. In 224 // to the start of the object in the Blink garbage-collected heap. In
196 // that case the pointer has to be adjusted before marking. 225 // that case the pointer has to be adjusted before marking.
197 template<typename T> 226 template<typename T>
198 class TraceTrait { 227 class TraceTrait {
228 static const bool needsTracing = WTF::NeedsTracing<T>::value || WTF::IsWeak< T>::value;
199 public: 229 public:
200 // Default implementation of TraceTrait<T>::trace just statically 230 // Default implementation of TraceTrait<T>::trace just statically
201 // dispatches to the trace method of the class T. 231 // dispatches to the trace method of the class T.
202 template<typename VisitorDispatcher> 232 template<typename VisitorDispatcher>
203 static void trace(VisitorDispatcher visitor, void* self) 233 static void trace(VisitorDispatcher visitor, void* self)
204 { 234 {
205 TraceCompatibilityAdaptor<T>::trace(visitor, static_cast<T*>(self)); 235 TraceCompatibilityAdaptor<T, needsTracing>::trace(visitor, static_cast<T *>(self));
206 } 236 }
207 237
208 template<typename VisitorDispatcher> 238 template<typename VisitorDispatcher>
209 static void mark(VisitorDispatcher visitor, const T* t) 239 static void mark(VisitorDispatcher visitor, const T* t)
210 { 240 {
211 DefaultTraceTrait<T>::mark(visitor, t); 241 DefaultTraceTrait<T>::mark(visitor, t);
212 } 242 }
213 243
214 #if ENABLE(ASSERT) 244 #if ENABLE(ASSERT)
215 static void checkGCInfo(const T* t) 245 static void checkGCInfo(const T* t)
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 struct GCInfoTrait { 921 struct GCInfoTrait {
892 static const GCInfo* get() 922 static const GCInfo* get()
893 { 923 {
894 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); 924 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get();
895 } 925 }
896 }; 926 };
897 927
898 } 928 }
899 929
900 #endif 930 #endif
OLDNEW
« no previous file with comments | « Source/platform/heap/InlinedGlobalMarkingVisitor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698