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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 }; | 429 }; |
429 | 430 |
430 template <typename T> struct VectorTraits<blink::UntracedMember<T>> : VectorTrai
tsBase<blink::UntracedMember<T>> { | 431 template <typename T> struct VectorTraits<blink::UntracedMember<T>> : VectorTrai
tsBase<blink::UntracedMember<T>> { |
431 STATIC_ONLY(VectorTraits); | 432 STATIC_ONLY(VectorTraits); |
432 static const bool needsDestruction = false; | 433 static const bool needsDestruction = false; |
433 static const bool canInitializeWithMemset = true; | 434 static const bool canInitializeWithMemset = true; |
434 static const bool canClearUnusedSlotsWithMemset = true; | 435 static const bool canClearUnusedSlotsWithMemset = true; |
435 static const bool canMoveWithMemcpy = true; | 436 static const bool canMoveWithMemcpy = true; |
436 }; | 437 }; |
437 | 438 |
| 439 template <typename T, blink::WeaknessPersistentConfiguration weaknessConfigurati
on, blink::CrossThreadnessPersistentConfiguration crossThreadnessConfiguration> |
| 440 struct VectorTraits<blink::PersistentBase<T, weaknessConfiguration, crossThreadn
essConfiguration>> |
| 441 : VectorTraitsBase<blink::PersistentBase<T, weaknessConfiguration, crossThre
adnessConfiguration>> { |
| 442 STATIC_ONLY(VectorTraits); |
| 443 static const bool needsDestruction = true; |
| 444 static const bool canInitializeWithMemset = true; |
| 445 static const bool canClearUnusedSlotsWithMemset = false; |
| 446 static const bool canMoveWithMemcpy = true; |
| 447 }; |
| 448 |
438 template <typename T> struct VectorTraits<blink::HeapVector<T, 0>> : VectorTrait
sBase<blink::HeapVector<T, 0>> { | 449 template <typename T> struct VectorTraits<blink::HeapVector<T, 0>> : VectorTrait
sBase<blink::HeapVector<T, 0>> { |
439 STATIC_ONLY(VectorTraits); | 450 STATIC_ONLY(VectorTraits); |
440 static const bool needsDestruction = false; | 451 static const bool needsDestruction = false; |
441 static const bool canInitializeWithMemset = true; | 452 static const bool canInitializeWithMemset = true; |
442 static const bool canClearUnusedSlotsWithMemset = true; | 453 static const bool canClearUnusedSlotsWithMemset = true; |
443 static const bool canMoveWithMemcpy = true; | 454 static const bool canMoveWithMemcpy = true; |
444 }; | 455 }; |
445 | 456 |
446 template <typename T> struct VectorTraits<blink::HeapDeque<T, 0>> : VectorTraits
Base<blink::HeapDeque<T, 0>> { | 457 template <typename T> struct VectorTraits<blink::HeapDeque<T, 0>> : VectorTraits
Base<blink::HeapDeque<T, 0>> { |
447 STATIC_ONLY(VectorTraits); | 458 STATIC_ONLY(VectorTraits); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 // regardless of whether they contain pointers to other heap allocated | 568 // regardless of whether they contain pointers to other heap allocated |
558 // objects. | 569 // objects. |
559 static const bool value = true; | 570 static const bool value = true; |
560 }; | 571 }; |
561 | 572 |
562 template<typename T, size_t inlineCapacity> | 573 template<typename T, size_t inlineCapacity> |
563 struct IsGarbageCollectedType<ListHashSetNode<T, blink::HeapListHashSetAllocator
<T, inlineCapacity>>> { | 574 struct IsGarbageCollectedType<ListHashSetNode<T, blink::HeapListHashSetAllocator
<T, inlineCapacity>>> { |
564 static const bool value = true; | 575 static const bool value = true; |
565 }; | 576 }; |
566 | 577 |
| 578 template<typename T, typename H> struct HandleHashTraits : SimpleClassHashTraits
<H> { |
| 579 STATIC_ONLY(HandleHashTraits); |
| 580 // TODO: The distinction between PeekInType and PassInType is there for |
| 581 // the sake of the reference counting handles. When they are gone the two |
| 582 // types can be merged into PassInType. |
| 583 // TODO: Implement proper const'ness for iterator types. Requires support |
| 584 // in the marking Visitor. |
| 585 using PeekInType = T*; |
| 586 using PassInType = T*; |
| 587 using IteratorGetType = H*; |
| 588 using IteratorConstGetType = const H*; |
| 589 using IteratorReferenceType = H&; |
| 590 using IteratorConstReferenceType = const H&; |
| 591 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { r
eturn *x; } |
| 592 static IteratorConstReferenceType getToReferenceConstConversion(IteratorCons
tGetType x) { return *x; } |
| 593 |
| 594 using PeekOutType = T*; |
| 595 |
| 596 template<typename U> |
| 597 static void store(const U& value, H& storage) { storage = value; } |
| 598 |
| 599 static PeekOutType peek(const H& value) { return value; } |
| 600 }; |
| 601 |
| 602 template<typename T> struct HashTraits<blink::Persistent<T>> : HandleHashTraits<
T, blink::Persistent<T>> { }; |
| 603 |
| 604 template<typename T> struct HashTraits<blink::CrossThreadPersistent<T>> : Handle
HashTraits<T, blink::CrossThreadPersistent<T>> { }; |
| 605 |
567 } // namespace WTF | 606 } // namespace WTF |
568 | 607 |
569 #endif | 608 #endif |
OLD | NEW |