MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / imalloc_sample

Function imalloc_sample

deps/memkind/src/jemalloc/src/jemalloc.c:1654–1683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1652}
1653
1654JEMALLOC_ALWAYS_INLINE void *
1655imalloc_sample(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd,
1656 size_t usize, szind_t ind) {
1657 void *ret;
1658
1659 /*
1660 * For small allocations, sampling bumps the usize. If so, we allocate
1661 * from the ind_large bucket.
1662 */
1663 szind_t ind_large;
1664 size_t bumped_usize = usize;
1665
1666 if (usize <= SMALL_MAXCLASS) {
1667 assert(((dopts->alignment == 0) ? sz_s2u(LARGE_MINCLASS) :
1668 sz_sa2u(LARGE_MINCLASS, dopts->alignment))
1669 == LARGE_MINCLASS);
1670 ind_large = sz_size2index(LARGE_MINCLASS);
1671 bumped_usize = sz_s2u(LARGE_MINCLASS);
1672 ret = imalloc_no_sample(sopts, dopts, tsd, bumped_usize,
1673 bumped_usize, ind_large);
1674 if (unlikely(ret == NULL)) {
1675 return NULL;
1676 }
1677 arena_prof_promote(tsd_tsdn(tsd), ret, usize);
1678 } else {
1679 ret = imalloc_no_sample(sopts, dopts, tsd, usize, usize, ind);
1680 }
1681
1682 return ret;
1683}
1684
1685/*
1686 * Returns true if the allocation will overflow, and false otherwise. Sets

Callers 1

imalloc_bodyFunction · 0.70

Calls 6

imalloc_no_sampleFunction · 0.70
arena_prof_promoteFunction · 0.70
sz_s2uFunction · 0.50
sz_sa2uFunction · 0.50
sz_size2indexFunction · 0.50
tsd_tsdnFunction · 0.50

Tested by

no test coverage detected