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/Persistent.h" |
10 #include "platform/heap/TraceTraits.h" | 10 #include "platform/heap/TraceTraits.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 // This is a static-only class used as a trait on collections to make them heap | 45 // This is a static-only class used as a trait on collections to make them heap |
46 // allocated. However see also HeapListHashSetAllocator. | 46 // allocated. However see also HeapListHashSetAllocator. |
47 class PLATFORM_EXPORT HeapAllocator { | 47 class PLATFORM_EXPORT HeapAllocator { |
48 STATIC_ONLY(HeapAllocator); | 48 STATIC_ONLY(HeapAllocator); |
49 | 49 |
50 public: | 50 public: |
51 using Visitor = blink::Visitor; | 51 using Visitor = blink::Visitor; |
52 static const bool isGarbageCollected = true; | 52 static const bool isGarbageCollected = true; |
53 | 53 |
54 template<typename T> | 54 template <typename T> |
55 static size_t maxElementCountInBackingStore() { | 55 static size_t maxElementCountInBackingStore() { |
56 return maxHeapObjectSize / sizeof(T); | 56 return maxHeapObjectSize / sizeof(T); |
57 } | 57 } |
58 | 58 |
59 template <typename T> | 59 template <typename T> |
60 static size_t quantizedSize(size_t count) { | 60 static size_t quantizedSize(size_t count) { |
61 CHECK(count <= maxElementCountInBackingStore<T>()); | 61 CHECK(count <= maxElementCountInBackingStore<T>()); |
62 return ThreadHeap::allocationSizeFromSize(count * sizeof(T)) - | 62 return ThreadHeap::allocationSizeFromSize(count * sizeof(T)) - |
63 sizeof(HeapObjectHeader); | 63 sizeof(HeapObjectHeader); |
64 } | 64 } |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 const blink::HeapHashCountedSet<Value, HashFunctions, Traits>& set, | 836 const blink::HeapHashCountedSet<Value, HashFunctions, Traits>& set, |
837 VectorType& vector) { | 837 VectorType& vector) { |
838 copyToVector(static_cast<const HashCountedSet<Value, HashFunctions, Traits, | 838 copyToVector(static_cast<const HashCountedSet<Value, HashFunctions, Traits, |
839 blink::HeapAllocator>&>(set), | 839 blink::HeapAllocator>&>(set), |
840 vector); | 840 vector); |
841 } | 841 } |
842 | 842 |
843 } // namespace WTF | 843 } // namespace WTF |
844 | 844 |
845 #endif | 845 #endif |
OLD | NEW |