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;
13 #define TCACHE_STATE_DISABLED ((tcache_t *)(uintptr_t)1)
14 #define TCACHE_STATE_REINCARNATED ((tcache_t *)(uintptr_t)2)
15 #define TCACHE_STATE_PURGATORY ((tcache_t *)(uintptr_t)3)
16 #define TCACHE_STATE_MAX TCACHE_STATE_PURGATORY
25 #define TCACHE_NSLOTS_SMALL_MAX 200
28 #define TCACHE_NSLOTS_LARGE 20
31 #define LG_TCACHE_MAXCLASS_DEFAULT 15
38 #define TCACHE_GC_SWEEP 8192
41 #define TCACHE_GC_INCR \
42 ((TCACHE_GC_SWEEP / NBINS) + ((TCACHE_GC_SWEEP / NBINS == 0) ? 0 : 1))
46 #ifdef JEMALLOC_H_STRUCTS
49 tcache_enabled_false = 0,
50 tcache_enabled_true = 1,
51 tcache_enabled_default = 2
58 struct tcache_bin_info_s {
63 tcache_bin_stats_t tstats;
76 tcache_bin_t tbins[1];
87 #ifdef JEMALLOC_H_EXTERNS
122 #ifdef JEMALLOC_H_INLINES
124 #ifndef JEMALLOC_ENABLE_INLINE
125 malloc_tsd_protos(JEMALLOC_ATTR(unused), tcache, tcache_t *)
126 malloc_tsd_protos(JEMALLOC_ATTR(unused), tcache_enabled, tcache_enabled_t)
140 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_TCACHE_C_))
147 malloc_tsd_funcs(JEMALLOC_ALWAYS_INLINE, tcache_enabled, tcache_enabled_t,
168 tcache_enabled_t tcache_enabled;
173 if (tcache_enabled == tcache_enabled_default) {
174 tcache_enabled = (tcache_enabled_t)opt_tcache;
178 return ((
bool)tcache_enabled);
184 tcache_enabled_t tcache_enabled;
189 tcache_enabled = (tcache_enabled_t)enabled;
193 if (tcache == TCACHE_STATE_DISABLED) {
198 if (tcache > TCACHE_STATE_MAX) {
202 if (tcache == NULL) {
203 tcache = TCACHE_STATE_DISABLED;
209 JEMALLOC_ALWAYS_INLINE tcache_t *
221 if (tcache == TCACHE_STATE_DISABLED)
223 if (tcache == NULL) {
224 if (create ==
false) {
244 if (tcache == TCACHE_STATE_PURGATORY) {
249 tcache = TCACHE_STATE_REINCARNATED;
253 if (tcache == TCACHE_STATE_REINCARNATED)
261 JEMALLOC_ALWAYS_INLINE
void
265 if (TCACHE_GC_INCR == 0)
269 assert(tcache->ev_cnt <= TCACHE_GC_INCR);
270 if (tcache->ev_cnt == TCACHE_GC_INCR)
274 JEMALLOC_ALWAYS_INLINE
void *
279 if (tbin->ncached == 0) {
280 tbin->low_water = -1;
284 if ((
int)tbin->ncached < tbin->low_water)
285 tbin->low_water = tbin->ncached;
286 ret = tbin->avail[tbin->ncached];
290 JEMALLOC_ALWAYS_INLINE
void *
297 binind = SMALL_SIZE2BIN(size);
298 assert(binind < NBINS);
299 tbin = &tcache->tbins[binind];
315 memset(ret, 0, size);
324 memset(ret, 0, size);
328 tbin->tstats.nrequests++;
335 JEMALLOC_ALWAYS_INLINE
void *
343 assert(size <= tcache_maxclass);
344 binind = NBINS + (size >>
LG_PAGE) - 1;
345 assert(binind < nhbins);
346 tbin = &tcache->tbins[binind];
358 arena_chunk_t *
chunk =
359 (arena_chunk_t *)CHUNK_ADDR2BASE(ret);
368 memset(ret, 0xa5, size);
370 memset(ret, 0, size);
375 memset(ret, 0, size);
379 tbin->tstats.nrequests++;
381 tcache->prof_accumbytes += size;
388 JEMALLOC_ALWAYS_INLINE
void
392 tcache_bin_info_t *tbin_info;
399 tbin = &tcache->tbins[binind];
400 tbin_info = &tcache_bin_info[binind];
401 if (tbin->ncached == tbin_info->ncached_max) {
405 assert(tbin->ncached < tbin_info->ncached_max);
406 tbin->avail[tbin->ncached] = ptr;
412 JEMALLOC_ALWAYS_INLINE
void
417 tcache_bin_info_t *tbin_info;
423 binind = NBINS + (size >>
LG_PAGE) - 1;
426 memset(ptr, 0x5a, size);
428 tbin = &tcache->tbins[binind];
429 tbin_info = &tcache_bin_info[binind];
430 if (tbin->ncached == tbin_info->ncached_max) {
434 assert(tbin->ncached < tbin_info->ncached_max);
435 tbin->avail[tbin->ncached] = ptr;
#define tcache_salloc
Definition: private_namespace.h:390
#define malloc_tsd_no_cleanup
Definition: private_namespace.h:249
#define tcache_arena_associate
Definition: private_namespace.h:360
#define PAGE_CEILING(s)
Definition: jemalloc_internal.h:364
#define JEMALLOC_INLINE
Definition: jemalloc_internal.h:259
#define tcache_stats_merge
Definition: private_namespace.h:391
static const bool config_stats
Definition: jemalloc_internal.h:141
#define opt_tcache
Definition: private_namespace.h:280
#define tcache_flush
Definition: private_namespace.h:386
#define tcache_bin_flush_large
Definition: private_namespace.h:362
#define tcache_event_hard
Definition: private_namespace.h:385
#define tcache_destroy
Definition: private_namespace.h:371
arena_t NULL
Definition: jemalloc_internal.h:624
#define tcache_enabled_tsd_get
Definition: private_namespace.h:380
JEMALLOC_INLINE arena_t * choose_arena(arena_t *arena)
Definition: jemalloc_internal.h:734
#define tcache_thread_cleanup
Definition: private_namespace.h:392
#define arena_bin_info
Definition: private_namespace.h:6
#define ql_elm(a_type)
Definition: ql.h:11
#define tcache_get
Definition: private_namespace.h:387
#define tcache_event
Definition: private_namespace.h:384
#define isthreaded
Definition: private_namespace.h:229
static const bool config_fill
Definition: jemalloc_internal.h:92
#define tcache_dalloc_large
Definition: private_namespace.h:369
_W64 unsigned int uintptr_t
Definition: stdint.h:119
#define tcache_alloc_small_hard
Definition: private_namespace.h:359
static const bool config_tcache
Definition: jemalloc_internal.h:148
#define tcache_maxclass
Definition: private_namespace.h:389
unsigned __int64 uint64_t
Definition: stdint.h:90
#define tcache_boot1
Definition: private_namespace.h:366
#define tcache_tsd_get
Definition: private_namespace.h:397
#define prof_promote
Definition: private_namespace.h:306
#define nhbins
Definition: private_namespace.h:260
#define tcache_boot0
Definition: private_namespace.h:365
#define LG_PAGE
Definition: jemalloc_internal.h:359
#define tcache_alloc_large
Definition: private_namespace.h:357
#define PAGE_MASK
Definition: jemalloc_internal.h:361
#define JEMALLOC_ALWAYS_INLINE
Definition: jemalloc_internal.h:256
internal::NamedArg< char > arg(StringRef name, const T &arg)
Definition: format.h:3248
static const bool config_prof
Definition: jemalloc_internal.h:106
malloc_tsd_externs(arenas, arena_t *) malloc_tsd_funcs(JEMALLOC_ALWAYS_INLINE
#define tcache_create
Definition: private_namespace.h:368
#define arena_dalloc_junk_small
Definition: private_namespace.h:12
static unorm16 zero()
Definition: unorm16.h:82
#define tcache_arena_dissociate
Definition: private_namespace.h:361
#define tcache_alloc_small
Definition: private_namespace.h:358
#define tcache_alloc_easy
Definition: private_namespace.h:356
#define tcache_enabled_get
Definition: private_namespace.h:373
#define tcache_enabled_set
Definition: private_namespace.h:375
#define arena_mapbits_large_binind_set
Definition: private_namespace.h:25
#define opt_lg_tcache_max
Definition: private_namespace.h:268
#define VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr, _qzz_len)
Definition: jemalloc_internal.h:464
static const bool config_lazy_lock
Definition: jemalloc_internal.h:99
#define tcache_dalloc_small
Definition: private_namespace.h:370
#define tcache_enabled_tsd_set
Definition: private_namespace.h:383
#define arena_alloc_junk_small
Definition: private_namespace.h:4
#define arena_malloc_large
Definition: private_namespace.h:19
#define tcache_tsd_set
Definition: private_namespace.h:400
#define PAGE
Definition: jemalloc_internal.h:360
#define tcache_bin_flush_small
Definition: private_namespace.h:363
#define tcache_bin_info
Definition: private_namespace.h:364