2 #ifdef JEMALLOC_H_TYPES
4 typedef struct tcache_bin_info_s tcache_bin_info_t;
5 typedef struct tcache_bin_s tcache_bin_t;
6 typedef struct tcache_s tcache_t;
7 typedef struct tcaches_s tcaches_t;
14 #define TCACHE_STATE_DISABLED ((tcache_t *)(uintptr_t)1)
15 #define TCACHE_STATE_REINCARNATED ((tcache_t *)(uintptr_t)2)
16 #define TCACHE_STATE_PURGATORY ((tcache_t *)(uintptr_t)3)
17 #define TCACHE_STATE_MAX TCACHE_STATE_PURGATORY
22 #define TCACHE_NSLOTS_SMALL_MIN 20
31 #define TCACHE_NSLOTS_SMALL_MAX 200
34 #define TCACHE_NSLOTS_LARGE 20
37 #define LG_TCACHE_MAXCLASS_DEFAULT 15
44 #define TCACHE_GC_SWEEP 8192
47 #define TCACHE_GC_INCR \
48 ((TCACHE_GC_SWEEP / JM_NBINS) + ((TCACHE_GC_SWEEP / JM_NBINS == 0) ? 0 : 1))
52 #ifdef JEMALLOC_H_STRUCTS
55 tcache_enabled_false = 0,
56 tcache_enabled_true = 1,
57 tcache_enabled_default = 2
64 struct tcache_bin_info_s {
69 tcache_bin_stats_t tstats;
88 tcache_bin_t tbins[1];
107 #ifdef JEMALLOC_H_EXTERNS
136 tcache_bin_t *tbin,
szind_t binind,
bool *tcache_success);
140 unsigned rem, tcache_t *tcache);
142 arena_t *oldarena, arena_t *newarena);
158 #ifdef JEMALLOC_H_INLINES
160 #ifndef JEMALLOC_ENABLE_INLINE
172 szind_t binind,
bool slow_path);
174 size_t size,
bool slow_path);
178 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_TCACHE_C_))
194 tcache_enabled_t tcache_enabled;
200 if (tcache_enabled == tcache_enabled_default) {
201 tcache_enabled = (tcache_enabled_t)
opt_tcache;
205 return ((
bool)tcache_enabled);
212 tcache_enabled_t tcache_enabled;
218 tcache_enabled = (tcache_enabled_t)enabled;
248 if (TCACHE_GC_INCR == 0)
261 tbin->low_water = -1;
262 *tcache_success =
false;
272 *tcache_success =
true;
273 ret = *(tbin->avail - tbin->ncached);
276 if (
unlikely((
int)tbin->ncached < tbin->low_water))
277 tbin->low_water = tbin->ncached;
284 szind_t binind,
bool zero,
bool slow_path)
289 size_t usize JEMALLOC_CC_SILENCE_INIT(0);
294 tbin = &tcache->tbins[binind];
301 bool tcache_hard_success;
307 tbin, binind, &tcache_hard_success);
308 if (tcache_hard_success ==
false)
341 tbin->tstats.nrequests++;
343 tcache->prof_accumbytes += usize;
350 szind_t binind,
bool zero,
bool slow_path)
358 tbin = &tcache->tbins[binind];
377 size_t usize JEMALLOC_CC_SILENCE_INIT(0);
387 arena_chunk_t *
chunk =
388 (arena_chunk_t *)CHUNK_ADDR2BASE(ret);
397 memset(ret, JEMALLOC_ALLOC_JUNK,
406 tbin->tstats.nrequests++;
408 tcache->prof_accumbytes += usize;
420 tcache_bin_info_t *tbin_info;
427 tbin = &tcache->tbins[binind];
429 if (
unlikely(tbin->ncached == tbin_info->ncached_max)) {
431 (tbin_info->ncached_max >> 1));
433 assert(tbin->ncached < tbin_info->ncached_max);
435 *(tbin->avail - tbin->ncached) = ptr;
446 tcache_bin_info_t *tbin_info;
457 tbin = &tcache->tbins[binind];
459 if (
unlikely(tbin->ncached == tbin_info->ncached_max)) {
461 (tbin_info->ncached_max >> 1), tcache);
464 assert(tbin->ncached < tbin_info->ncached_max);
466 *(tbin->avail - tbin->ncached) = ptr;
479 return (elm->tcache);
static RzBuffer * create(RzBin *bin, const ut8 *code, int codelen, const ut8 *data, int datalen, RzBinArchOptions *opt)
static static fork const void static count static fd link
static const bool config_stats
arena_t * arena_choose(tsd_t *tsd, arena_t *arena)
szind_t size2index(size_t size)
static const bool config_prof
static const bool config_tcache
size_t index2size(szind_t index)
static const bool config_fill
#define JEMALLOC_ALWAYS_INLINE
return memset(p, 0, total)
assert(limit<=UINT32_MAX/2)
#define arena_mapbits_large_binind_set
#define arena_alloc_junk_small
#define tcache_alloc_small
#define tcache_event_hard
#define arena_dalloc_junk_large
#define tcache_dalloc_large
#define tcache_postfork_child
#define arena_malloc_large
#define tcache_stats_merge
#define tcache_alloc_large
#define arena_dalloc_junk_small
#define tcache_bin_flush_large
#define tcache_postfork_parent
#define tsd_tcache_enabled_get
#define opt_lg_tcache_max
#define tcache_alloc_easy
#define tcache_enabled_set
#define tcache_bin_flush_small
#define tcache_enabled_cleanup
#define tcache_alloc_small_hard
#define tsd_tcache_enabled_set
#define tcache_dalloc_small
#define tcache_arena_reassociate
#define tcache_enabled_get
_W64 unsigned int uintptr_t