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 {
284
284
}
285
285
};
286
286
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 ;
289
292
extern Metadata TaskAllocatorSlabMetadata;
290
293
291
294
using TaskAllocator = StackAllocator<SlabCapacity, &TaskAllocatorSlabMetadata>;
Original file line number Diff line number Diff line change @@ -109,8 +109,8 @@ class StackAllocator {
109
109
}
110
110
111
111
// / 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 );
114
114
}
115
115
116
116
// / Return \p size with the added overhead of the slab header.
@@ -276,6 +276,10 @@ class StackAllocator {
276
276
assert (getNumAllocatedSlabs () == 0 );
277
277
}
278
278
279
+ static constexpr size_t slabHeaderSize () {
280
+ return Slab::headerSize ();
281
+ }
282
+
279
283
// / Allocate a memory buffer of \p size.
280
284
void *alloc (size_t size) {
281
285
if (guardAllocations)
You can’t perform that action at this time.
0 commit comments