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

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

Issue 1007803004: Oilpan: consistently use IsGarbageCollectedMixin<> trait. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 | « Source/modules/speech/SpeechRecognition.h ('k') | public/platform/WebPrivatePtr.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) 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 // By default classes that inherit from GarbageCollectedFinalized need 123 // By default classes that inherit from GarbageCollectedFinalized need
124 // finalization and finalization means calling the 'finalize' method 124 // finalization and finalization means calling the 'finalize' method
125 // of the object. The FinalizerTrait can be specialized if the default 125 // of the object. The FinalizerTrait can be specialized if the default
126 // behavior is not desired. 126 // behavior is not desired.
127 template<typename T> 127 template<typename T>
128 struct FinalizerTrait { 128 struct FinalizerTrait {
129 static const bool nonTrivialFinalizer = WTF::IsSubclassOfTemplate<typename W TF::RemoveConst<T>::Type, GarbageCollectedFinalized>::value; 129 static const bool nonTrivialFinalizer = WTF::IsSubclassOfTemplate<typename W TF::RemoveConst<T>::Type, GarbageCollectedFinalized>::value;
130 static void finalize(void* obj) { FinalizerTraitImpl<T, nonTrivialFinalizer> ::finalize(obj); } 130 static void finalize(void* obj) { FinalizerTraitImpl<T, nonTrivialFinalizer> ::finalize(obj); }
131 }; 131 };
132 132
133 // Template to determine if a class is a GarbageCollectedMixin by checking if it
134 // has IsGarbageCollectedMixinMarker
135 template<typename T>
136 struct IsGarbageCollectedMixin {
137 private:
138 typedef char YesType;
139 struct NoType {
140 char padding[8];
141 };
142
143 template <typename U> static YesType checkMarker(typename U::IsGarbageCollec tedMixinMarker*);
144 template <typename U> static NoType checkMarker(...);
145
146 public:
147 static const bool value = sizeof(checkMarker<T>(nullptr)) == sizeof(YesType) ;
148 };
149
133 // Trait to get the GCInfo structure for types that have their 150 // Trait to get the GCInfo structure for types that have their
134 // instances allocated in the Blink garbage-collected heap. 151 // instances allocated in the Blink garbage-collected heap.
135 template<typename T> struct GCInfoTrait; 152 template<typename T> struct GCInfoTrait;
136 153
137 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst< T>::Type, GarbageCollected>::value> class NeedsAdjustAndMark; 154 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst< T>::Type, GarbageCollected>::value> class NeedsAdjustAndMark;
138 155
139 template<typename T> 156 template<typename T>
140 class NeedsAdjustAndMark<T, true> { 157 class NeedsAdjustAndMark<T, true> {
141 public: 158 public:
142 static const bool value = false; 159 static const bool value = false;
143 }; 160 };
144 161
145 template <typename T> const bool NeedsAdjustAndMark<T, true>::value; 162 template <typename T> const bool NeedsAdjustAndMark<T, true>::value;
146 163
147 template<typename T> 164 template<typename T>
148 class NeedsAdjustAndMark<T, false> { 165 class NeedsAdjustAndMark<T, false> {
149 public: 166 public:
150 static const bool value = WTF::IsSubclass<typename WTF::RemoveConst<T>::Type , GarbageCollectedMixin>::value; 167 static const bool value = IsGarbageCollectedMixin<typename WTF::RemoveConst< T>::Type>::value;
151 }; 168 };
152 169
153 template <typename T> const bool NeedsAdjustAndMark<T, false>::value; 170 template <typename T> const bool NeedsAdjustAndMark<T, false>::value;
154 171
155 template<typename T, bool = NeedsAdjustAndMark<T>::value> class DefaultTraceTrai t; 172 template<typename T, bool = NeedsAdjustAndMark<T>::value> class DefaultTraceTrai t;
156 173
157 // HasInlinedTraceMethod<T>::value is true for T supporting 174 // HasInlinedTraceMethod<T>::value is true for T supporting
158 // T::trace(InlinedGlobalMarkingVisitor). 175 // T::trace(InlinedGlobalMarkingVisitor).
159 // The template works by checking if T::HasInlinedTraceMethodMarker type is 176 // The template works by checking if T::HasInlinedTraceMethodMarker type is
160 // available using SFINAE. The HasInlinedTraceMethodMarker type is defined 177 // available using SFINAE. The HasInlinedTraceMethodMarker type is defined
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 USING_GARBAGE_COLLECTED_MIXIN_BASE(TYPE) 1052 USING_GARBAGE_COLLECTED_MIXIN_BASE(TYPE)
1036 1053
1037 #if ENABLE(OILPAN) 1054 #if ENABLE(OILPAN)
1038 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXI N(TYPE) 1055 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) USING_GARBAGE_COLLECTED_MIXI N(TYPE)
1039 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN_NESTED(TYPE, NESTEDMIXIN) USING_GA RBAGE_COLLECTED_MIXIN_NESTED(TYPE, NESTEDMIXIN) 1056 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN_NESTED(TYPE, NESTEDMIXIN) USING_GA RBAGE_COLLECTED_MIXIN_NESTED(TYPE, NESTEDMIXIN)
1040 #else 1057 #else
1041 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE) 1058 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(TYPE)
1042 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN_NESTED(TYPE, NESTEDMIXIN) 1059 #define WILL_BE_USING_GARBAGE_COLLECTED_MIXIN_NESTED(TYPE, NESTEDMIXIN)
1043 #endif 1060 #endif
1044 1061
1045 // Template to determine if a class is a GarbageCollectedMixin by checking if it
1046 // has IsGarbageCollectedMixinMarker
1047 template<typename T>
1048 struct IsGarbageCollectedMixin {
1049 private:
1050 typedef char YesType;
1051 struct NoType {
1052 char padding[8];
1053 };
1054
1055 template <typename U> static YesType checkMarker(typename U::IsGarbageCollec tedMixinMarker*);
1056 template <typename U> static NoType checkMarker(...);
1057
1058 public:
1059 static const bool value = sizeof(checkMarker<T>(nullptr)) == sizeof(YesType) ;
1060 };
1061
1062 // An empty class with a constructor that's arranged invoked when all derived co nstructors 1062 // An empty class with a constructor that's arranged invoked when all derived co nstructors
1063 // of a mixin instance have completed and it is safe to allow GCs again. See 1063 // of a mixin instance have completed and it is safe to allow GCs again. See
1064 // AllocateObjectTrait<> comment for more. 1064 // AllocateObjectTrait<> comment for more.
1065 // 1065 //
1066 // USING_GARBAGE_COLLECTED_MIXIN() declares a GarbageCollectedMixinConstructorMa rker<> private 1066 // USING_GARBAGE_COLLECTED_MIXIN() declares a GarbageCollectedMixinConstructorMa rker<> private
1067 // field. By following Blink convention of using the macro at the top of a class declaration, 1067 // field. By following Blink convention of using the macro at the top of a class declaration,
1068 // its constructor will run first. 1068 // its constructor will run first.
1069 template<typename T> 1069 template<typename T>
1070 class GarbageCollectedMixinConstructorMarker { 1070 class GarbageCollectedMixinConstructorMarker {
1071 public: 1071 public:
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 struct GCInfoTrait { 1157 struct GCInfoTrait {
1158 static size_t index() 1158 static size_t index()
1159 { 1159 {
1160 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index(); 1160 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index();
1161 } 1161 }
1162 }; 1162 };
1163 1163
1164 } // namespace blink 1164 } // namespace blink
1165 1165
1166 #endif // Visitor_h 1166 #endif // Visitor_h
OLDNEW
« no previous file with comments | « Source/modules/speech/SpeechRecognition.h ('k') | public/platform/WebPrivatePtr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698