Skip to content

Commit 7919bd7

Browse files
committed
CI
1 parent 3ed5ee2 commit 7919bd7

File tree

12 files changed

+51
-56
lines changed

12 files changed

+51
-56
lines changed

src/snmalloc/backend_helpers/bitmap_coalesce_helpers.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ namespace snmalloc
3636
* of the servable-set DAG, which is determined by alignment-tier count
3737
* (B+1 tiers). For B=2: 1 incomparable pair -> 5 slots.
3838
*/
39-
static_assert(INTERMEDIATE_BITS == 2, "[A1] SLOTS_PER_EXPONENT=5 assumes B=2");
39+
static_assert(
40+
INTERMEDIATE_BITS == 2, "[A1] SLOTS_PER_EXPONENT=5 assumes B=2");
4041
static constexpr size_t SLOTS_PER_EXPONENT = 5;
4142

4243
/**
@@ -212,7 +213,8 @@ namespace snmalloc
212213
*
213214
* The bin_index function finds the highest bin the block qualifies for.
214215
*/
215-
static_assert(INTERMEDIATE_BITS == 2, "[A7] bin_index threshold logic assumes B=2");
216+
static_assert(
217+
INTERMEDIATE_BITS == 2, "[A7] bin_index threshold logic assumes B=2");
216218

217219
static constexpr size_t bin_index(size_t n_chunks, size_t alpha_chunks)
218220
{
@@ -261,7 +263,7 @@ namespace snmalloc
261263
size_t base_bit = exponent_base_bit(e);
262264

263265
// Size classes at this exponent:
264-
size_t s0 = size_t(1) << e; // m=0
266+
size_t s0 = size_t(1) << e; // m=0
265267
size_t s1 = 5 * (size_t(1) << (e - 2)); // m=1
266268
size_t s2 = 3 * (size_t(1) << (e - 1)); // m=2
267269
size_t s3 = 7 * (size_t(1) << (e - 2)); // m=3
@@ -315,8 +317,8 @@ namespace snmalloc
315317
// (e.g. if we can serve all 4 mantissas at e-1, that's slot
316318
// base_bit(e-1)+4 which could be > base_bit(e)+0).
317319
// Actually: base_bit(e)+0 = PREFIX_BITS + (e-2)*5,
318-
// base_bit(e-1)+4 = PREFIX_BITS + (e-3)*5 + 4 = PREFIX_BITS + (e-2)*5 - 1
319-
// So A-only at e is always > any slot at e-1. Return.
320+
// base_bit(e-1)+4 = PREFIX_BITS + (e-3)*5 + 4 = PREFIX_BITS + (e-2)*5
321+
// - 1 So A-only at e is always > any slot at e-1. Return.
320322
return candidate;
321323
}
322324
if (can_m1)

src/snmalloc/backend_helpers/bitmap_coalesce_range.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ namespace snmalloc
189189
bc.add_fresh_range(
190190
refill_range.unsafe_uintptr() + size, refill_size - size);
191191
}
192-
SNMALLOC_ASSERT(
193-
(refill_range.unsafe_uintptr() % alignment) == 0);
192+
SNMALLOC_ASSERT((refill_range.unsafe_uintptr() % alignment) == 0);
194193
}
195194
return refill_range;
196195
}
@@ -282,8 +281,7 @@ namespace snmalloc
282281
size_t sc_bytes = sc_chunks * MIN_CHUNK_SIZE;
283282

284283
// Required alignment: natural alignment for the rounded-up sizeclass.
285-
size_t sc_align =
286-
BC::natural_alignment(sc_chunks) * MIN_CHUNK_SIZE;
284+
size_t sc_align = BC::natural_alignment(sc_chunks) * MIN_CHUNK_SIZE;
287285

288286
auto result = bc.remove_block(sc_bytes);
289287
if (result.addr != 0)

src/snmalloc/backend_helpers/decayrange.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ namespace snmalloc
167167
* Maximum chunk size we cache (4 MiB).
168168
* Larger allocations bypass the cache and go directly to/from parent.
169169
*/
170-
static constexpr size_t MAX_CACHEABLE_SIZE =
171-
bits::one_at_bit(22);
170+
static constexpr size_t MAX_CACHEABLE_SIZE = bits::one_at_bit(22);
172171

173172
/**
174173
* How many slab sizes that can be cached.
@@ -177,7 +176,8 @@ namespace snmalloc
177176
*/
178177
static constexpr size_t NUM_SLAB_SIZES =
179178
bits::to_exp_mant_const<INTERMEDIATE_BITS, 0>(
180-
MAX_CACHEABLE_SIZE / MIN_CHUNK_SIZE) + 1;
179+
MAX_CACHEABLE_SIZE / MIN_CHUNK_SIZE) +
180+
1;
181181

