MCPcopy Create free account
hub / github.com/beefytech/Beef / imalloc_sample

Function imalloc_sample

BeefRT/JEMalloc/src/jemalloc.c:2402–2434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2400}
2401
2402JEMALLOC_ALWAYS_INLINE void *
2403imalloc_sample(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd,
2404 size_t usize, szind_t ind) {
2405 void *ret;
2406
2407 /*
2408 * For small allocations, sampling bumps the usize. If so, we allocate
2409 * from the ind_large bucket.
2410 */
2411 szind_t ind_large;
2412 size_t bumped_usize = usize;
2413
2414 dopts->alignment = prof_sample_align(dopts->alignment);
2415 if (usize <= SC_SMALL_MAXCLASS) {
2416 assert(((dopts->alignment == 0) ?
2417 sz_s2u(SC_LARGE_MINCLASS) :
2418 sz_sa2u(SC_LARGE_MINCLASS, dopts->alignment))
2419 == SC_LARGE_MINCLASS);
2420 ind_large = sz_size2index(SC_LARGE_MINCLASS);
2421 bumped_usize = sz_s2u(SC_LARGE_MINCLASS);
2422 ret = imalloc_no_sample(sopts, dopts, tsd, bumped_usize,
2423 bumped_usize, ind_large);
2424 if (unlikely(ret == NULL)) {
2425 return NULL;
2426 }
2427 arena_prof_promote(tsd_tsdn(tsd), ret, usize);
2428 } else {
2429 ret = imalloc_no_sample(sopts, dopts, tsd, usize, usize, ind);
2430 }
2431 assert(prof_sample_aligned(ret));
2432
2433 return ret;
2434}
2435
2436/*
2437 * Returns true if the allocation will overflow, and false otherwise. Sets

Callers 1

imalloc_bodyFunction · 0.85

Calls 8

prof_sample_alignFunction · 0.85
sz_s2uFunction · 0.85
sz_sa2uFunction · 0.85
sz_size2indexFunction · 0.85
imalloc_no_sampleFunction · 0.85
arena_prof_promoteFunction · 0.85
tsd_tsdnFunction · 0.85
prof_sample_alignedFunction · 0.85

Tested by

no test coverage detected