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 Address address = Heap::allocateOnHeapIndex(state, size, BlinkGC::Inline VectorHeapIndex, gcInfoIndex); |
| 66 const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T); | |
| 67 HeapAllocHooks::allocationHookIfEnabled(address, size, typeName); | |
|
sof
2016/02/23 09:13:02
Can you guarantee that this doesn't add a single e
hajimehoshi
2016/02/23 09:27:17
Yes. The actual hooks doesn't allocate any objects
Primiano Tucci (use gerrit)
2016/02/25 06:55:51
Is there any way we can make this future proof suc
hajimehoshi
2016/02/25 07:06:01
Good point. Such hooks should be in allocateOnHeap
hajimehoshi
2016/02/26 09:37:13
Done.
| |
| 68 return reinterpret_cast<T*>(address); | |
| 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::allocateOnHeapIndex(state, size, Blink GC::HashTableHeapIndex, gcInfoIndex)); | 79 Address address = Heap::allocateOnHeapIndex(state, size, BlinkGC::HashTa bleHeapIndex, gcInfoIndex); |
| 80 const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T); | |
| 81 HeapAllocHooks::allocationHookIfEnabled(address, size, typeName); | |
| 82 return reinterpret_cast<T*>(address); | |
| 77 } | 83 } |
| 78 template <typename T, typename HashTable> | 84 template <typename T, typename HashTable> |
| 79 static T* allocateZeroedHashTableBacking(size_t size) | 85 static T* allocateZeroedHashTableBacking(size_t size) |
| 80 { | 86 { |
| 81 return allocateHashTableBacking<T, HashTable>(size); | 87 return allocateHashTableBacking<T, HashTable>(size); |
| 82 } | 88 } |
| 83 static void freeHashTableBacking(void* address); | 89 static void freeHashTableBacking(void* address); |
| 84 static bool expandHashTableBacking(void*, size_t); | 90 static bool expandHashTableBacking(void*, size_t); |
| 85 | 91 |
| 86 template <typename Return, typename Metadata> | 92 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"); | 561 static_assert(sizeof(T), "T must be fully defined"); |
| 556 // All heap allocated node pointers need visiting to keep the nodes alive, | 562 // All heap allocated node pointers need visiting to keep the nodes alive, |
| 557 // regardless of whether they contain pointers to other heap allocated | 563 // regardless of whether they contain pointers to other heap allocated |
| 558 // objects. | 564 // objects. |
| 559 static const bool value = true; | 565 static const bool value = true; |
| 560 }; | 566 }; |
| 561 | 567 |
| 562 } // namespace WTF | 568 } // namespace WTF |
| 563 | 569 |
| 564 #endif | 570 #endif |
| OLD | NEW |