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

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

Issue 282263006: Oilpan: remove consts when checking GC-class convertibility. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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 | « Source/platform/heap/ThreadState.h ('k') | no next file » | 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) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 // The FinalizerTrait is used to determine if a type requires 124 // The FinalizerTrait is used to determine if a type requires
125 // finalization and what finalization means. 125 // finalization and what finalization means.
126 // 126 //
127 // By default classes that inherit from GarbageCollectedFinalized need 127 // By default classes that inherit from GarbageCollectedFinalized need
128 // finalization and finalization means calling the 'finalize' method 128 // finalization and finalization means calling the 'finalize' method
129 // of the object. The FinalizerTrait can be specialized if the default 129 // of the object. The FinalizerTrait can be specialized if the default
130 // behavior is not desired. 130 // behavior is not desired.
131 template<typename T> 131 template<typename T>
132 struct FinalizerTrait { 132 struct FinalizerTrait {
133 static const bool nonTrivialFinalizer = WTF::IsSubclassOfTemplate<T, Garbage CollectedFinalized>::value; 133 static const bool nonTrivialFinalizer = WTF::IsSubclassOfTemplate<typename W TF::RemoveConst<T>::Type, GarbageCollectedFinalized>::value;
134 static void finalize(void* obj) { FinalizerTraitImpl<T, nonTrivialFinalizer> ::finalize(obj); } 134 static void finalize(void* obj) { FinalizerTraitImpl<T, nonTrivialFinalizer> ::finalize(obj); }
135 }; 135 };
136 136
137 // The VTableTrait is used to determine if a type has at least one virtual metho d. 137 // The VTableTrait is used to determine if a type has at least one virtual metho d.
138 template<typename T> 138 template<typename T>
139 struct VTableTrait { 139 struct VTableTrait {
140 static const bool hasVTable = __is_polymorphic(T); 140 static const bool hasVTable = __is_polymorphic(T);
141 }; 141 };
142 142
143 // Trait to get the GCInfo structure for types that have their 143 // Trait to get the GCInfo structure for types that have their
144 // instances allocated in the Blink garbage-collected heap. 144 // instances allocated in the Blink garbage-collected heap.
145 template<typename T> struct GCInfoTrait; 145 template<typename T> struct GCInfoTrait;
146 146
147 template<typename T> class GarbageCollected; 147 template<typename T> class GarbageCollected;
148 class GarbageCollectedMixin; 148 class GarbageCollectedMixin;
149 template<typename T, bool = WTF::IsSubclassOfTemplate<T, GarbageCollected>::valu e> class NeedsAdjustAndMark; 149 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst< T>::Type, GarbageCollected>::value> class NeedsAdjustAndMark;
150 150
151 template<typename T> 151 template<typename T>
152 class NeedsAdjustAndMark<T, true> { 152 class NeedsAdjustAndMark<T, true> {
153 public: 153 public:
154 static const bool value = false; 154 static const bool value = false;
155 }; 155 };
156 156
157 template<typename T> 157 template<typename T>
158 class NeedsAdjustAndMark<T, false> { 158 class NeedsAdjustAndMark<T, false> {
159 public: 159 public:
160 static const bool value = WTF::IsSubclass<T, GarbageCollectedMixin>::value; 160 static const bool value = WTF::IsSubclass<typename WTF::RemoveConst<T>::Type , GarbageCollectedMixin>::value;
161 }; 161 };
162 162
163 template<typename T, bool = NeedsAdjustAndMark<T>::value> class DefaultTraceTrai t; 163 template<typename T, bool = NeedsAdjustAndMark<T>::value> class DefaultTraceTrai t;
164 164
165 // The TraceTrait is used to specify how to mark an object pointer and 165 // The TraceTrait is used to specify how to mark an object pointer and
166 // how to trace all of the pointers in the object. 166 // how to trace all of the pointers in the object.
167 // 167 //
168 // By default, the 'trace' method implemented on an object itself is 168 // By default, the 'trace' method implemented on an object itself is
169 // used to trace the pointers to other heap objects inside the object. 169 // used to trace the pointers to other heap objects inside the object.
170 // 170 //
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 class GarbageCollectedMixin { 662 class GarbageCollectedMixin {
663 public: 663 public:
664 virtual void adjustAndMark(Visitor*) const = 0; 664 virtual void adjustAndMark(Visitor*) const = 0;
665 virtual bool isAlive(Visitor*) const = 0; 665 virtual bool isAlive(Visitor*) const = 0;
666 }; 666 };
667 667
668 #define USING_GARBAGE_COLLECTED_MIXIN(TYPE) \ 668 #define USING_GARBAGE_COLLECTED_MIXIN(TYPE) \
669 public: \ 669 public: \
670 virtual void adjustAndMark(WebCore::Visitor* visitor) const OVERRIDE \ 670 virtual void adjustAndMark(WebCore::Visitor* visitor) const OVERRIDE \
671 { \ 671 { \
672 typedef WTF::IsSubclassOfTemplate<TYPE, WebCore::GarbageCollected> IsSub classOfGarbageCollected; \ 672 typedef WTF::IsSubclassOfTemplate<typename WTF::RemoveConst<TYPE>::Type, WebCore::GarbageCollected> IsSubclassOfGarbageCollected; \
673 COMPILE_ASSERT(IsSubclassOfGarbageCollected::value, OnlyGarbageCollected ObjectsCanHaveGarbageCollectedMixins); \ 673 COMPILE_ASSERT(IsSubclassOfGarbageCollected::value, OnlyGarbageCollected ObjectsCanHaveGarbageCollectedMixins); \
674 visitor->mark(this, &WebCore::TraceTrait<TYPE>::trace); \ 674 visitor->mark(this, &WebCore::TraceTrait<TYPE>::trace); \
675 } \ 675 } \
676 virtual bool isAlive(WebCore::Visitor* visitor) const OVERRIDE \ 676 virtual bool isAlive(WebCore::Visitor* visitor) const OVERRIDE \
677 { \ 677 { \
678 return visitor->isAlive(this); \ 678 return visitor->isAlive(this); \
679 } 679 }
680 680
681 #if ENABLE(OILPAN) 681 #if ENABLE(OILPAN)
682 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXI N(TYPE) 682 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXI N(TYPE)
(...skipping 23 matching lines...) Expand all
706 VTableTrait<T>::hasVTable, 706 VTableTrait<T>::hasVTable,
707 #if ENABLE(GC_TRACING) 707 #if ENABLE(GC_TRACING)
708 TypenameStringTrait<T>::get() 708 TypenameStringTrait<T>::get()
709 #endif 709 #endif
710 }; 710 };
711 return &gcInfo; 711 return &gcInfo;
712 } 712 }
713 }; 713 };
714 714
715 template<typename T> class GarbageCollected; 715 template<typename T> class GarbageCollected;
716 template<typename T, bool = WTF::IsSubclassOfTemplate<T, GarbageCollected>::valu e> struct GetGarbageCollectedBase; 716 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst< T>::Type, GarbageCollected>::value> struct GetGarbageCollectedBase;
717 717
718 template<typename T> 718 template<typename T>
719 struct GetGarbageCollectedBase<T, true> { 719 struct GetGarbageCollectedBase<T, true> {
720 typedef typename T::GarbageCollectedBase type; 720 typedef typename T::GarbageCollectedBase type;
721 }; 721 };
722 722
723 template<typename T> 723 template<typename T>
724 struct GetGarbageCollectedBase<T, false> { 724 struct GetGarbageCollectedBase<T, false> {
725 typedef T type; 725 typedef T type;
726 }; 726 };
727 727
728 template<typename T> 728 template<typename T>
729 struct GCInfoTrait { 729 struct GCInfoTrait {
730 static const GCInfo* get() 730 static const GCInfo* get()
731 { 731 {
732 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); 732 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get();
733 } 733 }
734 }; 734 };
735 735
736 } 736 }
737 737
738 #endif 738 #endif
OLDNEW
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698