| Index: Source/wtf/PartitionAlloc.cpp
|
| diff --git a/Source/wtf/PartitionAlloc.cpp b/Source/wtf/PartitionAlloc.cpp
|
| index d14559485d97aa50051843fc2c46b32762e0f7f5..9fd79e0bad176d5d60ce0c716c9e447d136b9946 100644
|
| --- a/Source/wtf/PartitionAlloc.cpp
|
| +++ b/Source/wtf/PartitionAlloc.cpp
|
| @@ -509,14 +509,18 @@ static ALWAYS_INLINE void partitionPageSetup(PartitionPage* page, PartitionBucke
|
| }
|
| }
|
|
|
| -static ALWAYS_INLINE size_t partitionRoundUpToSystemPage(size_t size)
|
| +static ALWAYS_INLINE char* partitionAlignUpToSystemPage(char* ptr)
|
| {
|
| - return (size + kSystemPageOffsetMask) & kSystemPageBaseMask;
|
| + const uintptr_t addr = reinterpret_cast<uintptr_t>(ptr);
|
| + const uintptr_t alignedAddr = (addr + kSystemPageOffsetMask) & kSystemPageBaseMask;
|
| + return reinterpret_cast<char*>(alignedAddr);
|
| }
|
|
|
| -static ALWAYS_INLINE size_t partitionRoundDownToSystemPage(size_t size)
|
| +static ALWAYS_INLINE char* partitionAlignDownToSystemPage(char* ptr)
|
| {
|
| - return size & kSystemPageBaseMask;
|
| + const uintptr_t addr = reinterpret_cast<uintptr_t>(ptr);
|
| + const uintptr_t alignedAddr = addr & kSystemPageBaseMask;
|
| + return reinterpret_cast<char*>(alignedAddr);
|
| }
|
|
|
| static ALWAYS_INLINE char* partitionPageAllocAndFillFreelist(PartitionPage* page)
|
| @@ -540,7 +544,7 @@ static ALWAYS_INLINE char* partitionPageAllocAndFillFreelist(PartitionPage* page
|
| // Our goal is to fault as few system pages as possible. We calculate the
|
| // page containing the "end" of the returned slot, and then allow freelist
|
| // pointers to be written up to the end of that page.
|
| - char* subPageLimit = reinterpret_cast<char*>(partitionRoundUpToSystemPage(reinterpret_cast<size_t>(firstFreelistPointer)));
|
| + char* subPageLimit = partitionAlignUpToSystemPage(firstFreelistPointer);
|
| char* slotsLimit = returnObject + (size * numSlots);
|
| char* freelistLimit = subPageLimit;
|
| if (UNLIKELY(slotsLimit < freelistLimit))
|
| @@ -1143,10 +1147,10 @@ static size_t partitionPurgePage(PartitionPage* page, bool discard)
|
| if (truncatedSlots) {
|
| beginPtr = ptr + (numSlots * slotSize);
|
| endPtr = beginPtr + (slotSize * truncatedSlots);
|
| - beginPtr = reinterpret_cast<char*>(partitionRoundUpToSystemPage(reinterpret_cast<size_t>(beginPtr)));
|
| + beginPtr = partitionAlignUpToSystemPage(beginPtr);
|
| // We round the end pointer here up and not down because we're at the
|
| // end of a slot span, so we "own" all the way up the page boundary.
|
| - endPtr = reinterpret_cast<char*>(partitionRoundUpToSystemPage(reinterpret_cast<size_t>(endPtr)));
|
| + endPtr = partitionAlignUpToSystemPage(endPtr);
|
| ASSERT(endPtr <= ptr + partitionBucketBytes(bucket));
|
| if (beginPtr < endPtr) {
|
| unprovisionedBytes = endPtr - beginPtr;
|
| @@ -1190,8 +1194,8 @@ static size_t partitionPurgePage(PartitionPage* page, bool discard)
|
| char* endPtr = beginPtr + slotSize;
|
| if (i != lastSlot)
|
| beginPtr += sizeof(PartitionFreelistEntry);
|
| - beginPtr = reinterpret_cast<char*>(partitionRoundUpToSystemPage(reinterpret_cast<size_t>(beginPtr)));
|
| - endPtr = reinterpret_cast<char*>(partitionRoundDownToSystemPage(reinterpret_cast<size_t>(endPtr)));
|
| + beginPtr = partitionAlignUpToSystemPage(beginPtr);
|
| + endPtr = partitionAlignDownToSystemPage(endPtr);
|
| if (beginPtr < endPtr) {
|
| size_t partialSlotBytes = endPtr - beginPtr;
|
| discardableBytes += partialSlotBytes;
|
|
|