| Index: Source/platform/heap/HeapAllocator.h
|
| diff --git a/Source/platform/heap/HeapAllocator.h b/Source/platform/heap/HeapAllocator.h
|
| index b328dbdc593ca4ae56e561fbd74c8143c0252dd9..264fe1c32c5a5800c5399c1f2f366e4e4de367b9 100644
|
| --- a/Source/platform/heap/HeapAllocator.h
|
| +++ b/Source/platform/heap/HeapAllocator.h
|
| @@ -5,7 +5,9 @@
|
| #ifndef HeapAllocator_h
|
| #define HeapAllocator_h
|
|
|
| +#include "platform/heap/BufferAllocator.h"
|
| #include "platform/heap/Heap.h"
|
| +#include "platform/heap/ThreadState.h"
|
| #include "platform/heap/TraceTraits.h"
|
| #include "wtf/Assertions.h"
|
| #include "wtf/Atomics.h"
|
| @@ -28,14 +30,14 @@ public:
|
| using Visitor = blink::Visitor;
|
| static const bool isGarbageCollected = true;
|
|
|
| - template<typename T>
|
| - static size_t quantizedSize(size_t count)
|
| + static size_t quantizedSize(size_t count, size_t elementSize)
|
| {
|
| - RELEASE_ASSERT(count <= maxHeapObjectSize / sizeof(T));
|
| - return Heap::allocationSizeFromSize(count * sizeof(T)) - sizeof(HeapObjectHeader);
|
| + RELEASE_ASSERT(count <= maxHeapObjectSize / elementSize);
|
| + return Heap::allocationSizeFromSize(count * elementSize) - sizeof(HeapObjectHeader);
|
| }
|
| +
|
| template <typename T>
|
| - static T* allocateVectorBacking(size_t size)
|
| + static T* allocateVectorBacking(size_t size, void*)
|
| {
|
| ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
|
| ASSERT(state->isAllocationAllowed());
|
| @@ -44,7 +46,7 @@ public:
|
| return reinterpret_cast<T*>(heap->allocateObject(Heap::allocationSizeFromSize(size), gcInfoIndex));
|
| }
|
| template <typename T>
|
| - static T* allocateExpandedVectorBacking(size_t size)
|
| + static T* allocateExpandedVectorBacking(size_t size, void*)
|
| {
|
| ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
|
| ASSERT(state->isAllocationAllowed());
|
| @@ -56,7 +58,7 @@ public:
|
| static bool expandVectorBacking(void*, size_t);
|
| static bool shrinkVectorBacking(void* address, size_t quantizedCurrentSize, size_t quantizedShrunkSize);
|
| template <typename T>
|
| - static T* allocateInlineVectorBacking(size_t size)
|
| + static T* allocateInlineVectorBacking(size_t size, void*)
|
| {
|
| size_t gcInfoIndex = GCInfoTrait<HeapVectorBacking<T, VectorTraits<T>>>::index();
|
| ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
|
| @@ -67,16 +69,32 @@ public:
|
| static bool shrinkInlineVectorBacking(void* address, size_t quantizedCurrentSize, size_t quantizedShrunkSize);
|
|
|
| template <typename T, typename HashTable>
|
| - static T* allocateHashTableBacking(size_t size)
|
| + static T* allocateHashTableBacking(size_t size, void*)
|
| {
|
| + ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
|
| + ASSERT(state->isAllocationAllowed());
|
| size_t gcInfoIndex = GCInfoTrait<HeapHashTableBacking<HashTable>>::index();
|
| + NormalPageHeap* heap = static_cast<NormalPageHeap*>(state->hashTableBackingHeap(gcInfoIndex));
|
| + return reinterpret_cast<T*>(heap->allocateObject(Heap::allocationSizeFromSize(size), gcInfoIndex));
|
| + }
|
| + template <typename T, typename HashTable>
|
| + static T* allocateZeroedHashTableBacking(size_t size, void* holder)
|
| + {
|
| + return allocateHashTableBacking<T, HashTable>(size, holder);
|
| + }
|
| + template <typename T, typename HashTable>
|
| + static T* allocateExpandedHashTableBacking(size_t size, void*)
|
| + {
|
| ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
|
| - return reinterpret_cast<T*>(Heap::allocateOnHeapIndex(state, size, ThreadState::HashTableHeapIndex, gcInfoIndex));
|
| + ASSERT(state->isAllocationAllowed());
|
| + size_t gcInfoIndex = GCInfoTrait<HeapHashTableBacking<HashTable>>::index();
|
| + NormalPageHeap* heap = static_cast<NormalPageHeap*>(state->expandedHashTableBackingHeap(gcInfoIndex));
|
| + return reinterpret_cast<T*>(heap->allocateObject(Heap::allocationSizeFromSize(size), gcInfoIndex));
|
| }
|
| template <typename T, typename HashTable>
|
| - static T* allocateZeroedHashTableBacking(size_t size)
|
| + static T* allocateZeroedExpandedHashTableBacking(size_t size, void* holder)
|
| {
|
| - return allocateHashTableBacking<T, HashTable>(size);
|
| + return allocateExpandedHashTableBacking<T, HashTable>(size, holder);
|
| }
|
| static void freeHashTableBacking(void* address);
|
| static bool expandHashTableBacking(void*, size_t);
|
|
|