Index: Source/wtf/PartitionAlloc.cpp |
diff --git a/Source/wtf/PartitionAlloc.cpp b/Source/wtf/PartitionAlloc.cpp |
index d14559485d97aa50051843fc2c46b32762e0f7f5..a648854fc49d239c482461291831cb144871e6cb 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; |
+ size_t addr = reinterpret_cast<size_t>(ptr); |
Primiano Tucci (use gerrit)
2015/09/03 11:24:53
these should be uintptr_t, also + const (i.e. cons
Ruud van Asseldonk
2015/09/03 13:44:47
Sure, but note that the current code uses size_t.
|
+ size_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; |
+ size_t addr = reinterpret_cast<size_t>(ptr); |
Primiano Tucci (use gerrit)
2015/09/03 11:24:53
same here
|
+ size_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)) |
@@ -651,7 +655,7 @@ static ALWAYS_INLINE void partitionPageSetRawSize(PartitionPage* page, size_t si |
static ALWAYS_INLINE PartitionPage* partitionDirectMap(PartitionRootBase* root, int flags, size_t rawSize) |
{ |
- size_t size = partitionDirectMapSize(rawSize); |
+ size_t size = partitionRoundUpToSystemPage(rawSize); |
// Because we need to fake looking like a super page, we need to allocate |
// a bunch of system pages more than "size": |
@@ -976,7 +980,7 @@ bool partitionReallocDirectMappedInPlace(PartitionRootGeneric* root, PartitionPa |
// Note that the new size might be a bucketed size; this function is called |
// whenever we're reallocating a direct mapped allocation. |
- size_t newSize = partitionDirectMapSize(rawSize); |
+ size_t newSize = partitionRoundUpToSystemPage(rawSize); |
if (newSize < kGenericMinDirectMappedDownsize) |
return false; |
@@ -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; |