| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 }; | 307 }; |
| 308 | 308 |
| 309 // FIXME: derive affinity based on the collection. | 309 // FIXME: derive affinity based on the collection. |
| 310 template<typename Collection, ThreadAffinity Affinity = AnyThread> | 310 template<typename Collection, ThreadAffinity Affinity = AnyThread> |
| 311 class PersistentHeapCollectionBase | 311 class PersistentHeapCollectionBase |
| 312 : public Collection | 312 : public Collection |
| 313 , public PersistentBase<ThreadLocalPersistents<Affinity>, PersistentHeapColl
ectionBase<Collection, Affinity> > { | 313 , public PersistentBase<ThreadLocalPersistents<Affinity>, PersistentHeapColl
ectionBase<Collection, Affinity> > { |
| 314 // Never allocate these objects with new. Use Persistent<Collection> instead
. | 314 // Never allocate these objects with new. Use Persistent<Collection> instead
. |
| 315 DISALLOW_ALLOCATION(); | 315 DISALLOW_ALLOCATION(); |
| 316 public: | 316 public: |
| 317 PersistentHeapCollectionBase() { } |
| 318 |
| 319 template<typename OtherCollection> |
| 320 PersistentHeapCollectionBase(const OtherCollection& other) : Collection(othe
r) { } |
| 321 |
| 317 void trace(Visitor* visitor) { visitor->trace(*static_cast<Collection*>(this
)); } | 322 void trace(Visitor* visitor) { visitor->trace(*static_cast<Collection*>(this
)); } |
| 318 }; | 323 }; |
| 319 | 324 |
| 320 template< | 325 template< |
| 321 typename KeyArg, | 326 typename KeyArg, |
| 322 typename MappedArg, | 327 typename MappedArg, |
| 323 typename HashArg = typename DefaultHash<KeyArg>::Hash, | 328 typename HashArg = typename DefaultHash<KeyArg>::Hash, |
| 324 typename KeyTraitsArg = HashTraits<KeyArg>, | 329 typename KeyTraitsArg = HashTraits<KeyArg>, |
| 325 typename MappedTraitsArg = HashTraits<MappedArg> > | 330 typename MappedTraitsArg = HashTraits<MappedArg> > |
| 326 class PersistentHeapHashMap : public PersistentHeapCollectionBase<HeapHashMap<Ke
yArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg> > { }; | 331 class PersistentHeapHashMap : public PersistentHeapCollectionBase<HeapHashMap<Ke
yArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg> > { }; |
| 327 | 332 |
| 328 template< | 333 template< |
| 329 typename ValueArg, | 334 typename ValueArg, |
| 330 typename HashArg = typename DefaultHash<ValueArg>::Hash, | 335 typename HashArg = typename DefaultHash<ValueArg>::Hash, |
| 331 typename TraitsArg = HashTraits<ValueArg> > | 336 typename TraitsArg = HashTraits<ValueArg> > |
| 332 class PersistentHeapHashSet : public PersistentHeapCollectionBase<HeapHashSet<Va
lueArg, HashArg, TraitsArg> > { }; | 337 class PersistentHeapHashSet : public PersistentHeapCollectionBase<HeapHashSet<Va
lueArg, HashArg, TraitsArg> > { }; |
| 333 | 338 |
| 334 template<typename T, size_t inlineCapacity = 0> | 339 template<typename T, size_t inlineCapacity = 0> |
| 335 class PersistentHeapVector : public PersistentHeapCollectionBase<HeapVector<T, i
nlineCapacity> > { }; | 340 class PersistentHeapVector : public PersistentHeapCollectionBase<HeapVector<T, i
nlineCapacity> > { |
| 341 public: |
| 342 PersistentHeapVector() { } |
| 343 |
| 344 template<size_t otherCapacity> |
| 345 PersistentHeapVector(const HeapVector<T, otherCapacity>& other) |
| 346 : PersistentHeapCollectionBase<HeapVector<T, inlineCapacity> >(other) |
| 347 { |
| 348 } |
| 349 }; |
| 336 | 350 |
| 337 // Members are used in classes to contain strong pointers to other oilpan heap | 351 // Members are used in classes to contain strong pointers to other oilpan heap |
| 338 // allocated objects. | 352 // allocated objects. |
| 339 // All Member fields of a class must be traced in the class' trace method. | 353 // All Member fields of a class must be traced in the class' trace method. |
| 340 // During the mark phase of the GC all live objects are marked as live and | 354 // During the mark phase of the GC all live objects are marked as live and |
| 341 // all Member fields of a live object will be traced marked as live as well. | 355 // all Member fields of a live object will be traced marked as live as well. |
| 342 template<typename T> | 356 template<typename T> |
| 343 class Member { | 357 class Member { |
| 344 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(Member); | 358 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(Member); |
| 345 WTF_DISALLOW_ZERO_ASSIGNMENT(Member); | 359 WTF_DISALLOW_ZERO_ASSIGNMENT(Member); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 }; | 766 }; |
| 753 | 767 |
| 754 template<typename T> inline T* getPtr(const WebCore::Member<T>& p) | 768 template<typename T> inline T* getPtr(const WebCore::Member<T>& p) |
| 755 { | 769 { |
| 756 return p.get(); | 770 return p.get(); |
| 757 } | 771 } |
| 758 | 772 |
| 759 } // namespace WTF | 773 } // namespace WTF |
| 760 | 774 |
| 761 #endif | 775 #endif |
| OLD | NEW |