MCPcopy Create free account
hub / github.com/F-Stack/f-stack / imalloc_sample

Function imalloc_sample

app/redis-6.2.6/deps/jemalloc/src/jemalloc.c:1713–1742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1711}
1712
1713JEMALLOC_ALWAYS_INLINE void *
1714imalloc_sample(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd,
1715 size_t usize, szind_t ind) {
1716 void *ret;
1717
1718 /*
1719 * For small allocations, sampling bumps the usize. If so, we allocate
1720 * from the ind_large bucket.
1721 */
1722 szind_t ind_large;
1723 size_t bumped_usize = usize;
1724
1725 if (usize <= SMALL_MAXCLASS) {
1726 assert(((dopts->alignment == 0) ? sz_s2u(LARGE_MINCLASS) :
1727 sz_sa2u(LARGE_MINCLASS, dopts->alignment))
1728 == LARGE_MINCLASS);
1729 ind_large = sz_size2index(LARGE_MINCLASS);
1730 bumped_usize = sz_s2u(LARGE_MINCLASS);
1731 ret = imalloc_no_sample(sopts, dopts, tsd, bumped_usize,
1732 bumped_usize, ind_large);
1733 if (unlikely(ret == NULL)) {
1734 return NULL;
1735 }
1736 arena_prof_promote(tsd_tsdn(tsd), ret, usize);
1737 } else {
1738 ret = imalloc_no_sample(sopts, dopts, tsd, usize, usize, ind);
1739 }
1740
1741 return ret;
1742}
1743
1744/*
1745 * Returns true if the allocation will overflow, and false otherwise. Sets

Callers 1

imalloc_bodyFunction · 0.85

Calls 6

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

Tested by

no test coverage detected