182182
/**
183183
* Convert a byte size to the decay cache sizeclass index.

src/snmalloc/backend_helpers/pagemap.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,14 @@ namespace snmalloc
7474
* measured in nat_align units.
7575
*/
7676
SNMALLOC_FAST_PATH
77-
static void set_metaentry(
78-
address_t p, size_t size, const Entry& t, size_t nat_align)
77+
static void
78+
set_metaentry(address_t p, size_t size, const Entry& t, size_t nat_align)
7979
{
8080
size_t chunks_per_nat = nat_align / MIN_CHUNK_SIZE;
81-
size_t n_chunks = size / MIN_CHUNK_SIZE;
8281
SNMALLOC_ASSERT_MSG(
83-
(n_chunks / chunks_per_nat) <= 7,
82+
((size / MIN_CHUNK_SIZE) / chunks_per_nat) <= 7,
8483
"Offset {} exceeds 3-bit field for size {} nat_align {}",
85-
n_chunks / chunks_per_nat,
84+
(size / MIN_CHUNK_SIZE) / chunks_per_nat,
8685
size,
8786
nat_align);
8887
size_t chunk_index = 0;

src/snmalloc/mem/corealloc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,7 @@ namespace snmalloc
758758
};
759759

760760
// Stage 1: flush all smaller sizeclasses.
761-
if (self->large_object_cache.flush_smaller(
762-
sizeclass, flush_fn))
761+
if (self->large_object_cache.flush_smaller(sizeclass, flush_fn))
763762
{
764763
auto retry = Config::Backend::alloc_chunk(
765764
self->get_backend_local_state(),

src/snmalloc/mem/largecache.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ namespace snmalloc
5151
* Maximum chunk size we cache (4 MiB).
5252
* Larger allocations bypass the cache and go directly to/from backend.
5353
*/
54-
static constexpr size_t MAX_CACHEABLE_SIZE =
55-
bits::one_at_bit(22);
54+
static constexpr size_t MAX_CACHEABLE_SIZE = bits::one_at_bit(22);
5655

5756
/**
5857
* Number of chunk sizeclasses we actually cache.
@@ -355,9 +354,7 @@ namespace snmalloc
355354
bool flush_smaller(sizeclass_t sc, FlushFn&& flush_fn)
356355
{
357356
// If not cacheable, all cached entries are smaller.
358-
size_t target_idx = is_cacheable(sc) ?
359-
to_sizeclass(sc) :
360-
NUM_SIZECLASSES;
357+
size_t target_idx = is_cacheable(sc) ? to_sizeclass(sc) : NUM_SIZECLASSES;
361358
bool flushed = false;
362359
for (size_t i = 0; i < target_idx; i++)
363360
{

src/snmalloc/mem/metadata.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ namespace snmalloc
8181
* aligned, so bits 0–4 of the meta word are free for tagging.
8282
*/
8383
static constexpr unsigned META_OFFSET_SHIFT = 2;
84-
static constexpr address_t META_OFFSET_MASK = address_t(7) << META_OFFSET_SHIFT;
84+
static constexpr address_t META_OFFSET_MASK = address_t(7)
85+
<< META_OFFSET_SHIFT;
8586

8687
/**
8788
* Mask covering all reserved low bits in the meta word.

src/snmalloc/mem/sizeclasstable.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ namespace snmalloc
198198
size_t level = NUM_LARGE_FINE_LEVELS + (index - LARGE_FINE_TOTAL);
199199
em_index = MIN_LARGE_EM + level * LARGE_SUBS_PER_LEVEL;
200200
}
201-
size_t chunks =
202-
bits::from_exp_mant<INTERMEDIATE_BITS, 0>(em_index);
201+
size_t chunks = bits::from_exp_mant<INTERMEDIATE_BITS, 0>(em_index);
203202
return chunks * MIN_CHUNK_SIZE;
204203
}
205204

@@ -214,8 +213,7 @@ namespace snmalloc
214213
constexpr size_t size_to_large_class_index_const(size_t size)
215214
{
216215
size_t chunks = (size + MIN_CHUNK_SIZE - 1) / MIN_CHUNK_SIZE;
217-
size_t em =
218-
bits::to_exp_mant_const<INTERMEDIATE_BITS, 0>(chunks);
216+
size_t em = bits::to_exp_mant_const<INTERMEDIATE_BITS, 0>(chunks);
219217
size_t local_em = em - MIN_LARGE_EM;
220218

221219
if (local_em < LARGE_FINE_TOTAL)
@@ -239,8 +237,7 @@ namespace snmalloc
239237
{
240238
// Ceiling division to avoid truncation when size isn't chunk-aligned.
241239
size_t chunks = (size + MIN_CHUNK_SIZE - 1) / MIN_CHUNK_SIZE;
242-
size_t em =
243-
bits::to_exp_mant<INTERMEDIATE_BITS, 0>(chunks);
240+
size_t em = bits::to_exp_mant<INTERMEDIATE_BITS, 0>(chunks);
244241
size_t local_em = em - MIN_LARGE_EM;
245242

246243
if (local_em < LARGE_FINE_TOTAL)

src/test/func/bc_core/bc_core.cc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77

88
#include <cstring>
99
#include <iostream>
10-
#include <vector>
11-
1210
#include <snmalloc/snmalloc_core.h>
1311
#include <test/setup.h>
12+
#include <vector>
1413

1514
using namespace snmalloc;
1615

@@ -296,7 +295,7 @@ void test_remove_from_bin()
296295
// chunk 4 (addr = 4*MCS), alpha = 4
297296
// chunk 12 (addr = 12*MCS), alpha = 4 (12 = 4*3, natural_alignment = 4)
298297
// chunk 20 (addr = 20*MCS), alpha = 4 (20 = 4*5, natural_alignment = 4)
299-
address_t a1 = chunk_addr(3); // 4*MCS
298+
address_t a1 = chunk_addr(3); // 4*MCS
300299
address_t a2 = chunk_addr(11); // 12*MCS
301300
address_t a3 = chunk_addr(19); // 20*MCS
302301

@@ -475,7 +474,7 @@ void test_coalesce_both()
475474
BCCore bc{};
476475

477476
// Insert blocks A and C with a gap between.
478-
address_t a_addr = chunk_addr(3); // 4*MCS, 4 chunks
477+
address_t a_addr = chunk_addr(3); // 4*MCS, 4 chunks
479478
address_t c_addr = chunk_addr(11); // 12*MCS, 4 chunks
480479

481480
bc.add_fresh_range(a_addr, chunk_size(4));
@@ -572,8 +571,8 @@ void test_stale_tag_after_absorption()
572571
BCCore bc{};
573572

574573
// Insert A, B, C adjacent: chunks 4-7, 8-11, 12-15.
575-
address_t a_addr = chunk_addr(3); // 4*MCS
576-
address_t b_addr = chunk_addr(7); // 8*MCS
574+
address_t a_addr = chunk_addr(3); // 4*MCS
575+
address_t b_addr = chunk_addr(7); // 8*MCS
577576
address_t c_addr = chunk_addr(11); // 12*MCS
578577
bc.add_fresh_range(a_addr, chunk_size(4));
579578
bc.add_fresh_range(b_addr, chunk_size(4));
@@ -656,6 +655,7 @@ void test_stress()
656655
address_t addr;
657656
size_t size;
658657
};
658+
659659
std::vector<Alloc> live;
660660

661661
// Insert some initial blocks.
@@ -726,7 +726,8 @@ void test_carving_exact_fit()
726726
CHECK(result.addr == addr);
727727
CHECK(result.size == chunk_size(4));
728728

729-
// Carving: aligned_addr = align_up(addr, 4*MCS) = addr since addr is 4-aligned.
729+
// Carving: aligned_addr = align_up(addr, 4*MCS) = addr since addr is
730+
// 4-aligned.
730731
address_t aligned = bits::align_up(result.addr, chunk_size(4));
731732
CHECK(aligned == addr);
732733
// No prefix, no suffix.
@@ -757,8 +758,8 @@ void test_carving_with_prefix()
757758
size_t suffix = result.size - prefix - chunk_size(4);
758759

759760
CHECK(aligned == chunk_addr(3)); // 4*MCS
760-
CHECK(prefix == chunk_size(3)); // 3 chunks of prefix
761-
CHECK(suffix == chunk_size(1)); // 1 chunk of suffix
761+
CHECK(prefix == chunk_size(3)); // 3 chunks of prefix
762+
CHECK(suffix == chunk_size(1)); // 1 chunk of suffix
762763

763764
// Return remainders to the pool.
764765
if (prefix > 0)

src/test/func/bc_helpers/bc_helpers.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
*/
88

99
#include <iostream>
10-
#include <vector>
11-
1210
#include <snmalloc/snmalloc_core.h>
1311
#include <test/setup.h>
12+
#include <vector>
1413

1514
using namespace snmalloc;
1615

@@ -122,8 +121,10 @@ void test_decompose_roundtrip()
122121
}
123122

124123
// Invalid sizes should not decompose
125-
CHECK(!BC::decompose(0, *reinterpret_cast<size_t*>(&failure_count),
126-
*reinterpret_cast<size_t*>(&failure_count)));
124+
CHECK(!BC::decompose(
125+
0,
126+
*reinterpret_cast<size_t*>(&failure_count),
127+
*reinterpret_cast<size_t*>(&failure_count)));
127128
// 9 is not a valid size class (between 8 and 10 for B=2)
128129
size_t e_tmp, m_tmp;
129130
CHECK(!BC::decompose(9, e_tmp, m_tmp));
@@ -153,9 +154,9 @@ void test_is_valid_sizeclass()
153154
}
154155
if (BC::is_valid_sizeclass(s) != expected)
155156
{
156-
std::cout << " is_valid_sizeclass(" << s << ") = "
157-
<< BC::is_valid_sizeclass(s)
158-
<< ", expected " << expected << std::endl;
157+
std::cout << " is_valid_sizeclass(" << s
158+
<< ") = " << BC::is_valid_sizeclass(s) << ", expected "
159+
<< expected << std::endl;
159160
CHECK(false);
160161
}
161162
}

0 commit comments

Comments
 (0)