File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -284,8 +284,11 @@ class alignas(sizeof(void*) * 2) ActiveTaskStatus {
284284 }
285285};
286286
287- // / The size of an allocator slab.
288- static constexpr size_t SlabCapacity = 1000 ;
287+ // / The size of an allocator slab. We want the full allocation to fit into a
288+ // / 1024-byte malloc quantum. We subtract off the slab header size, plus a
289+ // / little extra to stay within our limits even when there's overhead from
290+ // / malloc stack logging.
291+ static constexpr size_t SlabCapacity = 1024 - StackAllocator<0 , nullptr >::slabHeaderSize() - 8 ;
289292extern Metadata TaskAllocatorSlabMetadata;
290293
291294using TaskAllocator = StackAllocator<SlabCapacity, &TaskAllocatorSlabMetadata>;
Original file line number Diff line number Diff line change @@ -109,8 +109,8 @@ class StackAllocator {
109109 }
110110
111111 // / The size of the slab header.
112- static size_t headerSize () {
113- return llvm::alignTo (sizeof (Slab), llvm::Align ( alignment) );
112+ static constexpr size_t headerSize () {
113+ return (sizeof (Slab) + alignment - 1 ) & ~(alignment - 1 );
114114 }
115115
116116 // / Return \p size with the added overhead of the slab header.
@@ -276,6 +276,10 @@ class StackAllocator {
276276 assert (getNumAllocatedSlabs () == 0 );
277277 }
278278
279+ static constexpr size_t slabHeaderSize () {
280+ return Slab::headerSize ();
281+ }
282+
279283 // / Allocate a memory buffer of \p size.
280284 void *alloc (size_t size) {
281285 if (guardAllocations)
You can’t perform that action at this time.
0 commit comments