mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 21:23:06 +00:00
Extract large-cacheable tcache check into tcache_can_cache_large
This commit is contained in:
@@ -203,9 +203,7 @@ arena_malloc(tsdn_t *tsdn, arena_t *arena, size_t size, szind_t ind, bool zero,
|
|||||||
assert(sz_can_use_slab(size));
|
assert(sz_can_use_slab(size));
|
||||||
return tcache_alloc_small(tsdn_tsd(tsdn), arena, tcache,
|
return tcache_alloc_small(tsdn_tsd(tsdn), arena, tcache,
|
||||||
size, ind, zero, slow_path);
|
size, ind, zero, slow_path);
|
||||||
} else if (likely(ind < tcache_nbins_get(tcache->tcache_slow)
|
} else if (likely(tcache_can_cache_large(tcache, ind))) {
|
||||||
&& !tcache_bin_disabled(ind, &tcache->bins[ind],
|
|
||||||
tcache->tcache_slow))) {
|
|
||||||
return tcache_alloc_large(tsdn_tsd(tsdn), arena, tcache,
|
return tcache_alloc_large(tsdn_tsd(tsdn), arena, tcache,
|
||||||
size, ind, zero, slow_path);
|
size, ind, zero, slow_path);
|
||||||
}
|
}
|
||||||
@@ -319,9 +317,7 @@ arena_dalloc_large(tsdn_t *tsdn, void *ptr, tcache_t *tcache, szind_t szind,
|
|||||||
if (unlikely(is_sample_promoted)) {
|
if (unlikely(is_sample_promoted)) {
|
||||||
arena_dalloc_promoted(tsdn, ptr, tcache, slow_path);
|
arena_dalloc_promoted(tsdn, ptr, tcache, slow_path);
|
||||||
} else {
|
} else {
|
||||||
if (szind < tcache_nbins_get(tcache->tcache_slow)
|
if (tcache_can_cache_large(tcache, szind)) {
|
||||||
&& !tcache_bin_disabled(
|
|
||||||
szind, &tcache->bins[szind], tcache->tcache_slow)) {
|
|
||||||
tcache_dalloc_large(
|
tcache_dalloc_large(
|
||||||
tsdn_tsd(tsdn), tcache, ptr, szind, slow_path);
|
tsdn_tsd(tsdn), tcache, ptr, szind, slow_path);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -86,6 +86,13 @@ tcache_bin_disabled(szind_t ind, cache_bin_t *bin, tcache_slow_t *tcache_slow) {
|
|||||||
return disabled;
|
return disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JEMALLOC_ALWAYS_INLINE bool
|
||||||
|
tcache_can_cache_large(tcache_t *tcache, szind_t ind) {
|
||||||
|
return ind < tcache_nbins_get(tcache->tcache_slow)
|
||||||
|
&& !tcache_bin_disabled(ind, &tcache->bins[ind],
|
||||||
|
tcache->tcache_slow);
|
||||||
|
}
|
||||||
|
|
||||||
JEMALLOC_ALWAYS_INLINE void *
|
JEMALLOC_ALWAYS_INLINE void *
|
||||||
tcache_alloc_small(tsd_t *tsd, arena_t *arena, tcache_t *tcache, size_t size,
|
tcache_alloc_small(tsd_t *tsd, arena_t *arena, tcache_t *tcache, size_t size,
|
||||||
szind_t binind, bool zero, bool slow_path) {
|
szind_t binind, bool zero, bool slow_path) {
|
||||||
|
|||||||
@@ -652,9 +652,7 @@ arena_dalloc_promoted_impl(
|
|||||||
}
|
}
|
||||||
szind_t bumped_ind = sz_size2index(bumped_usize);
|
szind_t bumped_ind = sz_size2index(bumped_usize);
|
||||||
if (bumped_usize >= SC_LARGE_MINCLASS && tcache != NULL
|
if (bumped_usize >= SC_LARGE_MINCLASS && tcache != NULL
|
||||||
&& bumped_ind < TCACHE_NBINS_MAX
|
&& tcache_can_cache_large(tcache, bumped_ind)) {
|
||||||
&& !tcache_bin_disabled(
|
|
||||||
bumped_ind, &tcache->bins[bumped_ind], tcache->tcache_slow)) {
|
|
||||||
tcache_dalloc_large(
|
tcache_dalloc_large(
|
||||||
tsdn_tsd(tsdn), tcache, ptr, bumped_ind, slow_path);
|
tsdn_tsd(tsdn), tcache, ptr, bumped_ind, slow_path);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user