mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-22 19:02:13 +03:00
Remove build-time configuration 'config_limit_usize_gap'
This commit is contained in:
parent
852da1be15
commit
01e9ecbeb2
15 changed files with 160 additions and 244 deletions
|
|
@ -503,8 +503,7 @@ arena_sdalloc(tsdn_t *tsdn, void *ptr, size_t size, tcache_t *tcache,
|
|||
assert(alloc_ctx.slab == edata_slab_get(edata));
|
||||
emap_alloc_ctx_init(&alloc_ctx, alloc_ctx.szind, alloc_ctx.slab,
|
||||
sz_s2u(size));
|
||||
assert(!config_limit_usize_gap ||
|
||||
emap_alloc_ctx_usize_get(&alloc_ctx) ==
|
||||
assert(emap_alloc_ctx_usize_get(&alloc_ctx) ==
|
||||
edata_usize_get(edata));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -236,25 +236,16 @@ emap_alloc_ctx_init(emap_alloc_ctx_t *alloc_ctx, szind_t szind, bool slab,
|
|||
size_t usize) {
|
||||
alloc_ctx->szind = szind;
|
||||
alloc_ctx->slab = slab;
|
||||
/*
|
||||
* When config_limit_usize_gap disabled, alloc_ctx->usize
|
||||
* should not be accessed.
|
||||
*/
|
||||
if (config_limit_usize_gap) {
|
||||
alloc_ctx->usize = usize;
|
||||
assert(sz_limit_usize_gap_enabled() ||
|
||||
usize == sz_index2size(szind));
|
||||
} else if (config_debug) {
|
||||
alloc_ctx->usize = SC_LARGE_MAXCLASS + 1;
|
||||
}
|
||||
alloc_ctx->usize = usize;
|
||||
assert(sz_limit_usize_gap_enabled() ||
|
||||
usize == sz_index2size(szind));
|
||||
}
|
||||
|
||||
JEMALLOC_ALWAYS_INLINE size_t
|
||||
emap_alloc_ctx_usize_get(emap_alloc_ctx_t *alloc_ctx) {
|
||||
assert(alloc_ctx->szind < SC_NSIZES);
|
||||
if (!config_limit_usize_gap || alloc_ctx->slab) {
|
||||
assert(!config_limit_usize_gap ||
|
||||
alloc_ctx->usize == sz_index2size(alloc_ctx->szind));
|
||||
if (alloc_ctx->slab) {
|
||||
assert(alloc_ctx->usize == sz_index2size(alloc_ctx->szind));
|
||||
return sz_index2size(alloc_ctx->szind);
|
||||
}
|
||||
assert(sz_limit_usize_gap_enabled() ||
|
||||
|
|
@ -269,28 +260,15 @@ emap_alloc_ctx_lookup(tsdn_t *tsdn, emap_t *emap, const void *ptr,
|
|||
emap_alloc_ctx_t *alloc_ctx) {
|
||||
EMAP_DECLARE_RTREE_CTX;
|
||||
|
||||
if (config_limit_usize_gap) {
|
||||
rtree_contents_t contents = rtree_read(tsdn, &emap->rtree,
|
||||
rtree_ctx, (uintptr_t)ptr);
|
||||
/*
|
||||
* If the alloc is invalid, do not calculate usize since edata
|
||||
* could be corrupted.
|
||||
*/
|
||||
if (contents.metadata.szind == SC_NSIZES ||
|
||||
contents.edata == NULL) {
|
||||
emap_alloc_ctx_init(alloc_ctx, contents.metadata.szind,
|
||||
contents.metadata.slab, 0);
|
||||
return;
|
||||
}
|
||||
emap_alloc_ctx_init(alloc_ctx, contents.metadata.szind,
|
||||
contents.metadata.slab, edata_usize_get(contents.edata));
|
||||
} else {
|
||||
rtree_metadata_t metadata = rtree_metadata_read(tsdn,
|
||||
&emap->rtree, rtree_ctx, (uintptr_t)ptr);
|
||||
/* alloc_ctx->usize will not be read/write in this case. */
|
||||
emap_alloc_ctx_init(alloc_ctx, metadata.szind, metadata.slab,
|
||||
SC_LARGE_MAXCLASS + 1);
|
||||
}
|
||||
rtree_contents_t contents = rtree_read(tsdn, &emap->rtree,
|
||||
rtree_ctx, (uintptr_t)ptr);
|
||||
/*
|
||||
* If the alloc is invalid, do not calculate usize since edata
|
||||
* could be corrupted.
|
||||
*/
|
||||
emap_alloc_ctx_init(alloc_ctx, contents.metadata.szind,
|
||||
contents.metadata.slab, (contents.metadata.szind == SC_NSIZES
|
||||
|| contents.edata == NULL)? 0: edata_usize_get(contents.edata));
|
||||
}
|
||||
|
||||
/* The pointer must be mapped. */
|
||||
|
|
|
|||
|
|
@ -480,12 +480,6 @@
|
|||
/* If defined, use __int128 for optimization. */
|
||||
#undef JEMALLOC_HAVE_INT128
|
||||
|
||||
/*
|
||||
* If defined, the gap between any two contiguous usizes should not exceed
|
||||
* PAGE.
|
||||
*/
|
||||
#undef LIMIT_USIZE_GAP
|
||||
|
||||
#include "jemalloc/internal/jemalloc_internal_overrides.h"
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_DEFS_H_ */
|
||||
|
|
|
|||
|
|
@ -283,12 +283,4 @@ static const bool have_memcntl =
|
|||
#endif
|
||||
;
|
||||
|
||||
static const bool config_limit_usize_gap =
|
||||
#ifdef LIMIT_USIZE_GAP
|
||||
true
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
;
|
||||
|
||||
#endif /* JEMALLOC_PREAMBLE_H */
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@
|
|||
#endif
|
||||
|
||||
/*
|
||||
* When config_limit_usize_gap is enabled, the gaps between two contiguous
|
||||
* When limit_usize_gap is enabled, the gaps between two contiguous
|
||||
* size classes should not exceed PAGE. This means there should be no concept
|
||||
* of size classes for sizes > SC_SMALL_MAXCLASS (or >= SC_LARGE_MINCLASS).
|
||||
* However, between SC_LARGE_MINCLASS (SC_NGROUP * PAGE) and
|
||||
|
|
|
|||
|
|
@ -56,11 +56,7 @@ extern void sz_boot(const sc_data_t *sc_data, bool cache_oblivious);
|
|||
|
||||
JEMALLOC_ALWAYS_INLINE bool
|
||||
sz_limit_usize_gap_enabled() {
|
||||
#ifdef LIMIT_USIZE_GAP
|
||||
return opt_limit_usize_gap;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
JEMALLOC_ALWAYS_INLINE pszind_t
|
||||
|
|
@ -356,7 +352,7 @@ sz_s2u_compute(size_t size) {
|
|||
|
||||
JEMALLOC_ALWAYS_INLINE size_t
|
||||
sz_s2u_lookup(size_t size) {
|
||||
assert(!config_limit_usize_gap || size < SC_LARGE_MINCLASS);
|
||||
assert(size < SC_LARGE_MINCLASS);
|
||||
size_t ret = sz_index2size_lookup(sz_size2index_lookup(size));
|
||||
|
||||
assert(ret == sz_s2u_compute(size));
|
||||
|
|
|
|||
|
|
@ -19,11 +19,7 @@ typedef struct tcaches_s tcaches_t;
|
|||
/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
|
||||
#define TCACHES_ELM_NEED_REINIT ((tcache_t *)(uintptr_t)1)
|
||||
|
||||
#ifdef LIMIT_USIZE_GAP
|
||||
#define TCACHE_LG_MAXCLASS_LIMIT LG_USIZE_GROW_SLOW_THRESHOLD
|
||||
#else
|
||||
#define TCACHE_LG_MAXCLASS_LIMIT 23 /* tcache_max = 8M */
|
||||
#endif
|
||||
#define TCACHE_LG_MAXCLASS_LIMIT LG_USIZE_GROW_SLOW_THRESHOLD
|
||||
#define TCACHE_MAXCLASS_LIMIT ((size_t)1 << TCACHE_LG_MAXCLASS_LIMIT)
|
||||
#define TCACHE_NBINS_MAX (SC_NBINS + SC_NGROUP * \
|
||||
(TCACHE_LG_MAXCLASS_LIMIT - SC_LG_LARGE_MINCLASS) + 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue