Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef GarbageCollected_h | 5 #ifndef GarbageCollected_h |
| 6 #define GarbageCollected_h | 6 #define GarbageCollected_h |
| 7 | 7 |
| 8 #include "platform/heap/ThreadState.h" | 8 #include "platform/heap/ThreadState.h" |
| 9 #include "wtf/Allocator.h" | 9 #include "wtf/Allocator.h" |
| 10 #include "wtf/Assertions.h" | 10 #include "wtf/Assertions.h" |
| 11 #include "wtf/TypeTraits.h" | 11 #include "wtf/TypeTraits.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 template <typename T> | 15 template <typename T> |
| 16 class GarbageCollected; | 16 class GarbageCollected; |
| 17 class TraceWrapperBase; | |
| 18 | 17 |
| 19 // GC_PLUGIN_IGNORE is used to make the plugin ignore a particular class or | 18 // GC_PLUGIN_IGNORE is used to make the plugin ignore a particular class or |
| 20 // field when checking for proper usage. When using GC_PLUGIN_IGNORE | 19 // field when checking for proper usage. When using GC_PLUGIN_IGNORE |
| 21 // a bug-number should be provided as an argument where the bug describes | 20 // a bug-number should be provided as an argument where the bug describes |
| 22 // what needs to happen to remove the GC_PLUGIN_IGNORE again. | 21 // what needs to happen to remove the GC_PLUGIN_IGNORE again. |
| 23 #if COMPILER(CLANG) | 22 #if COMPILER(CLANG) |
| 24 #define GC_PLUGIN_IGNORE(bug) \ | 23 #define GC_PLUGIN_IGNORE(bug) \ |
| 25 __attribute__((annotate("blink_gc_plugin_ignore"))) | 24 __attribute__((annotate("blink_gc_plugin_ignore"))) |
| 26 #else | 25 #else |
| 27 #define GC_PLUGIN_IGNORE(bug) | 26 #define GC_PLUGIN_IGNORE(bug) |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 | 239 |
| 241 template <typename T> | 240 template <typename T> |
| 242 class NeedsAdjustAndMark<T, false> { | 241 class NeedsAdjustAndMark<T, false> { |
| 243 static_assert(sizeof(T), "T must be fully defined"); | 242 static_assert(sizeof(T), "T must be fully defined"); |
| 244 | 243 |
| 245 public: | 244 public: |
| 246 static const bool value = | 245 static const bool value = |
| 247 IsGarbageCollectedMixin<typename std::remove_const<T>::type>::value; | 246 IsGarbageCollectedMixin<typename std::remove_const<T>::type>::value; |
| 248 }; | 247 }; |
| 249 | 248 |
| 250 template <typename T, | 249 template <typename T> |
| 251 bool = std::is_base_of<TraceWrapperBase, | 250 class CanTraceWrappers { |
|
adithyas
2017/03/03 21:40:07
I don't know if this is useful anymore, I think th
Michael Lippautz
2017/03/07 08:00:00
I would keep it as we should be able to generate b
| |
| 252 typename std::remove_const<T>::type>::value> | 251 typedef char YesType; |
| 253 class CanTraceWrappers; | 252 typedef long NoType; |
| 254 | 253 |
| 255 template <typename T> | 254 template <typename U> |
| 256 class CanTraceWrappers<T, true> { | 255 static YesType TypeHasMarkAndDispatchTraceWrappers( |
| 257 static_assert(sizeof(T), "T must be fully defined"); | 256 decltype(&U::markAndDispatchTraceWrappers) *); |
| 257 template <typename U> | |
| 258 static NoType TypeHasMarkAndDispatchTraceWrappers(...); | |
| 258 | 259 |
| 259 public: | 260 public: |
| 260 static const bool value = true; | 261 static bool const value = |
| 261 }; | 262 (sizeof(TypeHasMarkAndDispatchTraceWrappers<T>(0)) == sizeof(YesType)); |
| 262 | |
| 263 template <typename T> | |
| 264 class CanTraceWrappers<T, false> { | |
| 265 static_assert(sizeof(T), "T must be fully defined"); | |
| 266 | |
| 267 public: | |
| 268 static const bool value = false; | |
| 269 }; | 263 }; |
| 270 | 264 |
| 271 // TODO(sof): migrate to wtf/TypeTraits.h | 265 // TODO(sof): migrate to wtf/TypeTraits.h |
| 272 template <typename T> | 266 template <typename T> |
| 273 class IsFullyDefined { | 267 class IsFullyDefined { |
| 274 using TrueType = char; | 268 using TrueType = char; |
| 275 struct FalseType { | 269 struct FalseType { |
| 276 char dummy[2]; | 270 char dummy[2]; |
| 277 }; | 271 }; |
| 278 | 272 |
| 279 template <typename U, size_t sz = sizeof(U)> | 273 template <typename U, size_t sz = sizeof(U)> |
| 280 static TrueType isSizeofKnown(U*); | 274 static TrueType isSizeofKnown(U*); |
| 281 static FalseType isSizeofKnown(...); | 275 static FalseType isSizeofKnown(...); |
| 282 static T& t; | 276 static T& t; |
| 283 | 277 |
| 284 public: | 278 public: |
| 285 static const bool value = sizeof(TrueType) == sizeof(isSizeofKnown(&t)); | 279 static const bool value = sizeof(TrueType) == sizeof(isSizeofKnown(&t)); |
| 286 }; | 280 }; |
| 287 | 281 |
| 288 } // namespace blink | 282 } // namespace blink |
| 289 | 283 |
| 290 #endif | 284 #endif |
| OLD | NEW |