Skip to content

Commit 0a4294e

Browse files
authored
common: define kMiniHeapSize and use it in MeshableArena's CheapHeap (#108)
1 parent bc5cbe2 commit 0a4294e

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/common.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ static constexpr int kMapShared = 1;
6969
static constexpr int kMapShared = kMeshingEnabled ? MAP_SHARED : MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE;
7070
#endif
7171

72+
// we have to define this here for use in meshable_arena's CheapHeap we allocate
73+
// MiniHeaps out of. We validate (and fail compilation) if this gets out of date
74+
// with a static_assert at the bottom of mini_heap.h
75+
static constexpr size_t kMiniHeapSize = 64;
76+
7277
static constexpr size_t kMinObjectSize = 16;
7378
static constexpr size_t kMaxSize = 16384;
7479
static constexpr size_t kClassSizesMax = 25;

src/meshable_arena.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class MeshableArena : public mesh::OneWayMmapHeap {
277277
atomic<MiniHeapID> *_mhIndex{nullptr};
278278

279279
protected:
280-
CheapHeap<64, kArenaSize / kPageSize> _mhAllocator{};
280+
CheapHeap<kMiniHeapSize, kArenaSize / kPageSize> _mhAllocator{};
281281
MWC _fastPrng;
282282

283283
private:

src/mini_heap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ typedef FixedArray<MiniHeap, 63> MiniHeapArray;
526526
static_assert(sizeof(pid_t) == 4, "pid_t not 32-bits!");
527527
static_assert(sizeof(mesh::internal::Bitmap) == 32, "Bitmap too big!");
528528
static_assert(sizeof(MiniHeap) == 64, "MiniHeap too big!");
529+
static_assert(sizeof(MiniHeap) == kMiniHeapSize, "MiniHeap size mismatch");
529530
static_assert(sizeof(MiniHeapArray) == 64 * sizeof(void *), "MiniHeapArray too big!");
530531
} // namespace mesh
531532

0 commit comments

Comments
 (0)