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 HeapAllocator_h | 5 #ifndef HeapAllocator_h |
| 6 #define HeapAllocator_h | 6 #define HeapAllocator_h |
| 7 | 7 |
| 8 #include "platform/heap/Heap.h" | 8 #include "platform/heap/Heap.h" |
| 9 #include "platform/heap/Persistent.h" | |
| 9 #include "platform/heap/TraceTraits.h" | 10 #include "platform/heap/TraceTraits.h" |
| 10 #include "wtf/Allocator.h" | 11 #include "wtf/Allocator.h" |
| 11 #include "wtf/Assertions.h" | 12 #include "wtf/Assertions.h" |
| 12 #include "wtf/Deque.h" | 13 #include "wtf/Deque.h" |
| 13 #include "wtf/HashCountedSet.h" | 14 #include "wtf/HashCountedSet.h" |
| 14 #include "wtf/HashMap.h" | 15 #include "wtf/HashMap.h" |
| 15 #include "wtf/HashSet.h" | 16 #include "wtf/HashSet.h" |
| 16 #include "wtf/HashTable.h" | 17 #include "wtf/HashTable.h" |
| 17 #include "wtf/LinkedHashSet.h" | 18 #include "wtf/LinkedHashSet.h" |
| 18 #include "wtf/ListHashSet.h" | 19 #include "wtf/ListHashSet.h" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 }; | 416 }; |
| 416 | 417 |
| 417 template <typename T> struct VectorTraits<blink::UntracedMember<T>> : VectorTrai tsBase<blink::UntracedMember<T>> { | 418 template <typename T> struct VectorTraits<blink::UntracedMember<T>> : VectorTrai tsBase<blink::UntracedMember<T>> { |
| 418 STATIC_ONLY(VectorTraits); | 419 STATIC_ONLY(VectorTraits); |
| 419 static const bool needsDestruction = false; | 420 static const bool needsDestruction = false; |
| 420 static const bool canInitializeWithMemset = true; | 421 static const bool canInitializeWithMemset = true; |
| 421 static const bool canClearUnusedSlotsWithMemset = true; | 422 static const bool canClearUnusedSlotsWithMemset = true; |
| 422 static const bool canMoveWithMemcpy = true; | 423 static const bool canMoveWithMemcpy = true; |
| 423 }; | 424 }; |
| 424 | 425 |
| 426 template <typename T, blink::WeaknessPersistentConfiguration weaknessConfigurati on, blink::CrossThreadnessPersistentConfiguration crossThreadnessConfiguration> | |
| 427 struct VectorTraits<blink::PersistentBase<T, weaknessConfiguration, crossThreadn essConfiguration>> | |
| 428 : VectorTraitsBase<blink::PersistentBase<T, weaknessConfiguration, crossThre adnessConfiguration>> { | |
| 429 STATIC_ONLY(VectorTraits); | |
| 430 static const bool needsDestruction = true; | |
| 431 static const bool canInitializeWithMemset = true; | |
| 432 static const bool canClearUnusedSlotsWithMemset = false; | |
| 433 static const bool canMoveWithMemcpy = true; | |
| 434 }; | |
| 435 | |
| 425 template <typename T> struct VectorTraits<blink::HeapVector<T, 0>> : VectorTrait sBase<blink::HeapVector<T, 0>> { | 436 template <typename T> struct VectorTraits<blink::HeapVector<T, 0>> : VectorTrait sBase<blink::HeapVector<T, 0>> { |
| 426 STATIC_ONLY(VectorTraits); | 437 STATIC_ONLY(VectorTraits); |
| 427 static const bool needsDestruction = false; | 438 static const bool needsDestruction = false; |
| 428 static const bool canInitializeWithMemset = true; | 439 static const bool canInitializeWithMemset = true; |
| 429 static const bool canClearUnusedSlotsWithMemset = true; | 440 static const bool canClearUnusedSlotsWithMemset = true; |
| 430 static const bool canMoveWithMemcpy = true; | 441 static const bool canMoveWithMemcpy = true; |
| 431 }; | 442 }; |
| 432 | 443 |
| 433 template <typename T> struct VectorTraits<blink::HeapDeque<T, 0>> : VectorTraits Base<blink::HeapDeque<T, 0>> { | 444 template <typename T> struct VectorTraits<blink::HeapDeque<T, 0>> : VectorTraits Base<blink::HeapDeque<T, 0>> { |
| 434 STATIC_ONLY(VectorTraits); | 445 STATIC_ONLY(VectorTraits); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 // regardless of whether they contain pointers to other heap allocated | 555 // regardless of whether they contain pointers to other heap allocated |
| 545 // objects. | 556 // objects. |
| 546 static const bool value = true; | 557 static const bool value = true; |
| 547 }; | 558 }; |
| 548 | 559 |
| 549 template<typename T, size_t inlineCapacity> | 560 template<typename T, size_t inlineCapacity> |
| 550 struct IsGarbageCollectedType<ListHashSetNode<T, blink::HeapListHashSetAllocator <T, inlineCapacity>>> { | 561 struct IsGarbageCollectedType<ListHashSetNode<T, blink::HeapListHashSetAllocator <T, inlineCapacity>>> { |
| 551 static const bool value = true; | 562 static const bool value = true; |
| 552 }; | 563 }; |
| 553 | 564 |
| 565 template<typename T> struct HashTraits<blink::CrossThreadPersistent<T>> : Simple ClassHashTraits<blink::CrossThreadPersistent<T>> { | |
|
sof
2016/05/26 09:41:44
Can we make this be over PersistentBase<> also, or
keishi
2016/05/26 11:38:17
I tried PersistentBase but it didn't work so had t
| |
| 566 STATIC_ONLY(HashTraits); | |
| 567 // TODO: The distinction between PeekInType and PassInType is there for | |
| 568 // the sake of the reference counting handles. When they are gone the two | |
| 569 // types can be merged into PassInType. | |
| 570 // TODO: Implement proper const'ness for iterator types. Requires support | |
| 571 // in the marking Visitor. | |
| 572 using PeekInType = T*; | |
| 573 using PassInType = T*; | |
| 574 using IteratorGetType = blink::CrossThreadPersistent<T>*; | |
| 575 using IteratorConstGetType = const blink::CrossThreadPersistent<T>*; | |
| 576 using IteratorReferenceType = blink::CrossThreadPersistent<T>&; | |
| 577 using IteratorConstReferenceType = const blink::CrossThreadPersistent<T>&; | |
| 578 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { r eturn *x; } | |
| 579 static IteratorConstReferenceType getToReferenceConstConversion(IteratorCons tGetType x) { return *x; } | |
| 580 // TODO: Similarly, there is no need for a distinction between PeekOutType | |
| 581 // and PassOutType without reference counting. | |
| 582 using PeekOutType = T*; | |
| 583 using PassOutType = T*; | |
| 584 | |
| 585 template<typename U> | |
| 586 static void store(const U& value, blink::CrossThreadPersistent<T>& storage) { storage = value; } | |
| 587 | |
| 588 static PeekOutType peek(const blink::CrossThreadPersistent<T>& value) { retu rn value; } | |
| 589 static PassOutType passOut(const blink::CrossThreadPersistent<T>& value) { r eturn value; } | |
| 590 }; | |
| 591 | |
| 554 } // namespace WTF | 592 } // namespace WTF |
| 555 | 593 |
| 556 #endif | 594 #endif |
| OLD | NEW |