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

Side by Side Diff: Source/platform/Supplementable.h

Issue 403333002: [oilpan]: Remove support for tracing off-heap hashmaps. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return this->m_supplements.get(key); 181 return this->m_supplements.get(key);
182 } 182 }
183 183
184 void reattachThread() 184 void reattachThread()
185 { 185 {
186 #if ENABLE(ASSERT) 186 #if ENABLE(ASSERT)
187 m_threadId = currentThread(); 187 m_threadId = currentThread();
188 #endif 188 #endif
189 } 189 }
190 190
191 virtual void trace(Visitor* visitor) { visitor->trace(m_supplements); }
192
193 void willBeDestroyed() 191 void willBeDestroyed()
194 { 192 {
195 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement Map::iterator SupplementIterator; 193 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement Map::iterator SupplementIterator;
196 for (SupplementIterator it = m_supplements.begin(); it != m_supplements. end(); ++it) 194 for (SupplementIterator it = m_supplements.begin(); it != m_supplements. end(); ++it)
197 it->value->willBeDestroyed(); 195 it->value->willBeDestroyed();
198 } 196 }
199 197
200 // FIXME: Oilpan: Make private and remove this ignore once PersistentHeapSup plementable is removed again. 198 // FIXME: Oilpan: Make private and remove this ignore once PersistentHeapSup plementable is removed again.
201 protected: 199 protected:
202 GC_PLUGIN_IGNORE("") 200 GC_PLUGIN_IGNORE("")
203 typename SupplementableTraits<T, isGarbageCollected>::SupplementMap m_supple ments; 201 typename SupplementableTraits<T, isGarbageCollected>::SupplementMap m_supple ments;
204 202
205 #if ENABLE(ASSERT) 203 #if ENABLE(ASSERT)
206 protected: 204 protected:
207 SupplementableBase() : m_threadId(currentThread()) { } 205 SupplementableBase() : m_threadId(currentThread()) { }
208 206
209 private: 207 private:
210 ThreadIdentifier m_threadId; 208 ThreadIdentifier m_threadId;
211 #endif 209 #endif
212 }; 210 };
213 211
214 template<typename T> 212 template<typename T>
215 class HeapSupplement : public SupplementBase<T, true> { }; 213 class HeapSupplement : public SupplementBase<T, true> { };
216 214
217 // FIXME: Oilpan: Move GarbageCollectedMixin to SupplementableBase<T, true> once PersistentHeapSupplementable is removed again. 215 // FIXME: Oilpan: Move GarbageCollectedMixin to SupplementableBase<T, true> once PersistentHeapSupplementable is removed again.
218 template<typename T> 216 template<typename T>
219 class GC_PLUGIN_IGNORE("http://crbug.com/395036") HeapSupplementable : public Su pplementableBase<T, true>, public GarbageCollectedMixin { 217 class HeapSupplementable : public SupplementableBase<T, true>, public GarbageCol lectedMixin {
220 public: 218 public:
221 virtual void trace(Visitor* visitor) { SupplementableBase<T, true>::trace(vi sitor); } 219 virtual void trace(Visitor* visitor) OVERRIDE { visitor->trace(this->m_suppl ements); }
222 }; 220 };
223 221
224 template<typename T> 222 template<typename T>
225 class PersistentHeapSupplementable : public SupplementableBase<T, true> { 223 class PersistentHeapSupplementable : public SupplementableBase<T, true> {
226 public: 224 public:
227 PersistentHeapSupplementable() : m_root(this) { } 225 PersistentHeapSupplementable() : m_root(this) { }
228 virtual ~PersistentHeapSupplementable() 226 virtual ~PersistentHeapSupplementable()
229 { 227 {
230 typedef typename SupplementableTraits<T, true>::SupplementMap::iterator SupplementIterator; 228 typedef typename SupplementableTraits<T, true>::SupplementMap::iterator SupplementIterator;
231 for (SupplementIterator it = this->m_supplements.begin(); it != this->m_ supplements.end(); ++it) 229 for (SupplementIterator it = this->m_supplements.begin(); it != this->m_ supplements.end(); ++it)
232 it->value->persistentHostHasBeenDestroyed(); 230 it->value->persistentHostHasBeenDestroyed();
233 } 231 }
232
233 virtual void trace(Visitor* visitor) { visitor->trace(this->m_supplements); }
234
234 private: 235 private:
235 class TraceDelegate : PersistentBase<ThreadLocalPersistents<AnyThread>, Trac eDelegate> { 236 class TraceDelegate : PersistentBase<ThreadLocalPersistents<AnyThread>, Trac eDelegate> {
236 public: 237 public:
237 TraceDelegate(PersistentHeapSupplementable* owner) : m_owner(owner) { } 238 TraceDelegate(PersistentHeapSupplementable* owner) : m_owner(owner) { }
238 void trace(Visitor* visitor) { m_owner->trace(visitor); } 239 void trace(Visitor* visitor) { m_owner->trace(visitor); }
239 private: 240 private:
240 PersistentHeapSupplementable* m_owner; 241 PersistentHeapSupplementable* m_owner;
241 }; 242 };
242 243
243 TraceDelegate m_root; 244 TraceDelegate m_root;
244 }; 245 };
245 246
246 template<typename T> 247 template<typename T>
247 class Supplement : public SupplementBase<T, false> { }; 248 class Supplement : public SupplementBase<T, false> { };
248 249
249 template<typename T> 250 template<typename T>
250 class Supplementable : public SupplementableBase<T, false> { }; 251 class Supplementable : public SupplementableBase<T, false> {
252 public:
253 virtual void trace(Visitor*)
254 {
255 // No tracing of off-heap supplements. We should not have any Supplement able
256 // object on the heap. Either the object is HeapSupplementable or if it is
257 // off heap it should use PersistentHeapSupplementable to trace any on-h eap
258 // supplements.
259 }
260 };
251 261
252 template<typename T> 262 template<typename T>
253 struct ThreadingTrait<blink::SupplementBase<T, true> > { 263 struct ThreadingTrait<blink::SupplementBase<T, true> > {
254 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 264 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
255 }; 265 };
256 266
257 template<typename T> 267 template<typename T>
258 struct ThreadingTrait<blink::SupplementableBase<T, true> > { 268 struct ThreadingTrait<blink::SupplementableBase<T, true> > {
259 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 269 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
260 }; 270 };
261 271
262 } // namespace blink 272 } // namespace blink
263 273
264 #endif // Supplementable_h 274 #endif // Supplementable_h
OLDNEW
« no previous file with comments | « Source/modules/webdatabase/SQLTransactionCoordinator.cpp ('k') | Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698