| Index: Source/platform/heap/Heap.h
|
| diff --git a/Source/platform/heap/Heap.h b/Source/platform/heap/Heap.h
|
| index 0b1e891d2f1e70a9d12b7d8407b2456f3a5896f9..41b02d2d0b060e34c77c82472a1b8495eb26d74d 100644
|
| --- a/Source/platform/heap/Heap.h
|
| +++ b/Source/platform/heap/Heap.h
|
| @@ -911,7 +911,9 @@ private:
|
| ASSERT(!point || heapPageFromAddress(point));
|
| ASSERT(size <= HeapPage<Header>::payloadSize());
|
| m_currentAllocationPoint = point;
|
| - m_remainingAllocationSize = size;
|
| + if (m_lastRemainingAllocationSize != m_remainingAllocationSize)
|
| + stats().increaseObjectSpace(m_lastRemainingAllocationSize-m_remainingAllocationSize);
|
| + m_lastRemainingAllocationSize = m_remainingAllocationSize = size;
|
| }
|
| void ensureCurrentAllocation(size_t, const GCInfo*);
|
| bool allocateFromFreeList(size_t);
|
| @@ -930,6 +932,7 @@ private:
|
|
|
| Address m_currentAllocationPoint;
|
| size_t m_remainingAllocationSize;
|
| + size_t m_lastRemainingAllocationSize;
|
|
|
| HeapPage<Header>* m_firstPage;
|
| LargeHeapObject<Header>* m_firstLargeHeapObject;
|
| @@ -1454,26 +1457,24 @@ template<typename Header>
|
| Address ThreadHeap<Header>::allocate(size_t size, const GCInfo* gcInfo)
|
| {
|
| size_t allocationSize = allocationSizeFromSize(size);
|
| - bool isLargeObject = allocationSize > blinkPageSize / 2;
|
| - if (isLargeObject)
|
| - return allocateLargeObject(allocationSize, gcInfo);
|
| - if (m_remainingAllocationSize < allocationSize)
|
| - return outOfLineAllocate(size, gcInfo);
|
| - Address headerAddress = m_currentAllocationPoint;
|
| - m_currentAllocationPoint += allocationSize;
|
| - m_remainingAllocationSize -= allocationSize;
|
| - Header* header = new (NotNull, headerAddress) Header(allocationSize, gcInfo);
|
| - size_t payloadSize = allocationSize - sizeof(Header);
|
| - stats().increaseObjectSpace(payloadSize);
|
| - 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, payloadSize);
|
| + if (allocationSize <= m_remainingAllocationSize) {
|
| + Address headerAddress = m_currentAllocationPoint;
|
| + m_currentAllocationPoint += allocationSize;
|
| + m_remainingAllocationSize -= allocationSize;
|
| + Header* header = 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, payloadSize);
|
| + memset(result, 0, allocationSize - sizeof(Header));
|
| #endif
|
| - ASSERT(heapPageFromAddress(headerAddress + allocationSize - 1));
|
| - return result;
|
| + ASSERT(heapPageFromAddress(headerAddress + allocationSize - 1));
|
| + return result;
|
| + }
|
| + ASSERT(allocationSize > m_remainingAllocationSize);
|
| + return outOfLineAllocate(size, gcInfo);
|
| }
|
|
|
| template<typename T, typename HeapTraits>
|
|
|