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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 m_raw = other; | 256 m_raw = other; |
257 return *this; | 257 return *this; |
258 } | 258 } |
259 | 259 |
260 T* get() const { return m_raw; } | 260 T* get() const { return m_raw; } |
261 | 261 |
262 private: | 262 private: |
263 T* m_raw; | 263 T* m_raw; |
264 }; | 264 }; |
265 | 265 |
| 266 template< |
| 267 typename KeyArg, |
| 268 typename MappedArg, |
| 269 typename HashArg = typename DefaultHash<KeyArg>::Hash, |
| 270 typename KeyTraitsArg = HashTraits<KeyArg>, |
| 271 typename MappedTraitsArg = HashTraits<MappedArg> > |
| 272 class PersistentHeapHashMap : public HeapHashMap<KeyArg, MappedArg, HashArg, Key
TraitsArg, MappedTraitsArg> { |
| 273 public: |
| 274 PersistentHeapHashMap() : m_self(this) { } |
| 275 private: |
| 276 Persistent<HeapHashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTrait
sArg> > m_self; |
| 277 }; |
| 278 |
| 279 template< |
| 280 typename ValueArg, |
| 281 typename HashArg = typename DefaultHash<ValueArg>::Hash, |
| 282 typename TraitsArg = HashTraits<ValueArg> > |
| 283 class PersistentHeapHashSet : public HeapHashSet<ValueArg, HashArg, TraitsArg> { |
| 284 public: |
| 285 PersistentHeapHashSet() : m_self(this) { } |
| 286 private: |
| 287 Persistent<HeapHashSet<ValueArg, HashArg, TraitsArg> > m_self; |
| 288 }; |
| 289 |
| 290 template<typename T, size_t inlineCapacity = 0> |
| 291 class PersistentHeapVector : public HeapVector<T, inlineCapacity> { |
| 292 public: |
| 293 PersistentHeapVector() : m_self(this) { } |
| 294 private: |
| 295 Persistent<HeapVector<T, inlineCapacity> > m_self; |
| 296 }; |
| 297 |
266 // Members are used in classes to contain strong pointers to other oilpan heap | 298 // Members are used in classes to contain strong pointers to other oilpan heap |
267 // allocated objects. | 299 // allocated objects. |
268 // All Member fields of a class must be traced in the class' trace method. | 300 // All Member fields of a class must be traced in the class' trace method. |
269 // During the mark phase of the GC all live objects are marked as live and | 301 // During the mark phase of the GC all live objects are marked as live and |
270 // all Member fields of a live object will be traced marked as live as well. | 302 // all Member fields of a live object will be traced marked as live as well. |
271 template<typename T> | 303 template<typename T> |
272 class Member { | 304 class Member { |
273 public: | 305 public: |
274 Member() : m_raw(0) { } | 306 Member() : m_raw(0) { } |
275 | 307 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 template<typename T> using RefCountedWillBeRefCountedGarbageCollected = RefCount
edGarbageCollected<T>; | 516 template<typename T> using RefCountedWillBeRefCountedGarbageCollected = RefCount
edGarbageCollected<T>; |
485 template<typename T> using RefPtrWillBePersistent = Persistent<T>; | 517 template<typename T> using RefPtrWillBePersistent = Persistent<T>; |
486 template<typename T> using RefPtrWillBeRawPtr = RawPtr<T>; | 518 template<typename T> using RefPtrWillBeRawPtr = RawPtr<T>; |
487 template<typename T> using RefPtrWillBeMember = Member<T>; | 519 template<typename T> using RefPtrWillBeMember = Member<T>; |
488 template<typename T> using RawPtrWillBeMember = Member<T>; | 520 template<typename T> using RawPtrWillBeMember = Member<T>; |
489 template<typename T> using RawPtrWillBeWeakMember = WeakMember<T>; | 521 template<typename T> using RawPtrWillBeWeakMember = WeakMember<T>; |
490 template<typename T> using OwnPtrWillBeMember = Member<T>; | 522 template<typename T> using OwnPtrWillBeMember = Member<T>; |
491 template<typename T> using PassOwnPtrWillBeRawPtr = RawPtr<T>; | 523 template<typename T> using PassOwnPtrWillBeRawPtr = RawPtr<T>; |
492 template<typename T> using NoBaseWillBeGarbageCollected = GarbageCollected<T>; | 524 template<typename T> using NoBaseWillBeGarbageCollected = GarbageCollected<T>; |
493 template<typename T> using NoBaseWillBeGarbageCollectedFinalized = GarbageCollec
tedFinalized<T>; | 525 template<typename T> using NoBaseWillBeGarbageCollectedFinalized = GarbageCollec
tedFinalized<T>; |
| 526 template< |
| 527 typename K, |
| 528 typename V, |
| 529 typename H = typename DefaultHash<K>::Hash, |
| 530 typename KT = HashTraits<K>, |
| 531 typename VT = HashTraits<V> > |
| 532 using WillBeHeapHashMap = HeapHashMap<K, V, H, KT, VT>; |
| 533 template< |
| 534 typename K, |
| 535 typename V, |
| 536 typename H = typename DefaultHash<K>::Hash, |
| 537 typename KT = HashTraits<K>, |
| 538 typename VT = HashTraits<V> > |
| 539 using WillBePersistentHeapHashMap = PersistentHeapHashMap<K, V, H, KT, VT>; |
| 540 template< |
| 541 typename V, |
| 542 typename H = typename DefaultHash<V>::Hash, |
| 543 typename T = HashTraits<V> > |
| 544 using WillBeHeapHashSet = HeapHashSet<V, H, T>; |
| 545 template< |
| 546 typename V, |
| 547 typename H = typename DefaultHash<V>::Hash, |
| 548 typename T = HashTraits<V> > |
| 549 using WillBePersistentHeapHashSet = PersistentHeapHashSet<V, H, T>; |
| 550 template<typename T, size_t inlineCapacity = 0> |
| 551 using WillBeHeapVector = HeapVector<T, inlineCapacity>; |
| 552 template<typename T, size_t inlineCapacity = 0> |
| 553 using WillBePersistentHeapVector = PersistentHeapVector<T, inlineCapacity>; |
494 #else // !COMPILER(CLANG) | 554 #else // !COMPILER(CLANG) |
495 #define PassRefPtrWillBeRawPtr RawPtr | 555 #define PassRefPtrWillBeRawPtr RawPtr |
496 #define RefCountedWillBeGarbageCollected GarbageCollected | 556 #define RefCountedWillBeGarbageCollected GarbageCollected |
497 #define RefCountedWillBeGarbageCollectedFinalized GarbageCollectedFinalized | 557 #define RefCountedWillBeGarbageCollectedFinalized GarbageCollectedFinalized |
498 #define RefCountedWillBeRefCountedGarbageCollected RefCountedGarbageCollected | 558 #define RefCountedWillBeRefCountedGarbageCollected RefCountedGarbageCollected |
499 #define RefPtrWillBePersistent Persistent | 559 #define RefPtrWillBePersistent Persistent |
500 #define RefPtrWillBeRawPtr RawPtr | 560 #define RefPtrWillBeRawPtr RawPtr |
501 #define RefPtrWillBeMember Member | 561 #define RefPtrWillBeMember Member |
502 #define RawPtrWillBeMember Member | 562 #define RawPtrWillBeMember Member |
503 #define RawPtrWillBeWeakMember WeakMember | 563 #define RawPtrWillBeWeakMember WeakMember |
504 #define OwnPtrWillBeMember Member | 564 #define OwnPtrWillBeMember Member |
505 #define PassOwnPtrWillBeRawPtr RawPtr | 565 #define PassOwnPtrWillBeRawPtr RawPtr |
506 #define NoBaseWillBeGarbageCollected GarbageCollected | 566 #define NoBaseWillBeGarbageCollected GarbageCollected |
507 #define NoBaseWillBeGarbageCollectedFinalized GarbageCollectedFinalized | 567 #define NoBaseWillBeGarbageCollectedFinalized GarbageCollectedFinalized |
| 568 #define WillBeHeapHashMap HeapHashMap |
| 569 #define WillBePersistentHeapHashMap PersistentHeapHashMap |
| 570 #define WillBeHeapHashSet HeapHashSet |
| 571 #define WillBePersistentHeapHashSet PersistentHeapHashSet |
| 572 #define WillBeHeapVector HeapVector |
| 573 #define WillBePersistentHeapVector PersistentHeapVector |
508 #endif // COMPILER(CLANG) | 574 #endif // COMPILER(CLANG) |
509 | 575 |
510 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeNoop(T* ptr) { retu
rn PassRefPtrWillBeRawPtr<T>(ptr); } | 576 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeNoop(T* ptr) { retu
rn PassRefPtrWillBeRawPtr<T>(ptr); } |
511 | 577 |
512 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefCountedWillBeRefCountedGa
rbageCollected(T* ptr) | 578 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefCountedWillBeRefCountedGa
rbageCollected(T* ptr) |
513 { | 579 { |
514 return PassRefPtrWillBeRawPtr<T>(adoptRefCountedGarbageCollected(ptr)); | 580 return PassRefPtrWillBeRawPtr<T>(adoptRefCountedGarbageCollected(ptr)); |
515 } | 581 } |
516 | 582 |
517 template<typename T> PassOwnPtrWillBeRawPtr<T> adoptPtrWillBeNoop(T* ptr) { retu
rn PassOwnPtrWillBeRawPtr<T>(ptr); } | 583 template<typename T> PassOwnPtrWillBeRawPtr<T> adoptPtrWillBeNoop(T* ptr) { retu
rn PassOwnPtrWillBeRawPtr<T>(ptr); } |
(...skipping 14 matching lines...) Expand all Loading... |
532 template<typename T> using RefCountedWillBeRefCountedGarbageCollected = RefCount
ed<T>; | 598 template<typename T> using RefCountedWillBeRefCountedGarbageCollected = RefCount
ed<T>; |
533 template<typename T> using RefPtrWillBePersistent = RefPtr<T>; | 599 template<typename T> using RefPtrWillBePersistent = RefPtr<T>; |
534 template<typename T> using RefPtrWillBeRawPtr = RefPtr<T>; | 600 template<typename T> using RefPtrWillBeRawPtr = RefPtr<T>; |
535 template<typename T> using RefPtrWillBeMember = RefPtr<T>; | 601 template<typename T> using RefPtrWillBeMember = RefPtr<T>; |
536 template<typename T> using RawPtrWillBeMember = RawPtr<T>; | 602 template<typename T> using RawPtrWillBeMember = RawPtr<T>; |
537 template<typename T> using RawPtrWillBeWeakMember = RawPtr<T>; | 603 template<typename T> using RawPtrWillBeWeakMember = RawPtr<T>; |
538 template<typename T> using OwnPtrWillBeMember = OwnPtr<T>; | 604 template<typename T> using OwnPtrWillBeMember = OwnPtr<T>; |
539 template<typename T> using PassOwnPtrWillBeRawPtr = PassOwnPtr<T>; | 605 template<typename T> using PassOwnPtrWillBeRawPtr = PassOwnPtr<T>; |
540 template<typename T> using NoBaseWillBeGarbageCollected = DummyBase<T>; | 606 template<typename T> using NoBaseWillBeGarbageCollected = DummyBase<T>; |
541 template<typename T> using NoBaseWillBeGarbageCollectedFinalized = DummyBase<T>; | 607 template<typename T> using NoBaseWillBeGarbageCollectedFinalized = DummyBase<T>; |
| 608 template< |
| 609 typename K, |
| 610 typename V, |
| 611 typename H = typename DefaultHash<K>::Hash, |
| 612 typename KT = HashTraits<K>, |
| 613 typename VT = HashTraits<V> > |
| 614 using WillBeHeapHashMap = HashMap<K, V, H, KT, VT>; |
| 615 template< |
| 616 typename K, |
| 617 typename V, |
| 618 typename H = typename DefaultHash<K>::Hash, |
| 619 typename KT = HashTraits<K>, |
| 620 typename VT = HashTraits<V> > |
| 621 using WillBePersistentHeapHashMap = HashMap<K, V, H, KT, VT>; |
| 622 template< |
| 623 typename V, |
| 624 typename H = typename DefaultHash<V>::Hash, |
| 625 typename T = HashTraits<V> > |
| 626 using WillBeHeapHashSet = HashSet<V, H, T>; |
| 627 template< |
| 628 typename V, |
| 629 typename H = typename DefaultHash<V>::Hash, |
| 630 typename T = HashTraits<V> > |
| 631 using WillBePersistentHeapHashSet = HashSet<V, H, T>; |
| 632 template<typename T, size_t inlineCapacity = 0> |
| 633 using WillBeHeapVector = Vector<T, inlineCapacity>; |
| 634 template<typename T, size_t inlineCapacity = 0> |
| 635 using WillBePersistentHeapVector = Vector<T, inlineCapacity>; |
542 #else // !COMPILER(CLANG) | 636 #else // !COMPILER(CLANG) |
543 #define PassRefPtrWillBeRawPtr PassRefPtr | 637 #define PassRefPtrWillBeRawPtr PassRefPtr |
544 #define RefCountedWillBeGarbageCollected RefCounted | 638 #define RefCountedWillBeGarbageCollected RefCounted |
545 #define RefCountedWillBeGarbageCollectedFinalized RefCounted | 639 #define RefCountedWillBeGarbageCollectedFinalized RefCounted |
546 #define RefCountedWillBeRefCountedGarbageCollected RefCounted | 640 #define RefCountedWillBeRefCountedGarbageCollected RefCounted |
547 #define RefPtrWillBePersistent RefPtr | 641 #define RefPtrWillBePersistent RefPtr |
548 #define RefPtrWillBeRawPtr RefPtr | 642 #define RefPtrWillBeRawPtr RefPtr |
549 #define RefPtrWillBeMember RefPtr | 643 #define RefPtrWillBeMember RefPtr |
550 #define RawPtrWillBeMember RawPtr | 644 #define RawPtrWillBeMember RawPtr |
551 #define RawPtrWillBeWeakMember RawPtr | 645 #define RawPtrWillBeWeakMember RawPtr |
552 #define OwnPtrWillBeMember OwnPtr | 646 #define OwnPtrWillBeMember OwnPtr |
553 #define PassOwnPtrWillBeRawPtr PassOwnPtr | 647 #define PassOwnPtrWillBeRawPtr PassOwnPtr |
554 #define NoBaseWillBeGarbageCollected DummyBase | 648 #define NoBaseWillBeGarbageCollected DummyBase |
555 #define NoBaseWillBeGarbageCollectedFinalized DummyBase | 649 #define NoBaseWillBeGarbageCollectedFinalized DummyBase |
| 650 #define WillBeHeapHashMap HashMap |
| 651 #define WillBePersistentHeapHashMap HashMap |
| 652 #define WillBeHeapHashSet HashSet |
| 653 #define WillBePersistentHeapHashSet HashSet |
| 654 #define WillBeHeapVector Vector |
| 655 #define WillBePersistentHeapVector Vector |
556 #endif // COMPILER(CLANG) | 656 #endif // COMPILER(CLANG) |
557 | 657 |
558 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeNoop(T* ptr) { retu
rn adoptRef(ptr); } | 658 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeNoop(T* ptr) { retu
rn adoptRef(ptr); } |
559 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefCountedWillBeRefCountedGa
rbageCollected(T* ptr) { return adoptRef(ptr); } | 659 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefCountedWillBeRefCountedGa
rbageCollected(T* ptr) { return adoptRef(ptr); } |
560 template<typename T> PassOwnPtrWillBeRawPtr<T> adoptPtrWillBeNoop(T* ptr) { retu
rn adoptPtr(ptr); } | 660 template<typename T> PassOwnPtrWillBeRawPtr<T> adoptPtrWillBeNoop(T* ptr) { retu
rn adoptPtr(ptr); } |
561 | 661 |
562 #endif // ENABLE(OILPAN) | 662 #endif // ENABLE(OILPAN) |
563 | 663 |
564 } // namespace WebCore | 664 } // namespace WebCore |
565 | 665 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 }; | 765 }; |
666 | 766 |
667 template<typename Key, typename Value, typename Extractor, typename Traits, type
name KeyTraits> | 767 template<typename Key, typename Value, typename Extractor, typename Traits, type
name KeyTraits> |
668 struct IsWeak<WebCore::HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTr
aits> > { | 768 struct IsWeak<WebCore::HeapHashTableBacking<Key, Value, Extractor, Traits, KeyTr
aits> > { |
669 static const bool value = Traits::isWeak; | 769 static const bool value = Traits::isWeak; |
670 }; | 770 }; |
671 | 771 |
672 } // namespace WTF | 772 } // namespace WTF |
673 | 773 |
674 #endif | 774 #endif |
OLD | NEW |