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

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

Issue 228403002: Deque: Add HeapDeque and prevent buggy use of swap and operator= (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix Ians nit Created 6 years, 8 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
« no previous file with comments | « no previous file | Source/platform/heap/Heap.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 /* 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 template<typename T> class HeapTerminatedArray; 45 template<typename T> class HeapTerminatedArray;
46 46
47 #define COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, ErrorMessage) \ 47 #define COMPILE_ASSERT_IS_GARBAGE_COLLECTED(T, ErrorMessage) \
48 do { \ 48 do { \
49 typedef typename WTF::RemoveConst<T>::Type NonConstType; \ 49 typedef typename WTF::RemoveConst<T>::Type NonConstType; \
50 typedef WTF::IsSubclassOfTemplate<NonConstType, GarbageCollected> Garbag eCollectedSubclass; \ 50 typedef WTF::IsSubclassOfTemplate<NonConstType, GarbageCollected> Garbag eCollectedSubclass; \
51 typedef WTF::IsSubclass<NonConstType, GarbageCollectedMixin> GarbageColl ectedMixinSubclass; \ 51 typedef WTF::IsSubclass<NonConstType, GarbageCollectedMixin> GarbageColl ectedMixinSubclass; \
52 typedef WTF::IsSubclassOfTemplate3<NonConstType, HeapHashSet> HeapHashSe tSubclass; \ 52 typedef WTF::IsSubclassOfTemplate3<NonConstType, HeapHashSet> HeapHashSe tSubclass; \
53 typedef WTF::IsSubclassOfTemplate5<NonConstType, HeapHashMap> HeapHashMa pSubclass; \ 53 typedef WTF::IsSubclassOfTemplate5<NonConstType, HeapHashMap> HeapHashMa pSubclass; \
54 typedef WTF::IsSubclassOfTemplateTypenameSize<NonConstType, HeapVector> HeapVectorSubclass; \ 54 typedef WTF::IsSubclassOfTemplateTypenameSize<NonConstType, HeapVector> HeapVectorSubclass; \
55 typedef WTF::IsSubclassOfTemplateTypenameSize<NonConstType, HeapDeque> H eapDequeSubclass; \
55 typedef WTF::IsSubclassOfTemplate<NonConstType, HeapTerminatedArray> Hea pTerminatedArraySubclass; \ 56 typedef WTF::IsSubclassOfTemplate<NonConstType, HeapTerminatedArray> Hea pTerminatedArraySubclass; \
56 COMPILE_ASSERT(GarbageCollectedSubclass::value || \ 57 COMPILE_ASSERT(GarbageCollectedSubclass::value || \
57 GarbageCollectedMixinSubclass::value || \ 58 GarbageCollectedMixinSubclass::value || \
58 HeapHashSetSubclass::value || \ 59 HeapHashSetSubclass::value || \
59 HeapHashMapSubclass::value || \ 60 HeapHashMapSubclass::value || \
60 HeapVectorSubclass::value || \ 61 HeapVectorSubclass::value || \
62 HeapDequeSubclass::value || \
61 HeapTerminatedArraySubclass::value, \ 63 HeapTerminatedArraySubclass::value, \
62 ErrorMessage); \ 64 ErrorMessage); \
63 } while (0) 65 } while (0)
64 66
65 template<typename T> class Member; 67 template<typename T> class Member;
66 68
67 class PersistentNode { 69 class PersistentNode {
68 public: 70 public:
69 explicit PersistentNode(TraceCallback trace) 71 explicit PersistentNode(TraceCallback trace)
70 : m_trace(trace) 72 : m_trace(trace)
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 public: 415 public:
414 PersistentHeapVector() { } 416 PersistentHeapVector() { }
415 417
416 template<size_t otherCapacity> 418 template<size_t otherCapacity>
417 PersistentHeapVector(const HeapVector<T, otherCapacity>& other) 419 PersistentHeapVector(const HeapVector<T, otherCapacity>& other)
418 : PersistentHeapCollectionBase<HeapVector<T, inlineCapacity> >(other) 420 : PersistentHeapCollectionBase<HeapVector<T, inlineCapacity> >(other)
419 { 421 {
420 } 422 }
421 }; 423 };
422 424
425 template<typename T, size_t inlineCapacity = 0>
426 class PersistentHeapDeque : public PersistentHeapCollectionBase<HeapDeque<T, inl ineCapacity> > {
427 public:
428 PersistentHeapDeque() { }
429
430 template<size_t otherCapacity>
431 PersistentHeapDeque(const HeapDeque<T, otherCapacity>& other)
432 : PersistentHeapCollectionBase<HeapDeque<T, inlineCapacity> >(other)
433 {
434 }
435 };
436
423 // Members are used in classes to contain strong pointers to other oilpan heap 437 // Members are used in classes to contain strong pointers to other oilpan heap
424 // allocated objects. 438 // allocated objects.
425 // All Member fields of a class must be traced in the class' trace method. 439 // All Member fields of a class must be traced in the class' trace method.
426 // During the mark phase of the GC all live objects are marked as live and 440 // During the mark phase of the GC all live objects are marked as live and
427 // all Member fields of a live object will be traced marked as live as well. 441 // all Member fields of a live object will be traced marked as live as well.
428 template<typename T> 442 template<typename T>
429 class Member { 443 class Member {
430 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(Member); 444 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(Member);
431 WTF_DISALLOW_ZERO_ASSIGNMENT(Member); 445 WTF_DISALLOW_ZERO_ASSIGNMENT(Member);
432 public: 446 public:
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 #define OwnPtrWillBeRawPtr WTF::RawPtr 726 #define OwnPtrWillBeRawPtr WTF::RawPtr
713 #define PassOwnPtrWillBeRawPtr WTF::RawPtr 727 #define PassOwnPtrWillBeRawPtr WTF::RawPtr
714 #define NoBaseWillBeGarbageCollected WebCore::GarbageCollected 728 #define NoBaseWillBeGarbageCollected WebCore::GarbageCollected
715 #define NoBaseWillBeGarbageCollectedFinalized WebCore::GarbageCollectedFinalized 729 #define NoBaseWillBeGarbageCollectedFinalized WebCore::GarbageCollectedFinalized
716 #define WillBeHeapHashMap WebCore::HeapHashMap 730 #define WillBeHeapHashMap WebCore::HeapHashMap
717 #define WillBePersistentHeapHashMap WebCore::PersistentHeapHashMap 731 #define WillBePersistentHeapHashMap WebCore::PersistentHeapHashMap
718 #define WillBeHeapHashSet WebCore::HeapHashSet 732 #define WillBeHeapHashSet WebCore::HeapHashSet
719 #define WillBePersistentHeapHashSet WebCore::PersistentHeapHashSet 733 #define WillBePersistentHeapHashSet WebCore::PersistentHeapHashSet
720 #define WillBeHeapVector WebCore::HeapVector 734 #define WillBeHeapVector WebCore::HeapVector
721 #define WillBePersistentHeapVector WebCore::PersistentHeapVector 735 #define WillBePersistentHeapVector WebCore::PersistentHeapVector
736 #define WillBeHeapDeque WebCore::HeapDeque
737 #define WillBePersistentHeapDeque WebCore::PersistentHeapDeque
722 #define WillBeGarbageCollectedMixin WebCore::GarbageCollectedMixin 738 #define WillBeGarbageCollectedMixin WebCore::GarbageCollectedMixin
723 #define WillBeHeapSupplement WebCore::HeapSupplement 739 #define WillBeHeapSupplement WebCore::HeapSupplement
724 #define WillBeHeapSupplementable WebCore::HeapSupplementable 740 #define WillBeHeapSupplementable WebCore::HeapSupplementable
725 #define WillBeHeapTerminatedArray WebCore::HeapTerminatedArray 741 #define WillBeHeapTerminatedArray WebCore::HeapTerminatedArray
726 #define WillBeHeapTerminatedArrayBuilder WebCore::HeapTerminatedArrayBuilder 742 #define WillBeHeapTerminatedArrayBuilder WebCore::HeapTerminatedArrayBuilder
727 #define WillBeHeapLinkedStack WebCore::HeapLinkedStack 743 #define WillBeHeapLinkedStack WebCore::HeapLinkedStack
728 744
729 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeNoop(T* ptr) 745 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeNoop(T* ptr)
730 { 746 {
731 static const bool notRefCountedGarbageCollected = !WTF::IsSubclassOfTemplate <T, RefCountedGarbageCollected>::value; 747 static const bool notRefCountedGarbageCollected = !WTF::IsSubclassOfTemplate <T, RefCountedGarbageCollected>::value;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 #define OwnPtrWillBeRawPtr WTF::OwnPtr 798 #define OwnPtrWillBeRawPtr WTF::OwnPtr
783 #define PassOwnPtrWillBeRawPtr WTF::PassOwnPtr 799 #define PassOwnPtrWillBeRawPtr WTF::PassOwnPtr
784 #define NoBaseWillBeGarbageCollected WebCore::DummyBase 800 #define NoBaseWillBeGarbageCollected WebCore::DummyBase
785 #define NoBaseWillBeGarbageCollectedFinalized WebCore::DummyBase 801 #define NoBaseWillBeGarbageCollectedFinalized WebCore::DummyBase
786 #define WillBeHeapHashMap WTF::HashMap 802 #define WillBeHeapHashMap WTF::HashMap
787 #define WillBePersistentHeapHashMap WTF::HashMap 803 #define WillBePersistentHeapHashMap WTF::HashMap
788 #define WillBeHeapHashSet WTF::HashSet 804 #define WillBeHeapHashSet WTF::HashSet
789 #define WillBePersistentHeapHashSet WTF::HashSet 805 #define WillBePersistentHeapHashSet WTF::HashSet
790 #define WillBeHeapVector WTF::Vector 806 #define WillBeHeapVector WTF::Vector
791 #define WillBePersistentHeapVector WTF::Vector 807 #define WillBePersistentHeapVector WTF::Vector
808 #define WillBeHeapDeque WTF::Deque
809 #define WillBePersistentHeapDeque WTF::Deque
792 #define WillBeGarbageCollectedMixin WebCore::DummyBase<void> 810 #define WillBeGarbageCollectedMixin WebCore::DummyBase<void>
793 #define WillBeHeapSupplement WebCore::Supplement 811 #define WillBeHeapSupplement WebCore::Supplement
794 #define WillBeHeapSupplementable WebCore::Supplementable 812 #define WillBeHeapSupplementable WebCore::Supplementable
795 #define WillBeHeapTerminatedArray WTF::TerminatedArray 813 #define WillBeHeapTerminatedArray WTF::TerminatedArray
796 #define WillBeHeapTerminatedArrayBuilder WTF::TerminatedArrayBuilder 814 #define WillBeHeapTerminatedArrayBuilder WTF::TerminatedArrayBuilder
797 #define WillBeHeapLinkedStack WTF::LinkedStack 815 #define WillBeHeapLinkedStack WTF::LinkedStack
798 816
799 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeNoop(T* ptr) { retu rn adoptRef(ptr); } 817 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeNoop(T* ptr) { retu rn adoptRef(ptr); }
800 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeRefCountedGarbageCo llected(T* ptr) { return adoptRef(ptr); } 818 template<typename T> PassRefPtrWillBeRawPtr<T> adoptRefWillBeRefCountedGarbageCo llected(T* ptr) { return adoptRef(ptr); }
801 template<typename T> PassOwnPtrWillBeRawPtr<T> adoptPtrWillBeNoop(T* ptr) { retu rn adoptPtr(ptr); } 819 template<typename T> PassOwnPtrWillBeRawPtr<T> adoptPtrWillBeNoop(T* ptr) { retu rn adoptPtr(ptr); }
(...skipping 28 matching lines...) Expand all
830 static const bool canInitializeWithMemset = true; 848 static const bool canInitializeWithMemset = true;
831 static const bool canMoveWithMemcpy = true; 849 static const bool canMoveWithMemcpy = true;
832 }; 850 };
833 851
834 template <typename T> struct VectorTraits<WebCore::HeapVector<T, 0> > : VectorTr aitsBase<WebCore::HeapVector<T, 0> > { 852 template <typename T> struct VectorTraits<WebCore::HeapVector<T, 0> > : VectorTr aitsBase<WebCore::HeapVector<T, 0> > {
835 static const bool needsDestruction = false; 853 static const bool needsDestruction = false;
836 static const bool canInitializeWithMemset = true; 854 static const bool canInitializeWithMemset = true;
837 static const bool canMoveWithMemcpy = true; 855 static const bool canMoveWithMemcpy = true;
838 }; 856 };
839 857
858 template <typename T> struct VectorTraits<WebCore::HeapDeque<T, 0> > : VectorTra itsBase<WebCore::HeapDeque<T, 0> > {
859 static const bool needsDestruction = false;
860 static const bool canInitializeWithMemset = true;
861 static const bool canMoveWithMemcpy = true;
862 };
863
840 template <typename T, size_t inlineCapacity> struct VectorTraits<WebCore::HeapVe ctor<T, inlineCapacity> > : VectorTraitsBase<WebCore::HeapVector<T, inlineCapaci ty> > { 864 template <typename T, size_t inlineCapacity> struct VectorTraits<WebCore::HeapVe ctor<T, inlineCapacity> > : VectorTraitsBase<WebCore::HeapVector<T, inlineCapaci ty> > {
841 static const bool needsDestruction = VectorTraits<T>::needsDestruction; 865 static const bool needsDestruction = VectorTraits<T>::needsDestruction;
842 static const bool canInitializeWithMemset = VectorTraits<T>::canInitializeWi thMemset; 866 static const bool canInitializeWithMemset = VectorTraits<T>::canInitializeWi thMemset;
843 static const bool canMoveWithMemcpy = VectorTraits<T>::canMoveWithMemcpy; 867 static const bool canMoveWithMemcpy = VectorTraits<T>::canMoveWithMemcpy;
844 }; 868 };
845 869
870 template <typename T, size_t inlineCapacity> struct VectorTraits<WebCore::HeapDe que<T, inlineCapacity> > : VectorTraitsBase<WebCore::HeapDeque<T, inlineCapacity > > {
871 static const bool needsDestruction = VectorTraits<T>::needsDestruction;
872 static const bool canInitializeWithMemset = VectorTraits<T>::canInitializeWi thMemset;
873 static const bool canMoveWithMemcpy = VectorTraits<T>::canMoveWithMemcpy;
874 };
875
846 template<typename T> struct HashTraits<WebCore::Member<T> > : SimpleClassHashTra its<WebCore::Member<T> > { 876 template<typename T> struct HashTraits<WebCore::Member<T> > : SimpleClassHashTra its<WebCore::Member<T> > {
847 static const bool needsDestruction = false; 877 static const bool needsDestruction = false;
848 // FIXME: The distinction between PeekInType and PassInType is there for 878 // FIXME: The distinction between PeekInType and PassInType is there for
849 // the sake of the reference counting handles. When they are gone the two 879 // the sake of the reference counting handles. When they are gone the two
850 // types can be merged into PassInType. 880 // types can be merged into PassInType.
851 // FIXME: Implement proper const'ness for iterator types. Requires support 881 // FIXME: Implement proper const'ness for iterator types. Requires support
852 // in the marking Visitor. 882 // in the marking Visitor.
853 typedef RawPtr<T> PeekInType; 883 typedef RawPtr<T> PeekInType;
854 typedef RawPtr<T> PassInType; 884 typedef RawPtr<T> PassInType;
855 typedef WebCore::Member<T>* IteratorGetType; 885 typedef WebCore::Member<T>* IteratorGetType;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 }; 1009 };
980 1010
981 template<typename T, typename U> 1011 template<typename T, typename U>
982 struct NeedsTracing<HashMap<T, U> > { 1012 struct NeedsTracing<HashMap<T, U> > {
983 static const bool value = false; 1013 static const bool value = false;
984 }; 1014 };
985 1015
986 } // namespace WTF 1016 } // namespace WTF
987 1017
988 #endif 1018 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698