1 #ifndef JEMALLOC_INTERNAL_TCACHE_TYPES_H 2 #define JEMALLOC_INTERNAL_TCACHE_TYPES_H 3 4 #include "jemalloc/internal/sc.h" 5 6 typedef struct tcache_s tcache_t; 7 typedef struct tcaches_s tcaches_t; 8 9 /* 10 * tcache pointers close to NULL are used to encode state information that is 11 * used for two purposes: preventing thread caching on a per thread basis and 12 * cleaning up during thread shutdown. 13 */ 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 18 19 /* 20 * Absolute minimum number of cache slots for each small bin. 21 */ 22 #define TCACHE_NSLOTS_SMALL_MIN 20 23 24 /* 25 * Absolute maximum number of cache slots for each small bin in the thread 26 * cache. This is an additional constraint beyond that imposed as: twice the 27 * number of regions per slab for this size class. 28 * 29 * This constant must be an even number. 30 */ 31 #define TCACHE_NSLOTS_SMALL_MAX 200 32 33 /* Number of cache slots for large size classes. */ 34 #define TCACHE_NSLOTS_LARGE 20 35 36 /* (1U << opt_lg_tcache_max) is used to compute tcache_maxclass. */ 37 #define LG_TCACHE_MAXCLASS_DEFAULT 15 38 39 /* 40 * TCACHE_GC_SWEEP is the approximate number of allocation events between 41 * full GC sweeps. Integer rounding may cause the actual number to be 42 * slightly higher, since GC is performed incrementally. 43 */ 44 #define TCACHE_GC_SWEEP 8192 45 46 /* Number of tcache allocation/deallocation events between incremental GCs. */ 47 #define TCACHE_GC_INCR \ 48 ((TCACHE_GC_SWEEP / SC_NBINS) + ((TCACHE_GC_SWEEP / SC_NBINS == 0) ? 0 : 1)) 49 50 /* Used in TSD static initializer only. Real init in tcache_data_init(). */ 51 #define TCACHE_ZERO_INITIALIZER {0} 52 53 /* Used in TSD static initializer only. Will be initialized to opt_tcache. */ 54 #define TCACHE_ENABLED_ZERO_INITIALIZER false 55 56 /* Used for explicit tcache only. Means flushed but not destroyed. */ 57 #define TCACHES_ELM_NEED_REINIT ((tcache_t *)(uintptr_t)1) 58 59 #endif /* JEMALLOC_INTERNAL_TCACHE_TYPES_H */ 60