Chromium Code Reviews| 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*>(heap->allocateObject(Heap::allocationSizeFro mSize(size), gcInfoIndex)); | 55 return reinterpret_cast<T*>(heap->allocateObject(Heap::allocationSizeFro mSize(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::allocateOnHeapIndex(state, size, Blink GC::InlineVectorHeapIndex, gcInfoIndex)); | 65 const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T); |
|
sof
2016/03/03 08:37:30
That this is HeapVector<> backing store isn't enco
hajimehoshi
2016/03/03 10:12:31
I tried to pass HeapVectorBacking<T, VectorTraits<
sof
2016/03/03 12:08:14
"#define COMMA ," or a local 'using/typedef' alias
hajimehoshi
2016/03/04 06:39:14
Thanks. 'using' worked. Done.
| |
| 66 return reinterpret_cast<T*>(Heap::allocateOnHeapIndex(state, size, Blink GC::InlineVectorHeapIndex, gcInfoIndex, typeName)); | |
| 66 } | 67 } |
| 67 static void freeInlineVectorBacking(void*); | 68 static void freeInlineVectorBacking(void*); |
| 68 static bool expandInlineVectorBacking(void*, size_t); | 69 static bool expandInlineVectorBacking(void*, size_t); |
| 69 static bool shrinkInlineVectorBacking(void* address, size_t quantizedCurrent Size, size_t quantizedShrunkSize); | 70 static bool shrinkInlineVectorBacking(void* address, size_t quantizedCurrent Size, size_t quantizedShrunkSize); |
| 70 | 71 |
| 71 template <typename T, typename HashTable> | 72 template <typename T, typename HashTable> |
| 72 static T* allocateHashTableBacking(size_t size) | 73 static T* allocateHashTableBacking(size_t size) |
| 73 { | 74 { |
| 74 size_t gcInfoIndex = GCInfoTrait<HeapHashTableBacking<HashTable>>::index (); | 75 size_t gcInfoIndex = GCInfoTrait<HeapHashTableBacking<HashTable>>::index (); |
| 75 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state( ); | 76 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state( ); |
| 76 return reinterpret_cast<T*>(Heap::allocateOnHeapIndex(state, size, Blink GC::HashTableHeapIndex, gcInfoIndex)); | 77 const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T); |
|
sof
2016/03/03 08:37:30
Ditto, but for HeapHashTable<> backing store.
hajimehoshi
2016/03/03 10:12:31
Done.
| |
| 78 return reinterpret_cast<T*>(Heap::allocateOnHeapIndex(state, size, Blink GC::HashTableHeapIndex, gcInfoIndex, typeName)); | |
| 77 } | 79 } |
| 78 template <typename T, typename HashTable> | 80 template <typename T, typename HashTable> |
| 79 static T* allocateZeroedHashTableBacking(size_t size) | 81 static T* allocateZeroedHashTableBacking(size_t size) |
| 80 { | 82 { |
| 81 return allocateHashTableBacking<T, HashTable>(size); | 83 return allocateHashTableBacking<T, HashTable>(size); |
| 82 } | 84 } |
| 83 static void freeHashTableBacking(void* address); | 85 static void freeHashTableBacking(void* address); |
| 84 static bool expandHashTableBacking(void*, size_t); | 86 static bool expandHashTableBacking(void*, size_t); |
| 85 | 87 |
| 86 template <typename Return, typename Metadata> | 88 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"); | 557 static_assert(sizeof(T), "T must be fully defined"); |
| 556 // All heap allocated node pointers need visiting to keep the nodes alive, | 558 // All heap allocated node pointers need visiting to keep the nodes alive, |
| 557 // regardless of whether they contain pointers to other heap allocated | 559 // regardless of whether they contain pointers to other heap allocated |
| 558 // objects. | 560 // objects. |
| 559 static const bool value = true; | 561 static const bool value = true; |
| 560 }; | 562 }; |
| 561 | 563 |
| 562 } // namespace WTF | 564 } // namespace WTF |
| 563 | 565 |
| 564 #endif | 566 #endif |
| OLD | NEW |