OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 HeapTerminatedArray_h | 5 #ifndef HeapTerminatedArray_h |
6 #define HeapTerminatedArray_h | 6 #define HeapTerminatedArray_h |
7 | 7 |
8 #include "platform/heap/Heap.h" | 8 #include "platform/heap/Heap.h" |
9 #include "wtf/TerminatedArray.h" | 9 #include "wtf/TerminatedArray.h" |
10 #include "wtf/TerminatedArrayBuilder.h" | 10 #include "wtf/TerminatedArrayBuilder.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 private: | 27 private: |
28 // Allocator describes how HeapTerminatedArrayBuilder should create new inta
nces | 28 // Allocator describes how HeapTerminatedArrayBuilder should create new inta
nces |
29 // of TerminateArray and manage their lifetimes. | 29 // of TerminateArray and manage their lifetimes. |
30 struct Allocator final { | 30 struct Allocator final { |
31 STATIC_ONLY(Allocator); | 31 STATIC_ONLY(Allocator); |
32 typedef HeapTerminatedArray* PassPtr; | 32 typedef HeapTerminatedArray* PassPtr; |
33 typedef RawPtr<HeapTerminatedArray> Ptr; | 33 typedef RawPtr<HeapTerminatedArray> Ptr; |
34 | 34 |
35 static PassPtr create(size_t capacity) | 35 static PassPtr create(size_t capacity) |
36 { | 36 { |
37 return reinterpret_cast<HeapTerminatedArray*>(ThreadHeap::allocate<H
eapTerminatedArray>(capacity * sizeof(T), IsEagerlyFinalizedType<T>::value)); | 37 return reinterpret_cast<HeapTerminatedArray*>(Heap::allocate<HeapTer
minatedArray>(capacity * sizeof(T), IsEagerlyFinalizedType<T>::value)); |
38 } | 38 } |
39 | 39 |
40 static PassPtr resize(PassPtr ptr, size_t capacity) | 40 static PassPtr resize(PassPtr ptr, size_t capacity) |
41 { | 41 { |
42 return reinterpret_cast<HeapTerminatedArray*>(ThreadHeap::reallocate
<HeapTerminatedArray>(ptr, capacity * sizeof(T))); | 42 return reinterpret_cast<HeapTerminatedArray*>(Heap::reallocate<HeapT
erminatedArray>(ptr, capacity * sizeof(T))); |
43 } | 43 } |
44 }; | 44 }; |
45 | 45 |
46 // Prohibit construction. Allocator makes HeapTerminatedArray instances for | 46 // Prohibit construction. Allocator makes HeapTerminatedArray instances for |
47 // HeapTerminatedArrayBuilder by pointer casting. | 47 // HeapTerminatedArrayBuilder by pointer casting. |
48 HeapTerminatedArray(); | 48 HeapTerminatedArray(); |
49 | 49 |
50 template<typename U, template <typename> class> friend class WTF::Terminated
ArrayBuilder; | 50 template<typename U, template <typename> class> friend class WTF::Terminated
ArrayBuilder; |
51 }; | 51 }; |
52 | 52 |
53 template<typename T> | 53 template<typename T> |
54 class TraceEagerlyTrait<HeapTerminatedArray<T>> { | 54 class TraceEagerlyTrait<HeapTerminatedArray<T>> { |
55 public: | 55 public: |
56 static const bool value = TraceEagerlyTrait<T>::value; | 56 static const bool value = TraceEagerlyTrait<T>::value; |
57 }; | 57 }; |
58 | 58 |
59 } // namespace blink | 59 } // namespace blink |
60 | 60 |
61 #endif // HeapTerminatedArray_h | 61 #endif // HeapTerminatedArray_h |
OLD | NEW |