diff options
author | Qi Wang <interwq@gwu.edu> | 2017-04-11 21:56:43 (GMT) |
---|---|---|
committer | Qi Wang <interwq@gmail.com> | 2017-04-12 20:55:39 (GMT) |
commit | f35213bae4ee6294a0743607637f9be8989622f1 (patch) | |
tree | cb3b98eaca799929779537081447448d1cd6d3a0 /src | |
parent | e709fae1d73b874796d7f629ef39a44e9b53fa87 (diff) | |
download | jemalloc-f35213bae4ee6294a0743607637f9be8989622f1.zip jemalloc-f35213bae4ee6294a0743607637f9be8989622f1.tar.gz jemalloc-f35213bae4ee6294a0743607637f9be8989622f1.tar.bz2 |
Pass dalloc_ctx down the sdalloc path.
This avoids redundant rtree lookups.
Diffstat (limited to 'src')
-rw-r--r-- | src/arena.c | 2 | ||||
-rw-r--r-- | src/jemalloc.c | 13 | ||||
-rw-r--r-- | src/large.c | 2 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/arena.c b/src/arena.c index 5d313e3..16728b3 100644 --- a/src/arena.c +++ b/src/arena.c @@ -1752,7 +1752,7 @@ arena_ralloc(tsdn_t *tsdn, arena_t *arena, void *ptr, size_t oldsize, size_t copysize = (usize < oldsize) ? usize : oldsize; memcpy(ret, ptr, copysize); - isdalloct(tsdn, ptr, oldsize, tcache, true); + isdalloct(tsdn, ptr, oldsize, tcache, NULL, true); return ret; } diff --git a/src/jemalloc.c b/src/jemalloc.c index 77ee857..e71949a 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -2083,17 +2083,26 @@ isfree(tsd_t *tsd, void *ptr, size_t usize, tcache_t *tcache, bool slow_path) { assert(ptr != NULL); assert(malloc_initialized() || IS_INITIALIZER); + dalloc_ctx_t dalloc_ctx, *ctx; if (config_prof && opt_prof) { + rtree_ctx_t *rtree_ctx = tsd_rtree_ctx(tsd); + rtree_szind_slab_read(tsd_tsdn(tsd), &extents_rtree, rtree_ctx, + (uintptr_t)ptr, true, &dalloc_ctx.szind, &dalloc_ctx.slab); + assert(dalloc_ctx.szind == size2index(usize)); prof_free(tsd, ptr, usize); + ctx = &dalloc_ctx; + } else { + ctx = NULL; } + if (config_stats) { *tsd_thread_deallocatedp_get(tsd) += usize; } if (likely(!slow_path)) { - isdalloct(tsd_tsdn(tsd), ptr, usize, tcache, false); + isdalloct(tsd_tsdn(tsd), ptr, usize, tcache, ctx, false); } else { - isdalloct(tsd_tsdn(tsd), ptr, usize, tcache, true); + isdalloct(tsd_tsdn(tsd), ptr, usize, tcache, ctx, true); } } diff --git a/src/large.c b/src/large.c index 18987c1..3b53eb3 100644 --- a/src/large.c +++ b/src/large.c @@ -304,7 +304,7 @@ large_ralloc(tsdn_t *tsdn, arena_t *arena, extent_t *extent, size_t usize, size_t copysize = (usize < oldusize) ? usize : oldusize; memcpy(ret, extent_addr_get(extent), copysize); - isdalloct(tsdn, extent_addr_get(extent), oldusize, tcache, true); + isdalloct(tsdn, extent_addr_get(extent), oldusize, tcache, NULL, true); return ret; } |