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

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

Issue 1287963002: Fix race at blink::GCInfoAtBase<T>::index (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@oilpan_1
Patch Set: Nits. Created 5 years, 4 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 | « no previous file | Source/platform/heap/Visitor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 GCInfo_h 5 #ifndef GCInfo_h
6 #define GCInfo_h 6 #define GCInfo_h
7 7
8 #include "platform/heap/Visitor.h" 8 #include "platform/heap/Visitor.h"
9 #include "wtf/Assertions.h" 9 #include "wtf/Assertions.h"
10 #include "wtf/Atomics.h" 10 #include "wtf/Atomics.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 // GCInfo contains meta-data associated with objects allocated in the 105 // GCInfo contains meta-data associated with objects allocated in the
106 // Blink heap. This meta-data consists of a function pointer used to 106 // Blink heap. This meta-data consists of a function pointer used to
107 // trace the pointers in the object during garbage collection, an 107 // trace the pointers in the object during garbage collection, an
108 // indication of whether or not the object needs a finalization 108 // indication of whether or not the object needs a finalization
109 // callback, and a function pointer used to finalize the object when 109 // callback, and a function pointer used to finalize the object when
110 // the garbage collector determines that the object is no longer 110 // the garbage collector determines that the object is no longer
111 // reachable. There is a GCInfo struct for each class that directly 111 // reachable. There is a GCInfo struct for each class that directly
112 // inherits from GarbageCollected or GarbageCollectedFinalized. 112 // inherits from GarbageCollected or GarbageCollectedFinalized.
113 struct GCInfo { 113 struct GCInfo {
114 using GetClassNameCallback = const String& (*)();
115
114 bool hasFinalizer() const { return m_nonTrivialFinalizer; } 116 bool hasFinalizer() const { return m_nonTrivialFinalizer; }
115 bool hasVTable() const { return m_hasVTable; } 117 bool hasVTable() const { return m_hasVTable; }
116 const String& className() const { return m_className; } 118 const String& className() const { return m_classNameGetter(); }
117 TraceCallback m_trace; 119 TraceCallback m_trace;
118 FinalizationCallback m_finalize; 120 FinalizationCallback m_finalize;
119 bool m_nonTrivialFinalizer; 121 bool m_nonTrivialFinalizer;
120 bool m_hasVTable; 122 bool m_hasVTable;
121 // |m_className| is held as a reference to prevent dtor being called at exit . 123 GetClassNameCallback m_classNameGetter;
122 const String& m_className;
123 }; 124 };
124 125
125 #if ENABLE(ASSERT) 126 #if ENABLE(ASSERT)
126 PLATFORM_EXPORT void assertObjectHasGCInfo(const void*, size_t gcInfoIndex); 127 PLATFORM_EXPORT void assertObjectHasGCInfo(const void*, size_t gcInfoIndex);
127 #endif 128 #endif
128 129
129 class GCInfoTable { 130 class GCInfoTable {
130 public: 131 public:
131 PLATFORM_EXPORT static void ensureGCInfoIndex(const GCInfo*, size_t*); 132 PLATFORM_EXPORT static void ensureGCInfoIndex(const GCInfo*, size_t*);
132 133
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 template<typename T> 165 template<typename T>
165 struct GCInfoAtBase { 166 struct GCInfoAtBase {
166 static size_t index() 167 static size_t index()
167 { 168 {
168 static_assert(sizeof(T), "T must be fully defined"); 169 static_assert(sizeof(T), "T must be fully defined");
169 static const GCInfo gcInfo = { 170 static const GCInfo gcInfo = {
170 TraceTrait<T>::trace, 171 TraceTrait<T>::trace,
171 FinalizerTrait<T>::finalize, 172 FinalizerTrait<T>::finalize,
172 FinalizerTrait<T>::nonTrivialFinalizer, 173 FinalizerTrait<T>::nonTrivialFinalizer,
173 WTF::IsPolymorphic<T>::value, 174 WTF::IsPolymorphic<T>::value,
174 TypenameStringTrait<T>::get() 175 TypenameStringTrait<T>::get
175 }; 176 };
176 RETURN_GCINFO_INDEX(); 177 RETURN_GCINFO_INDEX();
177 } 178 }
178 }; 179 };
179 180
180 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst< T>::Type, GarbageCollected>::value> struct GetGarbageCollectedBase; 181 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst< T>::Type, GarbageCollected>::value> struct GetGarbageCollectedBase;
181 182
182 template<typename T> 183 template<typename T>
183 struct GetGarbageCollectedBase<T, true> { 184 struct GetGarbageCollectedBase<T, true> {
184 typedef typename T::GarbageCollectedBase type; 185 typedef typename T::GarbageCollectedBase type;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 template<typename T, size_t inlineCapacity> 219 template<typename T, size_t inlineCapacity>
219 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator>> { }; 220 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T, inlineCapacity, HeapAllocator>> { };
220 template<typename T, size_t inlineCapacity> 221 template<typename T, size_t inlineCapacity>
221 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i nlineCapacity, HeapAllocator>> { }; 222 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i nlineCapacity, HeapAllocator>> { };
222 template<typename T, typename U, typename V> 223 template<typename T, typename U, typename V>
223 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted Set<T, U, V, HeapAllocator>> { }; 224 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted Set<T, U, V, HeapAllocator>> { };
224 225
225 } // namespace blink 226 } // namespace blink
226 227
227 #endif 228 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698