summaryrefslogtreecommitdiffstats
path: root/include/jemalloc
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2014-11-01 00:08:13 (GMT)
committerJason Evans <jasone@canonware.com>2014-11-01 00:08:13 (GMT)
commit6da2e9d4f6fdccf5108296c99b2b839a4f474bae (patch)
treefe8fc5628fcb3e42aa8891d05d64964d039758e9 /include/jemalloc
parentdc652131110abb480df608d17b20cf5bd4cfe2d4 (diff)
downloadjemalloc-6da2e9d4f6fdccf5108296c99b2b839a4f474bae.zip
jemalloc-6da2e9d4f6fdccf5108296c99b2b839a4f474bae.tar.gz
jemalloc-6da2e9d4f6fdccf5108296c99b2b839a4f474bae.tar.bz2
Fix arena_sdalloc() to use promoted size.
Diffstat (limited to 'include/jemalloc')
-rw-r--r--include/jemalloc/internal/arena.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/include/jemalloc/internal/arena.h b/include/jemalloc/internal/arena.h
index 16c04d2..8782b19 100644
--- a/include/jemalloc/internal/arena.h
+++ b/include/jemalloc/internal/arena.h
@@ -1020,9 +1020,9 @@ arena_dalloc(tsd_t *tsd, arena_chunk_t *chunk, void *ptr, bool try_tcache)
assert(((uintptr_t)ptr & PAGE_MASK) == 0);
if (try_tcache && size <= tcache_maxclass && likely((tcache =
- tcache_get(tsd, false)) != NULL)) {
+ tcache_get(tsd, false)) != NULL))
tcache_dalloc_large(tcache, ptr, size);
- } else
+ else
arena_dalloc_large(chunk->arena, chunk, ptr);
}
}
@@ -1031,18 +1031,26 @@ JEMALLOC_ALWAYS_INLINE void
arena_sdalloc(tsd_t *tsd, arena_chunk_t *chunk, void *ptr, size_t size,
bool try_tcache)
{
+ index_t binind;
tcache_t *tcache;
assert(ptr != NULL);
assert(CHUNK_ADDR2BASE(ptr) != ptr);
+ if (config_prof && opt_prof) {
+ /* Use promoted size, not request size. */
+ size_t pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE;
+ binind = arena_mapbits_binind_get(chunk, pageind);
+ size = index2size(binind);
+ } else
+ binind = size2index(size);
+
if (likely(size <= SMALL_MAXCLASS)) {
/* Small allocation. */
if (likely(try_tcache) && likely((tcache = tcache_get(tsd,
- false)) != NULL)) {
- index_t binind = size2index(size);
+ false)) != NULL))
tcache_dalloc_small(tcache, ptr, binind);
- } else {
+ else {
size_t pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >>
LG_PAGE;
arena_dalloc_small(chunk->arena, chunk, ptr, pageind);
@@ -1051,9 +1059,9 @@ arena_sdalloc(tsd_t *tsd, arena_chunk_t *chunk, void *ptr, size_t size,
assert(((uintptr_t)ptr & PAGE_MASK) == 0);
if (try_tcache && size <= tcache_maxclass && (tcache =
- tcache_get(tsd, false)) != NULL) {
+ tcache_get(tsd, false)) != NULL)
tcache_dalloc_large(tcache, ptr, size);
- } else
+ else
arena_dalloc_large(chunk->arena, chunk, ptr);
}
}