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