Both byMetadata and byObject share same logic and can be refactored.
Created attachment 407860 [details] PATCH
Created attachment 407861 [details] PATCH
Created attachment 407890 [details] Fix debug build
Created attachment 407916 [details] Refactoring
Comment on attachment 407916 [details] Refactoring View in context: https://bugs.webkit.org/attachment.cgi?id=407916&action=review Can you run MallocBench to ensure that this does not affect on the performance? Because this code is super critical path in bmalloc. > Source/bmalloc/bmalloc/Heap.cpp:372 > +inline void allocateSmallBumpRangesInline( Let's put BINLINE since this is super critical path which we should ensure that this is always inlined regardless of compiler's decision. > Source/bmalloc/bmalloc/Heap.cpp:385 > + lineCache[page->sizeClass()].push(page); Let's pass sizeClass and use it. > Source/bmalloc/bmalloc/Heap.cpp:403 > + auto sizeClass = page->sizeClass(); Let's use passed sizeClass. > Source/bmalloc/bmalloc/Heap.h:172 > + allocateSmallBumpRangesByMetadata(lock, page, allocator, rangeCache, lineCache); > + else > + allocateSmallBumpRangesByObject(lock, page, allocator, rangeCache, lineCache); Let's just pass `sizeClass` too.
<rdar://problem/68534246>