| Index: Source/platform/heap/Heap.h
|
| diff --git a/Source/platform/heap/Heap.h b/Source/platform/heap/Heap.h
|
| index 0088c15fce8173262c05554c8cf0cbf0a7a8b031..ba2b34a99adc5eeca7de3a835262bb64ebfde951 100644
|
| --- a/Source/platform/heap/Heap.h
|
| +++ b/Source/platform/heap/Heap.h
|
| @@ -715,7 +715,6 @@ public:
|
|
|
| void addToFreeList(Address, size_t);
|
| void clear();
|
| - FreeListEntry* takeEntry(size_t allocationSize);
|
|
|
| // Returns a bucket number for inserting a FreeListEntry of a given size.
|
| // All FreeListEntries in the given bucket, n, have size >= 2^n.
|
| @@ -727,9 +726,7 @@ private:
|
| // All FreeListEntries in the nth list have size >= 2^n.
|
| FreeListEntry* m_freeLists[blinkPageSizeLog2];
|
|
|
| -#if ENABLE(ASSERT)
|
| friend class ThreadHeap<Header>;
|
| -#endif
|
| };
|
|
|
| // Thread heaps represent a part of the per-thread Blink heap.
|
| @@ -778,7 +775,7 @@ public:
|
| m_freeList.addToFreeList(address, size);
|
| }
|
|
|
| - inline Address allocate(size_t, const GCInfo*);
|
| + inline Address allocate(size_t payloadSize, const GCInfo*);
|
| inline static size_t roundedAllocationSize(size_t size)
|
| {
|
| return allocationSizeFromSize(size) - sizeof(Header);
|
| @@ -794,7 +791,7 @@ public:
|
|
|
| private:
|
| void addPageToHeap(const GCInfo*);
|
| - PLATFORM_EXPORT Address outOfLineAllocate(size_t payloadSize, size_t allocationSize, const GCInfo*);
|
| + PLATFORM_EXPORT Address outOfLineAllocate(size_t allocationSize, const GCInfo*);
|
| static size_t allocationSizeFromSize(size_t);
|
| PLATFORM_EXPORT Address allocateLargeObject(size_t, const GCInfo*);
|
| Address currentAllocationPoint() const { return m_currentAllocationPoint; }
|
| @@ -811,11 +808,14 @@ private:
|
| m_lastRemainingAllocationSize = m_remainingAllocationSize = size;
|
| }
|
| void updateRemainingAllocationSize();
|
| - bool allocateFromFreeList(size_t);
|
| + Address allocateFromFreeList(size_t, const GCInfo*);
|
|
|
| void freeLargeObject(LargeObject<Header>*, LargeObject<Header>**);
|
| void allocatePage(const GCInfo*);
|
|
|
| + inline Address allocateSize(size_t allocationSize, const GCInfo*);
|
| + inline Address allocateInto(Address, size_t allocationSize, const GCInfo*);
|
| +
|
| #if ENABLE(ASSERT)
|
| bool pagesToBeSweptContains(Address);
|
| bool pagesAllocatedDuringSweepingContains(Address);
|
| @@ -825,6 +825,8 @@ private:
|
| void sweepLargePages();
|
| bool coalesce(size_t);
|
|
|
| + Address allocateFromFreeListEntry(FreeListEntry*, size_t, const GCInfo*);
|
| +
|
| Address m_currentAllocationPoint;
|
| size_t m_remainingAllocationSize;
|
| size_t m_lastRemainingAllocationSize;
|
| @@ -1274,27 +1276,39 @@ size_t ThreadHeap<Header>::allocationSizeFromSize(size_t size)
|
| return allocationSize;
|
| }
|
|
|
| +
|
| template<typename Header>
|
| -Address ThreadHeap<Header>::allocate(size_t size, const GCInfo* gcInfo)
|
| +inline Address ThreadHeap<Header>::allocateInto(Address headerAddress, size_t allocationSize, const GCInfo* gcInfo)
|
| +{
|
| + new (NotNull, headerAddress) Header(allocationSize, gcInfo);
|
| + Address result = headerAddress + sizeof(Header);
|
| + ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask));
|
| +
|
| + // Unpoison the memory used for the object (payload).
|
| + ASAN_UNPOISON_MEMORY_REGION(result, allocationSize - sizeof(Header));
|
| +#if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER)
|
| + memset(result, 0, allocationSize - sizeof(Header));
|
| +#endif
|
| + ASSERT(pageFromAddress(headerAddress + allocationSize - 1));
|
| + return result;
|
| +}
|
| +
|
| +template<typename Header>
|
| +Address ThreadHeap<Header>::allocateSize(size_t allocationSize, const GCInfo* gcInfo)
|
| {
|
| - size_t allocationSize = allocationSizeFromSize(size);
|
| if (LIKELY(allocationSize <= m_remainingAllocationSize)) {
|
| Address headerAddress = m_currentAllocationPoint;
|
| m_currentAllocationPoint += allocationSize;
|
| m_remainingAllocationSize -= allocationSize;
|
| - new (NotNull, headerAddress) Header(allocationSize, gcInfo);
|
| - Address result = headerAddress + sizeof(Header);
|
| - ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask));
|
| -
|
| - // Unpoison the memory used for the object (payload).
|
| - ASAN_UNPOISON_MEMORY_REGION(result, allocationSize - sizeof(Header));
|
| -#if ENABLE(ASSERT) || defined(LEAK_SANITIZER) || defined(ADDRESS_SANITIZER)
|
| - memset(result, 0, allocationSize - sizeof(Header));
|
| -#endif
|
| - ASSERT(pageFromAddress(headerAddress + allocationSize - 1));
|
| - return result;
|
| + return allocateInto(headerAddress, allocationSize, gcInfo);
|
| }
|
| - return outOfLineAllocate(size, allocationSize, gcInfo);
|
| + return outOfLineAllocate(allocationSize, gcInfo);
|
| +}
|
| +
|
| +template<typename Header>
|
| +Address ThreadHeap<Header>::allocate(size_t size, const GCInfo* gcInfo)
|
| +{
|
| + return allocateSize(allocationSizeFromSize(size), gcInfo);
|
| }
|
|
|
| template<typename T, typename HeapTraits>
|
|
|