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

Function imalloc_sample

deps/jemalloc/src/jemalloc.c:1953–1983  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1951}
1952
1953JEMALLOC_ALWAYS_INLINE void *
1954imalloc_sample(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd,
1955 size_t usize, szind_t ind) {
1956 void *ret;
1957
1958 /*
1959 * For small allocations, sampling bumps the usize. If so, we allocate
1960 * from the ind_large bucket.
1961 */
1962 szind_t ind_large;
1963 size_t bumped_usize = usize;
1964
1965 if (usize <= SC_SMALL_MAXCLASS) {
1966 assert(((dopts->alignment == 0) ?
1967 sz_s2u(SC_LARGE_MINCLASS) :
1968 sz_sa2u(SC_LARGE_MINCLASS, dopts->alignment))
1969 == SC_LARGE_MINCLASS);
1970 ind_large = sz_size2index(SC_LARGE_MINCLASS);
1971 bumped_usize = sz_s2u(SC_LARGE_MINCLASS);
1972 ret = imalloc_no_sample(sopts, dopts, tsd, bumped_usize,
1973 bumped_usize, ind_large);
1974 if (unlikely(ret == NULL)) {
1975 return NULL;
1976 }
1977 arena_prof_promote(tsd_tsdn(tsd), ret, usize);
1978 } else {
1979 ret = imalloc_no_sample(sopts, dopts, tsd, usize, usize, ind);
1980 }
1981
1982 return ret;
1983}
1984
1985/*
1986 * 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