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

Function irallocx_prof

deps/jemalloc/src/jemalloc.c:3173–3211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3171}
3172
3173JEMALLOC_ALWAYS_INLINE void *
3174irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
3175 size_t alignment, size_t *usize, bool zero, tcache_t *tcache,
3176 arena_t *arena, alloc_ctx_t *alloc_ctx, hook_ralloc_args_t *hook_args) {
3177 void *p;
3178 bool prof_active;
3179 prof_tctx_t *old_tctx, *tctx;
3180
3181 prof_active = prof_active_get_unlocked();
3182 old_tctx = prof_tctx_get(tsd_tsdn(tsd), old_ptr, alloc_ctx);
3183 tctx = prof_alloc_prep(tsd, *usize, prof_active, false);
3184 if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) {
3185 p = irallocx_prof_sample(tsd_tsdn(tsd), old_ptr, old_usize,
3186 *usize, alignment, zero, tcache, arena, tctx, hook_args);
3187 } else {
3188 p = iralloct(tsd_tsdn(tsd), old_ptr, old_usize, size, alignment,
3189 zero, tcache, arena, hook_args);
3190 }
3191 if (unlikely(p == NULL)) {
3192 prof_alloc_rollback(tsd, tctx, false);
3193 return NULL;
3194 }
3195
3196 if (p == old_ptr && alignment != 0) {
3197 /*
3198 * The allocation did not move, so it is possible that the size
3199 * class is smaller than would guarantee the requested
3200 * alignment, and that the alignment constraint was
3201 * serendipitously satisfied. Additionally, old_usize may not
3202 * be the same as the current usize because of in-place large
3203 * reallocation. Therefore, query the actual value of usize.
3204 */
3205 *usize = isalloc(tsd_tsdn(tsd), p);
3206 }
3207 prof_realloc(tsd, p, *usize, tctx, prof_active, false, old_ptr,
3208 old_usize, old_tctx);
3209
3210 return p;
3211}
3212
3213JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
3214void JEMALLOC_NOTHROW *

Callers 1

jemalloc.cFile · 0.70

Calls 6

irallocx_prof_sampleFunction · 0.70
prof_active_get_unlockedFunction · 0.50
tsd_tsdnFunction · 0.50
iralloctFunction · 0.50
isallocFunction · 0.50
prof_reallocFunction · 0.50

Tested by

no test coverage detected