https://bugs.webkit.org/show_bug.cgi?id=151817
Reviewed by Geoffrey Garen.
Reduced the super chunk size from 4MB to 2MB.
Added path to reallocate() of an extra large object to see if we can extend the allocation.
* bmalloc/Allocator.cpp:
(bmalloc::Allocator::reallocate):
* bmalloc/SegregatedFreeList.h:
* bmalloc/Sizes.h:
* bmalloc/VMAllocate.h:
(bmalloc::tryVMAllocate):
(bmalloc::tryVMExtend):
(bmalloc::vmAllocate):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@193373
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-12-03 Michael Saboff <msaboff@apple.com>
+
+ bmalloc: extra large allocations could be more efficient
+ https://bugs.webkit.org/show_bug.cgi?id=151817
+
+ Reviewed by Geoffrey Garen.
+
+ Reduced the super chunk size from 4MB to 2MB.
+
+ Added path to reallocate() of an extra large object to see if we can extend the allocation.
+
+ * bmalloc/Allocator.cpp:
+ (bmalloc::Allocator::reallocate):
+ * bmalloc/SegregatedFreeList.h:
+ * bmalloc/Sizes.h:
+ * bmalloc/VMAllocate.h:
+ (bmalloc::tryVMAllocate):
+ (bmalloc::tryVMExtend):
+ (bmalloc::vmAllocate):
+
2015-11-11 Akos Kiss <akiss@inf.u-szeged.hu>
bmalloc: Add libdl dependency
Range& range = PerProcess<Heap>::getFastCase()->findXLarge(lock, object);
oldSize = range.size();
+ newSize = roundUpToMultipleOf<xLargeAlignment>(newSize);
+
+ if (newSize == oldSize)
+ return object;
+
if (newSize < oldSize && newSize > largeMax) {
newSize = roundUpToMultipleOf<xLargeAlignment>(newSize);
if (oldSize - newSize >= xLargeAlignment) {
}
return object;
}
+
+ if (newSize > oldSize) {
+ lock.unlock();
+ bool wasExtended = tryVMExtend(object, oldSize, newSize);
+ lock.lock();
+
+ if (wasExtended) {
+ range = Range(object, newSize);
+ return object;
+ }
+ }
break;
}
}
FreeList& select(size_t);
Owner m_owner;
- std::array<FreeList, 16> m_freeLists;
+ std::array<FreeList, 15> m_freeLists;
};
} // namespace bmalloc
#endif
static const size_t vmPageMask = ~(vmPageSize - 1);
- static const size_t superChunkSize = 4 * MB;
+ static const size_t superChunkSize = 2 * MB;
static const size_t smallMax = 256;
static const size_t smallLineSize = 256;
return result;
}
+inline bool tryVMExtend(void* p, size_t vmOldSize, size_t vmNewSize)
+{
+ vmValidate(vmOldSize);
+ vmValidate(vmNewSize);
+
+ BASSERT(vmOldSize < vmNewSize);
+
+ void* nextAddress = static_cast<char*>(p) + vmOldSize;
+ size_t extentionSize = vmNewSize - vmOldSize;
+
+ void* result = mmap(nextAddress, extentionSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, BMALLOC_VM_TAG, 0);
+
+ if (result == MAP_FAILED)
+ return false;
+
+ if (result != nextAddress) {
+ munmap(result, extentionSize);
+ return false;
+ }
+
+ return true;
+}
+
inline void* vmAllocate(size_t vmSize)
{
void* result = tryVMAllocate(vmSize);