44#include " ../ds_core/sizeclassconfig.h"
55#include " ../stl/array.h"
66#include " ../stl/utility.h"
7- #include " backend_arena_bins .h"
7+ #include " arenabins .h"
88
99#include < stddef.h>
1010#include < stdint.h>
1111
1212namespace snmalloc
1313{
14- struct BackendArenaTestAccess ;
14+ struct ArenaTestAccess ;
1515
1616 /* *
1717 * Size encoding for a free block's first pagemap entry.
@@ -21,7 +21,7 @@ namespace snmalloc
2121 * placed in a size-1 bin (cannot serve aligned size-2 requests).
2222 * Large: 3+ chunks; precise size stored in a separate entry.
2323 */
24- enum class BackendArenaVariant : uint8_t
24+ enum class ArenaVariant : uint8_t
2525 {
2626 Min = 0 ,
2727 EvenTwo = 1 ,
@@ -45,7 +45,7 @@ namespace snmalloc
4545 * - `using RangeRep` — full RBTree Rep for the range tree, same
4646 * shape as `BinRep`.
4747 * - `get_variant(addr)` / `set_variant(addr, v)` — the
48- * `BackendArenaVariant ` tag for the block starting at `addr`.
48+ * `ArenaVariant ` tag for the block starting at `addr`.
4949 * - `get_large_size(addr)` / `set_large_size(addr, size)` —
5050 * exact byte size for `Large` blocks (3+ units).
5151 * - `can_consolidate(higher_addr) -> bool` — whether the block at
@@ -62,7 +62,7 @@ namespace snmalloc
6262 * returned to the caller.
6363 */
6464 template <typename Rep, size_t MIN_SIZE_BITS , size_t MAX_SIZE_BITS >
65- class BackendArena
65+ class Arena
6666 {
6767 static_assert (MAX_SIZE_BITS > MIN_SIZE_BITS );
6868 static_assert (MAX_SIZE_BITS < bits::BITS );
@@ -72,7 +72,7 @@ namespace snmalloc
7272 static constexpr size_t TWO_UNITS = size_t (2 ) << MIN_SIZE_BITS ;
7373
7474 static constexpr size_t B = 2 ;
75- using Bins = BackendArenaBins <B, MIN_SIZE_BITS >;
75+ using Bins = ArenaBins <B, MIN_SIZE_BITS >;
7676
7777 static_assert (
7878 bits::one_at_bit (MAX_SIZE_BITS ) - 1 <= Bins::max_supported_size());
@@ -89,15 +89,15 @@ namespace snmalloc
8989
9090 // ---- Metadata helpers ----
9191
92- static BackendArenaVariant variant_of (size_t size, uintptr_t addr)
92+ static ArenaVariant variant_of (size_t size, uintptr_t addr)
9393 {
9494 if (size == UNIT_SIZE )
95- return BackendArenaVariant ::Min;
95+ return ArenaVariant ::Min;
9696 if (size == TWO_UNITS )
9797 return ((addr >> MIN_SIZE_BITS ) & 1 ) == 0 ?
98- BackendArenaVariant ::EvenTwo :
99- BackendArenaVariant ::OddTwo;
100- return BackendArenaVariant ::Large;
98+ ArenaVariant ::EvenTwo :
99+ ArenaVariant ::OddTwo;
100+ return ArenaVariant ::Large;
101101 }
102102
103103 static stl::Pair<uintptr_t , size_t > range_from_addr (uintptr_t a)
@@ -107,12 +107,12 @@ namespace snmalloc
107107 auto v = Rep::get_variant (a);
108108 switch (v)
109109 {
110- case BackendArenaVariant ::Min:
110+ case ArenaVariant ::Min:
111111 return {a, UNIT_SIZE };
112- case BackendArenaVariant ::EvenTwo:
113- case BackendArenaVariant ::OddTwo:
112+ case ArenaVariant ::EvenTwo:
113+ case ArenaVariant ::OddTwo:
114114 return {a, TWO_UNITS };
115- case BackendArenaVariant ::Large:
115+ case ArenaVariant ::Large:
116116 {
117117 size_t s = Rep::get_large_size (a);
118118 SNMALLOC_ASSERT (
@@ -129,7 +129,7 @@ namespace snmalloc
129129 {
130130 auto path = bin_trees[0 ].get_root_path ();
131131 return bin_trees[0 ].find (path, a) &&
132- Rep::get_variant (a) == BackendArenaVariant ::Min;
132+ Rep::get_variant (a) == ArenaVariant ::Min;
133133 }
134134
135135 void insert_block (uintptr_t addr, size_t size)
@@ -156,12 +156,12 @@ namespace snmalloc
156156 bitmap.clear (bin);
157157 }
158158
159- friend struct BackendArenaTestAccess ;
159+ friend struct ArenaTestAccess ;
160160
161161 public:
162162 using addr_t = uintptr_t ;
163163
164- constexpr BackendArena () = default;
164+ constexpr Arena () = default;
165165
166166 /* *
167167 * Add a free block at `addr` with `size` bytes. The block is
@@ -179,7 +179,7 @@ namespace snmalloc
179179 // Unit alignment is required: callers feeding parent ranges (e.g.
180180 // mmap-backed PalRange returns page-aligned but not chunk-aligned
181181 // memory) must trim their input to UNIT_SIZE before reaching here.
182- // BackendArenaRange ::add_range does this trim.
182+ // LargeArenaRange ::add_range does this trim.
183183 SNMALLOC_ASSERT ((addr & (UNIT_SIZE - 1 )) == 0 );
184184 SNMALLOC_ASSERT (size > 0 );
185185 SNMALLOC_ASSERT ((size & (UNIT_SIZE - 1 )) == 0 );
@@ -348,7 +348,7 @@ namespace snmalloc
348348 uintptr_t prev = 0 ;
349349 bool prev_valid = false ;
350350 bin_trees[0 ].for_each ([&](uintptr_t node) {
351- if (Rep::get_variant (node) != BackendArenaVariant ::Min)
351+ if (Rep::get_variant (node) != ArenaVariant ::Min)
352352 return ;
353353 if (prev_valid)
354354 SNMALLOC_CHECK (
@@ -414,7 +414,7 @@ namespace snmalloc
414414 auto v = Rep::get_variant (node);
415415 auto [a, s] = range_from_addr (node);
416416 SNMALLOC_CHECK (v == variant_of (s, a));
417- if (v == BackendArenaVariant ::Large)
417+ if (v == ArenaVariant ::Large)
418418 SNMALLOC_CHECK (Rep::get_large_size (node) == s);
419419 });
420420 }
0 commit comments