| 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/TraceTraits.h" | 9 #include "platform/heap/TraceTraits.h" |
| 10 #include "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 return reinterpret_cast<T*>(arena->allocateObject(Heap::allocationSizeFr
omSize(size), gcInfoIndex)); | 55 return reinterpret_cast<T*>(arena->allocateObject(Heap::allocationSizeFr
omSize(size), gcInfoIndex)); |
| 56 } | 56 } |
| 57 static void freeVectorBacking(void*); | 57 static void freeVectorBacking(void*); |
| 58 static bool expandVectorBacking(void*, size_t); | 58 static bool expandVectorBacking(void*, size_t); |
| 59 static bool shrinkVectorBacking(void* address, size_t quantizedCurrentSize,
size_t quantizedShrunkSize); | 59 static bool shrinkVectorBacking(void* address, size_t quantizedCurrentSize,
size_t quantizedShrunkSize); |
| 60 template <typename T> | 60 template <typename T> |
| 61 static T* allocateInlineVectorBacking(size_t size) | 61 static T* allocateInlineVectorBacking(size_t size) |
| 62 { | 62 { |
| 63 size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T, VectorTraits<T>>>:
:index(); | 63 size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T, VectorTraits<T>>>:
:index(); |
| 64 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(
); | 64 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(
); |
| 65 using VectorType = HeapVectorBacking<T, VectorTraits<T>>; | 65 return reinterpret_cast<T*>(Heap::allocateOnArenaIndex(state, size, Blin
kGC::InlineVectorArenaIndex, gcInfoIndex)); |
| 66 const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(VectorType); | |
| 67 return reinterpret_cast<T*>(Heap::allocateOnArenaIndex(state, size, Blin
kGC::InlineVectorArenaIndex, gcInfoIndex, typeName)); | |
| 68 } | 66 } |
| 69 static void freeInlineVectorBacking(void*); | 67 static void freeInlineVectorBacking(void*); |
| 70 static bool expandInlineVectorBacking(void*, size_t); | 68 static bool expandInlineVectorBacking(void*, size_t); |
| 71 static bool shrinkInlineVectorBacking(void* address, size_t quantizedCurrent
Size, size_t quantizedShrunkSize); | 69 static bool shrinkInlineVectorBacking(void* address, size_t quantizedCurrent
Size, size_t quantizedShrunkSize); |
| 72 | 70 |
| 73 template <typename T, typename HashTable> | 71 template <typename T, typename HashTable> |
| 74 static T* allocateHashTableBacking(size_t size) | 72 static T* allocateHashTableBacking(size_t size) |
| 75 { | 73 { |
| 76 size_t gcInfoIndex = GCInfoTrait<HeapHashTableBacking<HashTable>>::index
(); | 74 size_t gcInfoIndex = GCInfoTrait<HeapHashTableBacking<HashTable>>::index
(); |
| 77 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(
); | 75 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(
); |
| 78 const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(HeapHashTableBacking<
HashTable>); | 76 return reinterpret_cast<T*>(Heap::allocateOnArenaIndex(state, size, Blin
kGC::HashTableArenaIndex, gcInfoIndex)); |
| 79 return reinterpret_cast<T*>(Heap::allocateOnArenaIndex(state, size, Blin
kGC::HashTableArenaIndex, gcInfoIndex, typeName)); | |
| 80 } | 77 } |
| 81 template <typename T, typename HashTable> | 78 template <typename T, typename HashTable> |
| 82 static T* allocateZeroedHashTableBacking(size_t size) | 79 static T* allocateZeroedHashTableBacking(size_t size) |
| 83 { | 80 { |
| 84 return allocateHashTableBacking<T, HashTable>(size); | 81 return allocateHashTableBacking<T, HashTable>(size); |
| 85 } | 82 } |
| 86 static void freeHashTableBacking(void* address); | 83 static void freeHashTableBacking(void* address); |
| 87 static bool expandHashTableBacking(void*, size_t); | 84 static bool expandHashTableBacking(void*, size_t); |
| 88 | 85 |
| 89 template <typename Return, typename Metadata> | 86 template <typename Return, typename Metadata> |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 static_assert(sizeof(T), "T must be fully defined"); | 555 static_assert(sizeof(T), "T must be fully defined"); |
| 559 // All heap allocated node pointers need visiting to keep the nodes alive, | 556 // All heap allocated node pointers need visiting to keep the nodes alive, |
| 560 // regardless of whether they contain pointers to other heap allocated | 557 // regardless of whether they contain pointers to other heap allocated |
| 561 // objects. | 558 // objects. |
| 562 static const bool value = true; | 559 static const bool value = true; |
| 563 }; | 560 }; |
| 564 | 561 |
| 565 } // namespace WTF | 562 } // namespace WTF |
| 566 | 563 |
| 567 #endif | 564 #endif |
| OLD | NEW |