| 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" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 GarbageCollected>::value> | 283 GarbageCollected>::value> |
| 284 class NeedsAdjustAndMark; | 284 class NeedsAdjustAndMark; |
| 285 | 285 |
| 286 template <typename T> | 286 template <typename T> |
| 287 class NeedsAdjustAndMark<T, true> { | 287 class NeedsAdjustAndMark<T, true> { |
| 288 static_assert(sizeof(T), "T must be fully defined"); | 288 static_assert(sizeof(T), "T must be fully defined"); |
| 289 | 289 |
| 290 public: | 290 public: |
| 291 static const bool value = false; | 291 static const bool value = false; |
| 292 }; | 292 }; |
| 293 template <typename T> | |
| 294 const bool NeedsAdjustAndMark<T, true>::value; | |
| 295 | 293 |
| 296 template <typename T> | 294 template <typename T> |
| 297 class NeedsAdjustAndMark<T, false> { | 295 class NeedsAdjustAndMark<T, false> { |
| 298 static_assert(sizeof(T), "T must be fully defined"); | 296 static_assert(sizeof(T), "T must be fully defined"); |
| 299 | 297 |
| 300 public: | 298 public: |
| 301 static const bool value = | 299 static const bool value = |
| 302 IsGarbageCollectedMixin<typename std::remove_const<T>::type>::value; | 300 IsGarbageCollectedMixin<typename std::remove_const<T>::type>::value; |
| 303 }; | 301 }; |
| 304 template <typename T> | |
| 305 const bool NeedsAdjustAndMark<T, false>::value; | |
| 306 | 302 |
| 307 template <typename T, | 303 template <typename T, |
| 308 bool = std::is_base_of<TraceWrapperBase, | 304 bool = std::is_base_of<TraceWrapperBase, |
| 309 typename std::remove_const<T>::type>::value> | 305 typename std::remove_const<T>::type>::value> |
| 310 class CanTraceWrappers; | 306 class CanTraceWrappers; |
| 311 | 307 |
| 312 template <typename T> | 308 template <typename T> |
| 313 class CanTraceWrappers<T, true> { | 309 class CanTraceWrappers<T, true> { |
| 314 static_assert(sizeof(T), "T must be fully defined"); | 310 static_assert(sizeof(T), "T must be fully defined"); |
| 315 | 311 |
| 316 public: | 312 public: |
| 317 static const bool value = true; | 313 static const bool value = true; |
| 318 }; | 314 }; |
| 319 template <typename T> | |
| 320 const bool CanTraceWrappers<T, true>::value; | |
| 321 | 315 |
| 322 template <typename T> | 316 template <typename T> |
| 323 class CanTraceWrappers<T, false> { | 317 class CanTraceWrappers<T, false> { |
| 324 static_assert(sizeof(T), "T must be fully defined"); | 318 static_assert(sizeof(T), "T must be fully defined"); |
| 325 | 319 |
| 326 public: | 320 public: |
| 327 static const bool value = false; | 321 static const bool value = false; |
| 328 }; | 322 }; |
| 329 template <typename T> | |
| 330 const bool CanTraceWrappers<T, false>::value; | |
| 331 | 323 |
| 332 // TODO(sof): migrate to wtf/TypeTraits.h | 324 // TODO(sof): migrate to wtf/TypeTraits.h |
| 333 template <typename T> | 325 template <typename T> |
| 334 class IsFullyDefined { | 326 class IsFullyDefined { |
| 335 using TrueType = char; | 327 using TrueType = char; |
| 336 struct FalseType { | 328 struct FalseType { |
| 337 char dummy[2]; | 329 char dummy[2]; |
| 338 }; | 330 }; |
| 339 | 331 |
| 340 template <typename U, size_t sz = sizeof(U)> | 332 template <typename U, size_t sz = sizeof(U)> |
| 341 static TrueType isSizeofKnown(U*); | 333 static TrueType isSizeofKnown(U*); |
| 342 static FalseType isSizeofKnown(...); | 334 static FalseType isSizeofKnown(...); |
| 343 static T& t; | 335 static T& t; |
| 344 | 336 |
| 345 public: | 337 public: |
| 346 static const bool value = sizeof(TrueType) == sizeof(isSizeofKnown(&t)); | 338 static const bool value = sizeof(TrueType) == sizeof(isSizeofKnown(&t)); |
| 347 }; | 339 }; |
| 348 | 340 |
| 349 } // namespace blink | 341 } // namespace blink |
| 350 | 342 |
| 351 #endif | 343 #endif |
| OLD | NEW |