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

Function ixallocx_prof

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

Source from the content-addressed store, hash-verified

2777}
2778
2779JEMALLOC_ALWAYS_INLINE size_t
2780ixallocx_prof(tsd_t *tsd, void *ptr, size_t old_usize, size_t size,
2781 size_t extra, size_t alignment, bool zero, alloc_ctx_t *alloc_ctx) {
2782 size_t usize_max, usize;
2783 bool prof_active;
2784 prof_tctx_t *old_tctx, *tctx;
2785
2786 prof_active = prof_active_get_unlocked();
2787 old_tctx = prof_tctx_get(tsd_tsdn(tsd), ptr, alloc_ctx);
2788 /*
2789 * usize isn't knowable before ixalloc() returns when extra is non-zero.
2790 * Therefore, compute its maximum possible value and use that in
2791 * prof_alloc_prep() to decide whether to capture a backtrace.
2792 * prof_realloc() will use the actual usize to decide whether to sample.
2793 */
2794 if (alignment == 0) {
2795 usize_max = sz_s2u(size+extra);
2796 assert(usize_max > 0 && usize_max <= LARGE_MAXCLASS);
2797 } else {
2798 usize_max = sz_sa2u(size+extra, alignment);
2799 if (unlikely(usize_max == 0 || usize_max > LARGE_MAXCLASS)) {
2800 /*
2801 * usize_max is out of range, and chances are that
2802 * allocation will fail, but use the maximum possible
2803 * value and carry on with prof_alloc_prep(), just in
2804 * case allocation succeeds.
2805 */
2806 usize_max = LARGE_MAXCLASS;
2807 }
2808 }
2809 tctx = prof_alloc_prep(tsd, usize_max, prof_active, false);
2810
2811 if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) {
2812 usize = ixallocx_prof_sample(tsd_tsdn(tsd), ptr, old_usize,
2813 size, extra, alignment, zero, tctx);
2814 } else {
2815 usize = ixallocx_helper(tsd_tsdn(tsd), ptr, old_usize, size,
2816 extra, alignment, zero);
2817 }
2818 if (usize == old_usize) {
2819 prof_alloc_rollback(tsd, tctx, false);
2820 return usize;
2821 }
2822 prof_realloc(tsd, ptr, usize, tctx, prof_active, false, ptr, old_usize,
2823 old_tctx);
2824
2825 return usize;
2826}
2827
2828JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW
2829je_xallocx(void *ptr, size_t size, size_t extra, int flags) {

Callers 1

je_xallocxFunction · 0.85

Calls 7

prof_active_get_unlockedFunction · 0.85
tsd_tsdnFunction · 0.85
sz_s2uFunction · 0.85
sz_sa2uFunction · 0.85
ixallocx_prof_sampleFunction · 0.85
ixallocx_helperFunction · 0.85
prof_reallocFunction · 0.85

Tested by

no test coverage detected