Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 1 | /******************************************************************************/ |
| 2 | #ifdef JEMALLOC_H_TYPES |
| 3 | |
| 4 | /* |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 5 | * RUN_MAX_OVRHD indicates maximum desired run header overhead. Runs are sized |
| 6 | * as small as possible such that this setting is still honored, without |
| 7 | * violating other constraints. The goal is to make runs as small as possible |
| 8 | * without exceeding a per run external fragmentation threshold. |
| 9 | * |
| 10 | * We use binary fixed point math for overhead computations, where the binary |
| 11 | * point is implicitly RUN_BFP bits to the left. |
| 12 | * |
| 13 | * Note that it is possible to set RUN_MAX_OVRHD low enough that it cannot be |
Jason Evans | 8ad0eac | 2010-12-17 18:07:53 -0800 | [diff] [blame] | 14 | * honored for some/all object sizes, since when heap profiling is enabled |
| 15 | * there is one pointer of header overhead per object (plus a constant). This |
| 16 | * constraint is relaxed (ignored) for runs that are so small that the |
| 17 | * per-region overhead is greater than: |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 18 | * |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 19 | * (RUN_MAX_OVRHD / (reg_interval << (3+RUN_BFP)) |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 20 | */ |
| 21 | #define RUN_BFP 12 |
| 22 | /* \/ Implicit binary fixed point. */ |
| 23 | #define RUN_MAX_OVRHD 0x0000003dU |
| 24 | #define RUN_MAX_OVRHD_RELAX 0x00001800U |
| 25 | |
Jason Evans | 47e57f9 | 2011-03-22 09:00:56 -0700 | [diff] [blame] | 26 | /* Maximum number of regions in one run. */ |
| 27 | #define LG_RUN_MAXREGS 11 |
| 28 | #define RUN_MAXREGS (1U << LG_RUN_MAXREGS) |
| 29 | |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 30 | /* |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 31 | * Minimum redzone size. Redzones may be larger than this if necessary to |
| 32 | * preserve region alignment. |
| 33 | */ |
| 34 | #define REDZONE_MINSIZE 16 |
| 35 | |
| 36 | /* |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 37 | * The minimum ratio of active:dirty pages per arena is computed as: |
| 38 | * |
| 39 | * (nactive >> opt_lg_dirty_mult) >= ndirty |
| 40 | * |
Jason Evans | e3d1306 | 2012-10-30 15:42:37 -0700 | [diff] [blame] | 41 | * So, supposing that opt_lg_dirty_mult is 3, there can be no less than 8 times |
| 42 | * as many active pages as dirty pages. |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 43 | */ |
Jason Evans | e3d1306 | 2012-10-30 15:42:37 -0700 | [diff] [blame] | 44 | #define LG_DIRTY_MULT_DEFAULT 3 |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 45 | |
| 46 | typedef struct arena_chunk_map_s arena_chunk_map_t; |
| 47 | typedef struct arena_chunk_s arena_chunk_t; |
| 48 | typedef struct arena_run_s arena_run_t; |
Jason Evans | 49f7e8f | 2011-03-15 13:59:15 -0700 | [diff] [blame] | 49 | typedef struct arena_bin_info_s arena_bin_info_t; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 50 | typedef struct arena_bin_s arena_bin_t; |
| 51 | typedef struct arena_s arena_t; |
| 52 | |
| 53 | #endif /* JEMALLOC_H_TYPES */ |
| 54 | /******************************************************************************/ |
| 55 | #ifdef JEMALLOC_H_STRUCTS |
| 56 | |
| 57 | /* Each element of the chunk map corresponds to one page within the chunk. */ |
| 58 | struct arena_chunk_map_s { |
Jason Evans | 7372b15 | 2012-02-10 20:22:09 -0800 | [diff] [blame] | 59 | #ifndef JEMALLOC_PROF |
| 60 | /* |
Jason Evans | 602c8e0 | 2014-08-18 16:22:13 -0700 | [diff] [blame^] | 61 | * Overlay prof_tctx in order to allow it to be referenced by dead code. |
Jason Evans | 7372b15 | 2012-02-10 20:22:09 -0800 | [diff] [blame] | 62 | * Such antics aren't warranted for per arena data structures, but |
| 63 | * chunk map overhead accounts for a percentage of memory, rather than |
| 64 | * being just a fixed cost. |
| 65 | */ |
| 66 | union { |
| 67 | #endif |
Jason Evans | 070b3c3 | 2014-08-14 14:45:58 -0700 | [diff] [blame] | 68 | /* |
| 69 | * Linkage for run trees. There are two disjoint uses: |
| 70 | * |
| 71 | * 1) arena_t's runs_avail tree. |
| 72 | * 2) arena_run_t conceptually uses this linkage for in-use non-full |
| 73 | * runs, rather than directly embedding linkage. |
| 74 | */ |
| 75 | rb_node(arena_chunk_map_t) rb_link; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 76 | |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 77 | /* Profile counters, used for large object runs. */ |
Jason Evans | 602c8e0 | 2014-08-18 16:22:13 -0700 | [diff] [blame^] | 78 | prof_tctx_t *prof_tctx; |
Jason Evans | 7372b15 | 2012-02-10 20:22:09 -0800 | [diff] [blame] | 79 | #ifndef JEMALLOC_PROF |
| 80 | }; /* union { ... }; */ |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 81 | #endif |
| 82 | |
Qinfan Wu | 04d60a1 | 2014-07-18 14:21:17 -0700 | [diff] [blame] | 83 | /* Linkage for list of dirty runs. */ |
| 84 | ql_elm(arena_chunk_map_t) dr_link; |
| 85 | |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 86 | /* |
| 87 | * Run address (or size) and various flags are stored together. The bit |
| 88 | * layout looks like (assuming 32-bit system): |
| 89 | * |
Jason Evans | 53bd42c | 2012-05-10 00:18:46 -0700 | [diff] [blame] | 90 | * ???????? ???????? ????nnnn nnnndula |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 91 | * |
| 92 | * ? : Unallocated: Run address for first/last pages, unset for internal |
| 93 | * pages. |
Jason Evans | 19b3d61 | 2010-03-18 20:36:40 -0700 | [diff] [blame] | 94 | * Small: Run page offset. |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 95 | * Large: Run size for first page, unset for trailing pages. |
Jason Evans | 53bd42c | 2012-05-10 00:18:46 -0700 | [diff] [blame] | 96 | * n : binind for small size class, BININD_INVALID for large size class. |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 97 | * d : dirty? |
Jason Evans | 8ad0eac | 2010-12-17 18:07:53 -0800 | [diff] [blame] | 98 | * u : unzeroed? |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 99 | * l : large? |
| 100 | * a : allocated? |
| 101 | * |
| 102 | * Following are example bit patterns for the three types of runs. |
| 103 | * |
| 104 | * p : run page offset |
| 105 | * s : run size |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 106 | * n : binind for size class; large objects set these to BININD_INVALID |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 107 | * x : don't care |
| 108 | * - : 0 |
Jason Evans | 0b270a9 | 2010-03-31 16:45:04 -0700 | [diff] [blame] | 109 | * + : 1 |
Jason Evans | 3377ffa | 2010-10-01 17:53:37 -0700 | [diff] [blame] | 110 | * [DULA] : bit set |
| 111 | * [dula] : bit unset |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 112 | * |
Jason Evans | 19b3d61 | 2010-03-18 20:36:40 -0700 | [diff] [blame] | 113 | * Unallocated (clean): |
Jason Evans | 53bd42c | 2012-05-10 00:18:46 -0700 | [diff] [blame] | 114 | * ssssssss ssssssss ssss++++ ++++du-a |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 115 | * xxxxxxxx xxxxxxxx xxxxxxxx xxxx-Uxx |
Jason Evans | 53bd42c | 2012-05-10 00:18:46 -0700 | [diff] [blame] | 116 | * ssssssss ssssssss ssss++++ ++++dU-a |
Jason Evans | 19b3d61 | 2010-03-18 20:36:40 -0700 | [diff] [blame] | 117 | * |
| 118 | * Unallocated (dirty): |
Jason Evans | 53bd42c | 2012-05-10 00:18:46 -0700 | [diff] [blame] | 119 | * ssssssss ssssssss ssss++++ ++++D--a |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 120 | * xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx |
Jason Evans | 53bd42c | 2012-05-10 00:18:46 -0700 | [diff] [blame] | 121 | * ssssssss ssssssss ssss++++ ++++D--a |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 122 | * |
Jason Evans | dafde14 | 2010-03-17 16:27:39 -0700 | [diff] [blame] | 123 | * Small: |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 124 | * pppppppp pppppppp ppppnnnn nnnnd--A |
| 125 | * pppppppp pppppppp ppppnnnn nnnn---A |
| 126 | * pppppppp pppppppp ppppnnnn nnnnd--A |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 127 | * |
| 128 | * Large: |
Jason Evans | 53bd42c | 2012-05-10 00:18:46 -0700 | [diff] [blame] | 129 | * ssssssss ssssssss ssss++++ ++++D-LA |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 130 | * xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx |
Jason Evans | 53bd42c | 2012-05-10 00:18:46 -0700 | [diff] [blame] | 131 | * -------- -------- ----++++ ++++D-LA |
Jason Evans | 0b270a9 | 2010-03-31 16:45:04 -0700 | [diff] [blame] | 132 | * |
Jason Evans | ae4c7b4 | 2012-04-02 07:04:34 -0700 | [diff] [blame] | 133 | * Large (sampled, size <= PAGE): |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 134 | * ssssssss ssssssss ssssnnnn nnnnD-LA |
Jason Evans | 0b270a9 | 2010-03-31 16:45:04 -0700 | [diff] [blame] | 135 | * |
Jason Evans | ae4c7b4 | 2012-04-02 07:04:34 -0700 | [diff] [blame] | 136 | * Large (not sampled, size == PAGE): |
Jason Evans | 53bd42c | 2012-05-10 00:18:46 -0700 | [diff] [blame] | 137 | * ssssssss ssssssss ssss++++ ++++D-LA |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 138 | */ |
| 139 | size_t bits; |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 140 | #define CHUNK_MAP_BININD_SHIFT 4 |
| 141 | #define BININD_INVALID ((size_t)0xffU) |
| 142 | /* CHUNK_MAP_BININD_MASK == (BININD_INVALID << CHUNK_MAP_BININD_SHIFT) */ |
| 143 | #define CHUNK_MAP_BININD_MASK ((size_t)0xff0U) |
| 144 | #define CHUNK_MAP_BININD_INVALID CHUNK_MAP_BININD_MASK |
| 145 | #define CHUNK_MAP_FLAGS_MASK ((size_t)0xcU) |
Jason Evans | 0b270a9 | 2010-03-31 16:45:04 -0700 | [diff] [blame] | 146 | #define CHUNK_MAP_DIRTY ((size_t)0x8U) |
Jason Evans | 3377ffa | 2010-10-01 17:53:37 -0700 | [diff] [blame] | 147 | #define CHUNK_MAP_UNZEROED ((size_t)0x4U) |
Jason Evans | 0b270a9 | 2010-03-31 16:45:04 -0700 | [diff] [blame] | 148 | #define CHUNK_MAP_LARGE ((size_t)0x2U) |
| 149 | #define CHUNK_MAP_ALLOCATED ((size_t)0x1U) |
| 150 | #define CHUNK_MAP_KEY CHUNK_MAP_ALLOCATED |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 151 | }; |
| 152 | typedef rb_tree(arena_chunk_map_t) arena_avail_tree_t; |
| 153 | typedef rb_tree(arena_chunk_map_t) arena_run_tree_t; |
Jason Evans | aa5113b | 2014-01-14 16:23:03 -0800 | [diff] [blame] | 154 | typedef ql_head(arena_chunk_map_t) arena_chunk_mapelms_t; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 155 | |
| 156 | /* Arena chunk header. */ |
| 157 | struct arena_chunk_s { |
| 158 | /* Arena that owns the chunk. */ |
Jason Evans | e3d1306 | 2012-10-30 15:42:37 -0700 | [diff] [blame] | 159 | arena_t *arena; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 160 | |
Jason Evans | 7393f44 | 2010-10-01 17:35:43 -0700 | [diff] [blame] | 161 | /* |
| 162 | * Map of pages within chunk that keeps track of free/large/small. The |
| 163 | * first map_bias entries are omitted, since the chunk header does not |
| 164 | * need to be tracked in the map. This omission saves a header page |
| 165 | * for common chunk sizes (e.g. 4 MiB). |
| 166 | */ |
Jason Evans | e3d1306 | 2012-10-30 15:42:37 -0700 | [diff] [blame] | 167 | arena_chunk_map_t map[1]; /* Dynamically sized. */ |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 168 | }; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 169 | |
| 170 | struct arena_run_s { |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 171 | /* Bin this run is associated with. */ |
| 172 | arena_bin_t *bin; |
| 173 | |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 174 | /* Index of next region that has never been allocated, or nregs. */ |
| 175 | uint32_t nextind; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 176 | |
| 177 | /* Number of free regions in run. */ |
| 178 | unsigned nfree; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 179 | }; |
| 180 | |
Jason Evans | 49f7e8f | 2011-03-15 13:59:15 -0700 | [diff] [blame] | 181 | /* |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 182 | * Read-only information associated with each element of arena_t's bins array |
Jason Evans | 49f7e8f | 2011-03-15 13:59:15 -0700 | [diff] [blame] | 183 | * is stored separately, partly to reduce memory usage (only one copy, rather |
| 184 | * than one per arena), but mainly to avoid false cacheline sharing. |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 185 | * |
| 186 | * Each run has the following layout: |
| 187 | * |
| 188 | * /--------------------\ |
| 189 | * | arena_run_t header | |
| 190 | * | ... | |
| 191 | * bitmap_offset | bitmap | |
| 192 | * | ... | |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 193 | * |--------------------| |
| 194 | * | redzone | |
| 195 | * reg0_offset | region 0 | |
| 196 | * | redzone | |
| 197 | * |--------------------| \ |
| 198 | * | redzone | | |
| 199 | * | region 1 | > reg_interval |
| 200 | * | redzone | / |
| 201 | * |--------------------| |
| 202 | * | ... | |
| 203 | * | ... | |
| 204 | * | ... | |
| 205 | * |--------------------| |
| 206 | * | redzone | |
| 207 | * | region nregs-1 | |
| 208 | * | redzone | |
| 209 | * |--------------------| |
| 210 | * | alignment pad? | |
| 211 | * \--------------------/ |
| 212 | * |
| 213 | * reg_interval has at least the same minimum alignment as reg_size; this |
| 214 | * preserves the alignment constraint that sa2u() depends on. Alignment pad is |
| 215 | * either 0 or redzone_size; it is present only if needed to align reg0_offset. |
Jason Evans | 49f7e8f | 2011-03-15 13:59:15 -0700 | [diff] [blame] | 216 | */ |
| 217 | struct arena_bin_info_s { |
| 218 | /* Size of regions in a run for this bin's size class. */ |
| 219 | size_t reg_size; |
| 220 | |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 221 | /* Redzone size. */ |
| 222 | size_t redzone_size; |
| 223 | |
| 224 | /* Interval between regions (reg_size + (redzone_size << 1)). */ |
| 225 | size_t reg_interval; |
| 226 | |
Jason Evans | 49f7e8f | 2011-03-15 13:59:15 -0700 | [diff] [blame] | 227 | /* Total size of a run for this bin's size class. */ |
| 228 | size_t run_size; |
| 229 | |
| 230 | /* Total number of regions in a run for this bin's size class. */ |
| 231 | uint32_t nregs; |
| 232 | |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 233 | /* |
| 234 | * Offset of first bitmap_t element in a run header for this bin's size |
| 235 | * class. |
| 236 | */ |
| 237 | uint32_t bitmap_offset; |
| 238 | |
| 239 | /* |
| 240 | * Metadata used to manipulate bitmaps for runs associated with this |
| 241 | * bin. |
| 242 | */ |
| 243 | bitmap_info_t bitmap_info; |
| 244 | |
Jason Evans | 49f7e8f | 2011-03-15 13:59:15 -0700 | [diff] [blame] | 245 | /* Offset of first region in a run for this bin's size class. */ |
| 246 | uint32_t reg0_offset; |
| 247 | }; |
| 248 | |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 249 | struct arena_bin_s { |
| 250 | /* |
Jason Evans | 86815df | 2010-03-13 20:32:56 -0800 | [diff] [blame] | 251 | * All operations on runcur, runs, and stats require that lock be |
| 252 | * locked. Run allocation/deallocation are protected by the arena lock, |
| 253 | * which may be acquired while holding one or more bin locks, but not |
| 254 | * vise versa. |
| 255 | */ |
| 256 | malloc_mutex_t lock; |
| 257 | |
| 258 | /* |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 259 | * Current run being used to service allocations of this bin's size |
| 260 | * class. |
| 261 | */ |
| 262 | arena_run_t *runcur; |
| 263 | |
| 264 | /* |
| 265 | * Tree of non-full runs. This tree is used when looking for an |
| 266 | * existing run when runcur is no longer usable. We choose the |
| 267 | * non-full run that is lowest in memory; this policy tends to keep |
| 268 | * objects packed well, and it can also help reduce the number of |
| 269 | * almost-empty chunks. |
| 270 | */ |
| 271 | arena_run_tree_t runs; |
| 272 | |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 273 | /* Bin statistics. */ |
| 274 | malloc_bin_stats_t stats; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 275 | }; |
| 276 | |
| 277 | struct arena_s { |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 278 | /* This arena's index within the arenas array. */ |
| 279 | unsigned ind; |
| 280 | |
Jason Evans | 86815df | 2010-03-13 20:32:56 -0800 | [diff] [blame] | 281 | /* |
Jason Evans | 597632b | 2011-03-18 13:41:33 -0700 | [diff] [blame] | 282 | * Number of threads currently assigned to this arena. This field is |
| 283 | * protected by arenas_lock. |
| 284 | */ |
| 285 | unsigned nthreads; |
| 286 | |
| 287 | /* |
| 288 | * There are three classes of arena operations from a locking |
| 289 | * perspective: |
| 290 | * 1) Thread asssignment (modifies nthreads) is protected by |
| 291 | * arenas_lock. |
| 292 | * 2) Bin-related operations are protected by bin locks. |
| 293 | * 3) Chunk- and run-related operations are protected by this mutex. |
Jason Evans | 86815df | 2010-03-13 20:32:56 -0800 | [diff] [blame] | 294 | */ |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 295 | malloc_mutex_t lock; |
| 296 | |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 297 | arena_stats_t stats; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 298 | /* |
| 299 | * List of tcaches for extant threads associated with this arena. |
| 300 | * Stats from these are merged incrementally, and at exit. |
| 301 | */ |
| 302 | ql_head(tcache_t) tcache_ql; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 303 | |
Jason Evans | d34f9e7 | 2010-02-11 13:19:21 -0800 | [diff] [blame] | 304 | uint64_t prof_accumbytes; |
Jason Evans | d34f9e7 | 2010-02-11 13:19:21 -0800 | [diff] [blame] | 305 | |
Jason Evans | 609ae59 | 2012-10-11 13:53:15 -0700 | [diff] [blame] | 306 | dss_prec_t dss_prec; |
| 307 | |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 308 | /* |
| 309 | * In order to avoid rapid chunk allocation/deallocation when an arena |
| 310 | * oscillates right on the cusp of needing a new chunk, cache the most |
| 311 | * recently freed chunk. The spare is left in the arena's chunk trees |
| 312 | * until it is deleted. |
| 313 | * |
| 314 | * There is one spare chunk per arena, rather than one spare total, in |
| 315 | * order to avoid interactions between multiple threads that could make |
| 316 | * a single spare inadequate. |
| 317 | */ |
| 318 | arena_chunk_t *spare; |
| 319 | |
Jason Evans | e2deab7 | 2014-05-15 22:22:27 -0700 | [diff] [blame] | 320 | /* Number of pages in active runs and huge regions. */ |
Jason Evans | bc25a47 | 2010-01-24 16:41:01 -0800 | [diff] [blame] | 321 | size_t nactive; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 322 | |
| 323 | /* |
| 324 | * Current count of pages within unused runs that are potentially |
| 325 | * dirty, and for which madvise(... MADV_DONTNEED) has not been called. |
| 326 | * By tracking this, we can institute a limit on how much dirty unused |
| 327 | * memory is mapped for each arena. |
| 328 | */ |
| 329 | size_t ndirty; |
| 330 | |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 331 | /* |
Jason Evans | 19b3d61 | 2010-03-18 20:36:40 -0700 | [diff] [blame] | 332 | * Size/address-ordered trees of this arena's available runs. The trees |
Jason Evans | e3d1306 | 2012-10-30 15:42:37 -0700 | [diff] [blame] | 333 | * are used for first-best-fit run allocation. |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 334 | */ |
Jason Evans | e3d1306 | 2012-10-30 15:42:37 -0700 | [diff] [blame] | 335 | arena_avail_tree_t runs_avail; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 336 | |
Jason Evans | 070b3c3 | 2014-08-14 14:45:58 -0700 | [diff] [blame] | 337 | /* List of dirty runs this arena manages. */ |
| 338 | arena_chunk_mapelms_t runs_dirty; |
| 339 | |
aravind | fb7fe50 | 2014-05-05 15:16:56 -0700 | [diff] [blame] | 340 | /* |
| 341 | * user-configureable chunk allocation and deallocation functions. |
| 342 | */ |
| 343 | chunk_alloc_t *chunk_alloc; |
Jason Evans | e2deab7 | 2014-05-15 22:22:27 -0700 | [diff] [blame] | 344 | chunk_dalloc_t *chunk_dalloc; |
aravind | fb7fe50 | 2014-05-05 15:16:56 -0700 | [diff] [blame] | 345 | |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 346 | /* bins is used to store trees of free regions. */ |
| 347 | arena_bin_t bins[NBINS]; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 348 | }; |
| 349 | |
| 350 | #endif /* JEMALLOC_H_STRUCTS */ |
| 351 | /******************************************************************************/ |
| 352 | #ifdef JEMALLOC_H_EXTERNS |
| 353 | |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 354 | extern ssize_t opt_lg_dirty_mult; |
Jason Evans | 41ade96 | 2011-03-06 22:56:36 -0800 | [diff] [blame] | 355 | /* |
Jason Evans | 3541a90 | 2014-04-16 17:14:33 -0700 | [diff] [blame] | 356 | * small_size2bin_tab is a compact lookup table that rounds request sizes up to |
Jason Evans | 41ade96 | 2011-03-06 22:56:36 -0800 | [diff] [blame] | 357 | * size classes. In order to reduce cache footprint, the table is compressed, |
Jason Evans | 3541a90 | 2014-04-16 17:14:33 -0700 | [diff] [blame] | 358 | * and all accesses are via small_size2bin(). |
Jason Evans | 41ade96 | 2011-03-06 22:56:36 -0800 | [diff] [blame] | 359 | */ |
Jason Evans | 3541a90 | 2014-04-16 17:14:33 -0700 | [diff] [blame] | 360 | extern uint8_t const small_size2bin_tab[]; |
| 361 | /* |
| 362 | * small_bin2size_tab duplicates information in arena_bin_info, but in a const |
| 363 | * array, for which it is easier for the compiler to optimize repeated |
| 364 | * dereferences. |
| 365 | */ |
| 366 | extern uint32_t const small_bin2size_tab[NBINS]; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 367 | |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 368 | extern arena_bin_info_t arena_bin_info[NBINS]; |
Jason Evans | 49f7e8f | 2011-03-15 13:59:15 -0700 | [diff] [blame] | 369 | |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 370 | /* Number of large size classes. */ |
Jason Evans | 7393f44 | 2010-10-01 17:35:43 -0700 | [diff] [blame] | 371 | #define nlclasses (chunk_npages - map_bias) |
Jason Evans | 3c23435 | 2010-01-27 13:10:55 -0800 | [diff] [blame] | 372 | |
Jason Evans | e2deab7 | 2014-05-15 22:22:27 -0700 | [diff] [blame] | 373 | void *arena_chunk_alloc_huge(arena_t *arena, size_t size, size_t alignment, |
| 374 | bool *zero); |
| 375 | void arena_chunk_dalloc_huge(arena_t *arena, void *chunk, size_t size); |
Jason Evans | 6005f07 | 2010-09-30 16:55:08 -0700 | [diff] [blame] | 376 | void arena_purge_all(arena_t *arena); |
Jason Evans | dafde14 | 2010-03-17 16:27:39 -0700 | [diff] [blame] | 377 | void arena_tcache_fill_small(arena_t *arena, tcache_bin_t *tbin, |
Jason Evans | 7372b15 | 2012-02-10 20:22:09 -0800 | [diff] [blame] | 378 | size_t binind, uint64_t prof_accumbytes); |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 379 | void arena_alloc_junk_small(void *ptr, arena_bin_info_t *bin_info, |
| 380 | bool zero); |
Jason Evans | 0d6c5d8 | 2013-12-17 15:14:36 -0800 | [diff] [blame] | 381 | #ifdef JEMALLOC_JET |
| 382 | typedef void (arena_redzone_corruption_t)(void *, size_t, bool, size_t, |
| 383 | uint8_t); |
Jason Evans | 6b694c4 | 2014-01-07 16:47:56 -0800 | [diff] [blame] | 384 | extern arena_redzone_corruption_t *arena_redzone_corruption; |
| 385 | typedef void (arena_dalloc_junk_small_t)(void *, arena_bin_info_t *); |
| 386 | extern arena_dalloc_junk_small_t *arena_dalloc_junk_small; |
| 387 | #else |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 388 | void arena_dalloc_junk_small(void *ptr, arena_bin_info_t *bin_info); |
Jason Evans | 6b694c4 | 2014-01-07 16:47:56 -0800 | [diff] [blame] | 389 | #endif |
Jason Evans | 0d6c5d8 | 2013-12-17 15:14:36 -0800 | [diff] [blame] | 390 | void arena_quarantine_junk_small(void *ptr, size_t usize); |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 391 | void *arena_malloc_small(arena_t *arena, size_t size, bool zero); |
Jason Evans | dafde14 | 2010-03-17 16:27:39 -0700 | [diff] [blame] | 392 | void *arena_malloc_large(arena_t *arena, size_t size, bool zero); |
Jason Evans | 5ff709c | 2012-04-11 18:13:45 -0700 | [diff] [blame] | 393 | void *arena_palloc(arena_t *arena, size_t size, size_t alignment, bool zero); |
Jason Evans | 0b270a9 | 2010-03-31 16:45:04 -0700 | [diff] [blame] | 394 | void arena_prof_promoted(const void *ptr, size_t size); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 395 | void arena_dalloc_bin_locked(arena_t *arena, arena_chunk_t *chunk, void *ptr, |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 396 | arena_chunk_map_t *mapelm); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 397 | void arena_dalloc_bin(arena_t *arena, arena_chunk_t *chunk, void *ptr, |
| 398 | size_t pageind, arena_chunk_map_t *mapelm); |
| 399 | void arena_dalloc_small(arena_t *arena, arena_chunk_t *chunk, void *ptr, |
| 400 | size_t pageind); |
Jason Evans | 6b694c4 | 2014-01-07 16:47:56 -0800 | [diff] [blame] | 401 | #ifdef JEMALLOC_JET |
| 402 | typedef void (arena_dalloc_junk_large_t)(void *, size_t); |
| 403 | extern arena_dalloc_junk_large_t *arena_dalloc_junk_large; |
| 404 | #endif |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 405 | void arena_dalloc_large_locked(arena_t *arena, arena_chunk_t *chunk, |
| 406 | void *ptr); |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 407 | void arena_dalloc_large(arena_t *arena, arena_chunk_t *chunk, void *ptr); |
Jason Evans | 6b694c4 | 2014-01-07 16:47:56 -0800 | [diff] [blame] | 408 | #ifdef JEMALLOC_JET |
| 409 | typedef void (arena_ralloc_junk_large_t)(void *, size_t, size_t); |
| 410 | extern arena_ralloc_junk_large_t *arena_ralloc_junk_large; |
| 411 | #endif |
Jason Evans | b2c3166 | 2014-01-12 15:05:44 -0800 | [diff] [blame] | 412 | bool arena_ralloc_no_move(void *ptr, size_t oldsize, size_t size, |
Jason Evans | 8e3c3c6 | 2010-09-17 15:46:18 -0700 | [diff] [blame] | 413 | size_t extra, bool zero); |
Jason Evans | 609ae59 | 2012-10-11 13:53:15 -0700 | [diff] [blame] | 414 | void *arena_ralloc(arena_t *arena, void *ptr, size_t oldsize, size_t size, |
| 415 | size_t extra, size_t alignment, bool zero, bool try_tcache_alloc, |
| 416 | bool try_tcache_dalloc); |
| 417 | dss_prec_t arena_dss_prec_get(arena_t *arena); |
Jason Evans | 4d434ad | 2014-04-15 12:09:48 -0700 | [diff] [blame] | 418 | bool arena_dss_prec_set(arena_t *arena, dss_prec_t dss_prec); |
Jason Evans | 609ae59 | 2012-10-11 13:53:15 -0700 | [diff] [blame] | 419 | void arena_stats_merge(arena_t *arena, const char **dss, size_t *nactive, |
| 420 | size_t *ndirty, arena_stats_t *astats, malloc_bin_stats_t *bstats, |
| 421 | malloc_large_stats_t *lstats); |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 422 | bool arena_new(arena_t *arena, unsigned ind); |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 423 | void arena_boot(void); |
Jason Evans | 4e2e3dd | 2012-03-13 16:31:41 -0700 | [diff] [blame] | 424 | void arena_prefork(arena_t *arena); |
| 425 | void arena_postfork_parent(arena_t *arena); |
| 426 | void arena_postfork_child(arena_t *arena); |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 427 | |
| 428 | #endif /* JEMALLOC_H_EXTERNS */ |
| 429 | /******************************************************************************/ |
| 430 | #ifdef JEMALLOC_H_INLINES |
| 431 | |
| 432 | #ifndef JEMALLOC_ENABLE_INLINE |
Jason Evans | d04047c | 2014-05-28 16:11:55 -0700 | [diff] [blame] | 433 | size_t small_size2bin_compute(size_t size); |
| 434 | size_t small_size2bin_lookup(size_t size); |
Jason Evans | 3541a90 | 2014-04-16 17:14:33 -0700 | [diff] [blame] | 435 | size_t small_size2bin(size_t size); |
Jason Evans | d04047c | 2014-05-28 16:11:55 -0700 | [diff] [blame] | 436 | size_t small_bin2size_compute(size_t binind); |
| 437 | size_t small_bin2size_lookup(size_t binind); |
Jason Evans | 3541a90 | 2014-04-16 17:14:33 -0700 | [diff] [blame] | 438 | size_t small_bin2size(size_t binind); |
Jason Evans | d04047c | 2014-05-28 16:11:55 -0700 | [diff] [blame] | 439 | size_t small_s2u_compute(size_t size); |
| 440 | size_t small_s2u_lookup(size_t size); |
| 441 | size_t small_s2u(size_t size); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 442 | arena_chunk_map_t *arena_mapp_get(arena_chunk_t *chunk, size_t pageind); |
| 443 | size_t *arena_mapbitsp_get(arena_chunk_t *chunk, size_t pageind); |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 444 | size_t arena_mapbitsp_read(size_t *mapbitsp); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 445 | size_t arena_mapbits_get(arena_chunk_t *chunk, size_t pageind); |
| 446 | size_t arena_mapbits_unallocated_size_get(arena_chunk_t *chunk, |
| 447 | size_t pageind); |
| 448 | size_t arena_mapbits_large_size_get(arena_chunk_t *chunk, size_t pageind); |
| 449 | size_t arena_mapbits_small_runind_get(arena_chunk_t *chunk, size_t pageind); |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 450 | size_t arena_mapbits_binind_get(arena_chunk_t *chunk, size_t pageind); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 451 | size_t arena_mapbits_dirty_get(arena_chunk_t *chunk, size_t pageind); |
| 452 | size_t arena_mapbits_unzeroed_get(arena_chunk_t *chunk, size_t pageind); |
| 453 | size_t arena_mapbits_large_get(arena_chunk_t *chunk, size_t pageind); |
| 454 | size_t arena_mapbits_allocated_get(arena_chunk_t *chunk, size_t pageind); |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 455 | void arena_mapbitsp_write(size_t *mapbitsp, size_t mapbits); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 456 | void arena_mapbits_unallocated_set(arena_chunk_t *chunk, size_t pageind, |
| 457 | size_t size, size_t flags); |
| 458 | void arena_mapbits_unallocated_size_set(arena_chunk_t *chunk, size_t pageind, |
| 459 | size_t size); |
| 460 | void arena_mapbits_large_set(arena_chunk_t *chunk, size_t pageind, |
| 461 | size_t size, size_t flags); |
| 462 | void arena_mapbits_large_binind_set(arena_chunk_t *chunk, size_t pageind, |
| 463 | size_t binind); |
| 464 | void arena_mapbits_small_set(arena_chunk_t *chunk, size_t pageind, |
| 465 | size_t runind, size_t binind, size_t flags); |
| 466 | void arena_mapbits_unzeroed_set(arena_chunk_t *chunk, size_t pageind, |
| 467 | size_t unzeroed); |
Jason Evans | 88c222c | 2013-02-06 11:59:30 -0800 | [diff] [blame] | 468 | bool arena_prof_accum_impl(arena_t *arena, uint64_t accumbytes); |
| 469 | bool arena_prof_accum_locked(arena_t *arena, uint64_t accumbytes); |
| 470 | bool arena_prof_accum(arena_t *arena, uint64_t accumbytes); |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 471 | size_t arena_ptr_small_binind_get(const void *ptr, size_t mapbits); |
Jason Evans | 49f7e8f | 2011-03-15 13:59:15 -0700 | [diff] [blame] | 472 | size_t arena_bin_index(arena_t *arena, arena_bin_t *bin); |
| 473 | unsigned arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, |
Jason Evans | b602daa | 2011-03-15 22:19:45 -0700 | [diff] [blame] | 474 | const void *ptr); |
Jason Evans | 602c8e0 | 2014-08-18 16:22:13 -0700 | [diff] [blame^] | 475 | prof_tctx_t *arena_prof_tctx_get(const void *ptr); |
| 476 | void arena_prof_tctx_set(const void *ptr, prof_tctx_t *tctx); |
Jason Evans | 01b3fe5 | 2012-04-03 09:28:00 -0700 | [diff] [blame] | 477 | void *arena_malloc(arena_t *arena, size_t size, bool zero, bool try_tcache); |
Jason Evans | f7088e6 | 2012-04-19 18:28:03 -0700 | [diff] [blame] | 478 | size_t arena_salloc(const void *ptr, bool demote); |
Ben Maurer | be8e59f | 2014-04-05 15:59:08 -0700 | [diff] [blame] | 479 | void arena_dalloc(arena_chunk_t *chunk, void *ptr, bool try_tcache); |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 480 | #endif |
| 481 | |
| 482 | #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_ARENA_C_)) |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 483 | # ifdef JEMALLOC_ARENA_INLINE_A |
Jason Evans | d04047c | 2014-05-28 16:11:55 -0700 | [diff] [blame] | 484 | JEMALLOC_INLINE size_t |
| 485 | small_size2bin_compute(size_t size) |
| 486 | { |
| 487 | #if (NTBINS != 0) |
| 488 | if (size <= (ZU(1) << LG_TINY_MAXCLASS)) { |
| 489 | size_t lg_tmin = LG_TINY_MAXCLASS - NTBINS + 1; |
| 490 | size_t lg_ceil = lg_floor(pow2_ceil(size)); |
| 491 | return (lg_ceil < lg_tmin ? 0 : lg_ceil - lg_tmin); |
| 492 | } else |
| 493 | #endif |
| 494 | { |
| 495 | size_t x = lg_floor((size<<1)-1); |
| 496 | size_t shift = (x < LG_SIZE_CLASS_GROUP + LG_QUANTUM) ? 0 : |
| 497 | x - (LG_SIZE_CLASS_GROUP + LG_QUANTUM); |
| 498 | size_t grp = shift << LG_SIZE_CLASS_GROUP; |
| 499 | |
| 500 | size_t lg_delta = (x < LG_SIZE_CLASS_GROUP + LG_QUANTUM + 1) |
| 501 | ? LG_QUANTUM : x - LG_SIZE_CLASS_GROUP - 1; |
| 502 | |
| 503 | size_t delta_inverse_mask = ZI(-1) << lg_delta; |
| 504 | size_t mod = ((((size-1) & delta_inverse_mask) >> lg_delta)) & |
| 505 | ((ZU(1) << LG_SIZE_CLASS_GROUP) - 1); |
| 506 | |
| 507 | size_t bin = NTBINS + grp + mod; |
| 508 | return (bin); |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | JEMALLOC_ALWAYS_INLINE size_t |
| 513 | small_size2bin_lookup(size_t size) |
| 514 | { |
| 515 | |
| 516 | assert(size <= LOOKUP_MAXCLASS); |
| 517 | { |
| 518 | size_t ret = ((size_t)(small_size2bin_tab[(size-1) >> |
| 519 | LG_TINY_MIN])); |
| 520 | assert(ret == small_size2bin_compute(size)); |
| 521 | return (ret); |
| 522 | } |
| 523 | } |
| 524 | |
Jason Evans | 3541a90 | 2014-04-16 17:14:33 -0700 | [diff] [blame] | 525 | JEMALLOC_ALWAYS_INLINE size_t |
| 526 | small_size2bin(size_t size) |
| 527 | { |
| 528 | |
Jason Evans | d04047c | 2014-05-28 16:11:55 -0700 | [diff] [blame] | 529 | assert(size > 0); |
| 530 | if (size <= LOOKUP_MAXCLASS) |
| 531 | return (small_size2bin_lookup(size)); |
| 532 | else |
| 533 | return (small_size2bin_compute(size)); |
| 534 | } |
| 535 | |
| 536 | JEMALLOC_INLINE size_t |
| 537 | small_bin2size_compute(size_t binind) |
| 538 | { |
| 539 | #if (NTBINS > 0) |
| 540 | if (binind < NTBINS) |
| 541 | return (ZU(1) << (LG_TINY_MAXCLASS - NTBINS + 1 + binind)); |
| 542 | else |
| 543 | #endif |
| 544 | { |
| 545 | size_t reduced_binind = binind - NTBINS; |
| 546 | size_t grp = reduced_binind >> LG_SIZE_CLASS_GROUP; |
| 547 | size_t mod = reduced_binind & ((ZU(1) << LG_SIZE_CLASS_GROUP) - |
| 548 | 1); |
| 549 | |
| 550 | size_t grp_size_mask = ~((!!grp)-1); |
| 551 | size_t grp_size = ((ZU(1) << (LG_QUANTUM + |
| 552 | (LG_SIZE_CLASS_GROUP-1))) << grp) & grp_size_mask; |
| 553 | |
| 554 | size_t shift = (grp == 0) ? 1 : grp; |
| 555 | size_t lg_delta = shift + (LG_QUANTUM-1); |
| 556 | size_t mod_size = (mod+1) << lg_delta; |
| 557 | |
| 558 | size_t usize = grp_size + mod_size; |
| 559 | return (usize); |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | JEMALLOC_ALWAYS_INLINE size_t |
| 564 | small_bin2size_lookup(size_t binind) |
| 565 | { |
| 566 | |
| 567 | assert(binind < NBINS); |
| 568 | { |
| 569 | size_t ret = ((size_t)(small_bin2size_tab[binind])); |
| 570 | assert(ret == small_bin2size_compute(binind)); |
| 571 | return (ret); |
| 572 | } |
Jason Evans | 3541a90 | 2014-04-16 17:14:33 -0700 | [diff] [blame] | 573 | } |
| 574 | |
| 575 | JEMALLOC_ALWAYS_INLINE size_t |
| 576 | small_bin2size(size_t binind) |
| 577 | { |
| 578 | |
Jason Evans | d04047c | 2014-05-28 16:11:55 -0700 | [diff] [blame] | 579 | return (small_bin2size_lookup(binind)); |
| 580 | } |
| 581 | |
| 582 | JEMALLOC_ALWAYS_INLINE size_t |
| 583 | small_s2u_compute(size_t size) |
| 584 | { |
| 585 | #if (NTBINS > 0) |
| 586 | if (size <= (ZU(1) << LG_TINY_MAXCLASS)) { |
| 587 | size_t lg_tmin = LG_TINY_MAXCLASS - NTBINS + 1; |
| 588 | size_t lg_ceil = lg_floor(pow2_ceil(size)); |
| 589 | return (lg_ceil < lg_tmin ? (ZU(1) << lg_tmin) : |
| 590 | (ZU(1) << lg_ceil)); |
| 591 | } else |
| 592 | #endif |
| 593 | { |
| 594 | size_t x = lg_floor((size<<1)-1); |
| 595 | size_t lg_delta = (x < LG_SIZE_CLASS_GROUP + LG_QUANTUM + 1) |
| 596 | ? LG_QUANTUM : x - LG_SIZE_CLASS_GROUP - 1; |
| 597 | size_t delta = ZU(1) << lg_delta; |
| 598 | size_t delta_mask = delta - 1; |
| 599 | size_t usize = (size + delta_mask) & ~delta_mask; |
| 600 | return (usize); |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | JEMALLOC_ALWAYS_INLINE size_t |
| 605 | small_s2u_lookup(size_t size) |
| 606 | { |
| 607 | size_t ret = (small_bin2size(small_size2bin(size))); |
| 608 | |
| 609 | assert(ret == small_s2u_compute(size)); |
| 610 | return (ret); |
| 611 | } |
| 612 | |
| 613 | JEMALLOC_ALWAYS_INLINE size_t |
| 614 | small_s2u(size_t size) |
| 615 | { |
| 616 | |
| 617 | assert(size > 0); |
| 618 | if (size <= LOOKUP_MAXCLASS) |
| 619 | return (small_s2u_lookup(size)); |
| 620 | else |
| 621 | return (small_s2u_compute(size)); |
Jason Evans | 3541a90 | 2014-04-16 17:14:33 -0700 | [diff] [blame] | 622 | } |
| 623 | # endif /* JEMALLOC_ARENA_INLINE_A */ |
| 624 | |
| 625 | # ifdef JEMALLOC_ARENA_INLINE_B |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 626 | JEMALLOC_ALWAYS_INLINE arena_chunk_map_t * |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 627 | arena_mapp_get(arena_chunk_t *chunk, size_t pageind) |
| 628 | { |
| 629 | |
| 630 | assert(pageind >= map_bias); |
| 631 | assert(pageind < chunk_npages); |
| 632 | |
| 633 | return (&chunk->map[pageind-map_bias]); |
| 634 | } |
| 635 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 636 | JEMALLOC_ALWAYS_INLINE size_t * |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 637 | arena_mapbitsp_get(arena_chunk_t *chunk, size_t pageind) |
| 638 | { |
| 639 | |
| 640 | return (&arena_mapp_get(chunk, pageind)->bits); |
| 641 | } |
| 642 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 643 | JEMALLOC_ALWAYS_INLINE size_t |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 644 | arena_mapbitsp_read(size_t *mapbitsp) |
| 645 | { |
| 646 | |
| 647 | return (*mapbitsp); |
| 648 | } |
| 649 | |
| 650 | JEMALLOC_ALWAYS_INLINE size_t |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 651 | arena_mapbits_get(arena_chunk_t *chunk, size_t pageind) |
| 652 | { |
| 653 | |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 654 | return (arena_mapbitsp_read(arena_mapbitsp_get(chunk, pageind))); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 655 | } |
| 656 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 657 | JEMALLOC_ALWAYS_INLINE size_t |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 658 | arena_mapbits_unallocated_size_get(arena_chunk_t *chunk, size_t pageind) |
| 659 | { |
| 660 | size_t mapbits; |
| 661 | |
| 662 | mapbits = arena_mapbits_get(chunk, pageind); |
| 663 | assert((mapbits & (CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED)) == 0); |
| 664 | return (mapbits & ~PAGE_MASK); |
| 665 | } |
| 666 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 667 | JEMALLOC_ALWAYS_INLINE size_t |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 668 | arena_mapbits_large_size_get(arena_chunk_t *chunk, size_t pageind) |
| 669 | { |
| 670 | size_t mapbits; |
| 671 | |
| 672 | mapbits = arena_mapbits_get(chunk, pageind); |
| 673 | assert((mapbits & (CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED)) == |
| 674 | (CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED)); |
| 675 | return (mapbits & ~PAGE_MASK); |
| 676 | } |
| 677 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 678 | JEMALLOC_ALWAYS_INLINE size_t |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 679 | arena_mapbits_small_runind_get(arena_chunk_t *chunk, size_t pageind) |
| 680 | { |
| 681 | size_t mapbits; |
| 682 | |
| 683 | mapbits = arena_mapbits_get(chunk, pageind); |
| 684 | assert((mapbits & (CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED)) == |
| 685 | CHUNK_MAP_ALLOCATED); |
| 686 | return (mapbits >> LG_PAGE); |
| 687 | } |
| 688 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 689 | JEMALLOC_ALWAYS_INLINE size_t |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 690 | arena_mapbits_binind_get(arena_chunk_t *chunk, size_t pageind) |
| 691 | { |
| 692 | size_t mapbits; |
| 693 | size_t binind; |
| 694 | |
| 695 | mapbits = arena_mapbits_get(chunk, pageind); |
| 696 | binind = (mapbits & CHUNK_MAP_BININD_MASK) >> CHUNK_MAP_BININD_SHIFT; |
| 697 | assert(binind < NBINS || binind == BININD_INVALID); |
| 698 | return (binind); |
| 699 | } |
| 700 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 701 | JEMALLOC_ALWAYS_INLINE size_t |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 702 | arena_mapbits_dirty_get(arena_chunk_t *chunk, size_t pageind) |
| 703 | { |
| 704 | size_t mapbits; |
| 705 | |
| 706 | mapbits = arena_mapbits_get(chunk, pageind); |
| 707 | return (mapbits & CHUNK_MAP_DIRTY); |
| 708 | } |
| 709 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 710 | JEMALLOC_ALWAYS_INLINE size_t |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 711 | arena_mapbits_unzeroed_get(arena_chunk_t *chunk, size_t pageind) |
| 712 | { |
| 713 | size_t mapbits; |
| 714 | |
| 715 | mapbits = arena_mapbits_get(chunk, pageind); |
| 716 | return (mapbits & CHUNK_MAP_UNZEROED); |
| 717 | } |
| 718 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 719 | JEMALLOC_ALWAYS_INLINE size_t |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 720 | arena_mapbits_large_get(arena_chunk_t *chunk, size_t pageind) |
| 721 | { |
| 722 | size_t mapbits; |
| 723 | |
| 724 | mapbits = arena_mapbits_get(chunk, pageind); |
| 725 | return (mapbits & CHUNK_MAP_LARGE); |
| 726 | } |
| 727 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 728 | JEMALLOC_ALWAYS_INLINE size_t |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 729 | arena_mapbits_allocated_get(arena_chunk_t *chunk, size_t pageind) |
| 730 | { |
| 731 | size_t mapbits; |
| 732 | |
| 733 | mapbits = arena_mapbits_get(chunk, pageind); |
| 734 | return (mapbits & CHUNK_MAP_ALLOCATED); |
| 735 | } |
| 736 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 737 | JEMALLOC_ALWAYS_INLINE void |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 738 | arena_mapbitsp_write(size_t *mapbitsp, size_t mapbits) |
| 739 | { |
| 740 | |
| 741 | *mapbitsp = mapbits; |
| 742 | } |
| 743 | |
| 744 | JEMALLOC_ALWAYS_INLINE void |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 745 | arena_mapbits_unallocated_set(arena_chunk_t *chunk, size_t pageind, size_t size, |
| 746 | size_t flags) |
| 747 | { |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 748 | size_t *mapbitsp = arena_mapbitsp_get(chunk, pageind); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 749 | |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 750 | assert((size & PAGE_MASK) == 0); |
| 751 | assert((flags & ~CHUNK_MAP_FLAGS_MASK) == 0); |
Jason Evans | d8ceef6 | 2012-05-10 20:59:39 -0700 | [diff] [blame] | 752 | assert((flags & (CHUNK_MAP_DIRTY|CHUNK_MAP_UNZEROED)) == flags); |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 753 | arena_mapbitsp_write(mapbitsp, size | CHUNK_MAP_BININD_INVALID | flags); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 754 | } |
| 755 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 756 | JEMALLOC_ALWAYS_INLINE void |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 757 | arena_mapbits_unallocated_size_set(arena_chunk_t *chunk, size_t pageind, |
| 758 | size_t size) |
| 759 | { |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 760 | size_t *mapbitsp = arena_mapbitsp_get(chunk, pageind); |
| 761 | size_t mapbits = arena_mapbitsp_read(mapbitsp); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 762 | |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 763 | assert((size & PAGE_MASK) == 0); |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 764 | assert((mapbits & (CHUNK_MAP_LARGE|CHUNK_MAP_ALLOCATED)) == 0); |
| 765 | arena_mapbitsp_write(mapbitsp, size | (mapbits & PAGE_MASK)); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 766 | } |
| 767 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 768 | JEMALLOC_ALWAYS_INLINE void |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 769 | arena_mapbits_large_set(arena_chunk_t *chunk, size_t pageind, size_t size, |
| 770 | size_t flags) |
| 771 | { |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 772 | size_t *mapbitsp = arena_mapbitsp_get(chunk, pageind); |
| 773 | size_t mapbits = arena_mapbitsp_read(mapbitsp); |
Jason Evans | d8ceef6 | 2012-05-10 20:59:39 -0700 | [diff] [blame] | 774 | size_t unzeroed; |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 775 | |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 776 | assert((size & PAGE_MASK) == 0); |
Jason Evans | d8ceef6 | 2012-05-10 20:59:39 -0700 | [diff] [blame] | 777 | assert((flags & CHUNK_MAP_DIRTY) == flags); |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 778 | unzeroed = mapbits & CHUNK_MAP_UNZEROED; /* Preserve unzeroed. */ |
| 779 | arena_mapbitsp_write(mapbitsp, size | CHUNK_MAP_BININD_INVALID | flags |
| 780 | | unzeroed | CHUNK_MAP_LARGE | CHUNK_MAP_ALLOCATED); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 781 | } |
| 782 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 783 | JEMALLOC_ALWAYS_INLINE void |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 784 | arena_mapbits_large_binind_set(arena_chunk_t *chunk, size_t pageind, |
| 785 | size_t binind) |
| 786 | { |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 787 | size_t *mapbitsp = arena_mapbitsp_get(chunk, pageind); |
| 788 | size_t mapbits = arena_mapbitsp_read(mapbitsp); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 789 | |
| 790 | assert(binind <= BININD_INVALID); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 791 | assert(arena_mapbits_large_size_get(chunk, pageind) == PAGE); |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 792 | arena_mapbitsp_write(mapbitsp, (mapbits & ~CHUNK_MAP_BININD_MASK) | |
| 793 | (binind << CHUNK_MAP_BININD_SHIFT)); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 794 | } |
| 795 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 796 | JEMALLOC_ALWAYS_INLINE void |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 797 | arena_mapbits_small_set(arena_chunk_t *chunk, size_t pageind, size_t runind, |
| 798 | size_t binind, size_t flags) |
| 799 | { |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 800 | size_t *mapbitsp = arena_mapbitsp_get(chunk, pageind); |
| 801 | size_t mapbits = arena_mapbitsp_read(mapbitsp); |
Jason Evans | d8ceef6 | 2012-05-10 20:59:39 -0700 | [diff] [blame] | 802 | size_t unzeroed; |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 803 | |
| 804 | assert(binind < BININD_INVALID); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 805 | assert(pageind - runind >= map_bias); |
Jason Evans | d8ceef6 | 2012-05-10 20:59:39 -0700 | [diff] [blame] | 806 | assert((flags & CHUNK_MAP_DIRTY) == flags); |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 807 | unzeroed = mapbits & CHUNK_MAP_UNZEROED; /* Preserve unzeroed. */ |
| 808 | arena_mapbitsp_write(mapbitsp, (runind << LG_PAGE) | (binind << |
| 809 | CHUNK_MAP_BININD_SHIFT) | flags | unzeroed | CHUNK_MAP_ALLOCATED); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 810 | } |
| 811 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 812 | JEMALLOC_ALWAYS_INLINE void |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 813 | arena_mapbits_unzeroed_set(arena_chunk_t *chunk, size_t pageind, |
| 814 | size_t unzeroed) |
| 815 | { |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 816 | size_t *mapbitsp = arena_mapbitsp_get(chunk, pageind); |
| 817 | size_t mapbits = arena_mapbitsp_read(mapbitsp); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 818 | |
Jason Evans | 87a02d2 | 2013-10-19 21:40:20 -0700 | [diff] [blame] | 819 | arena_mapbitsp_write(mapbitsp, (mapbits & ~CHUNK_MAP_UNZEROED) | |
| 820 | unzeroed); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 821 | } |
| 822 | |
Jason Evans | 88c222c | 2013-02-06 11:59:30 -0800 | [diff] [blame] | 823 | JEMALLOC_INLINE bool |
Jason Evans | a3b3386 | 2012-11-13 12:56:27 -0800 | [diff] [blame] | 824 | arena_prof_accum_impl(arena_t *arena, uint64_t accumbytes) |
| 825 | { |
| 826 | |
| 827 | cassert(config_prof); |
| 828 | assert(prof_interval != 0); |
| 829 | |
| 830 | arena->prof_accumbytes += accumbytes; |
| 831 | if (arena->prof_accumbytes >= prof_interval) { |
Jason Evans | a3b3386 | 2012-11-13 12:56:27 -0800 | [diff] [blame] | 832 | arena->prof_accumbytes -= prof_interval; |
Jason Evans | 88c222c | 2013-02-06 11:59:30 -0800 | [diff] [blame] | 833 | return (true); |
Jason Evans | a3b3386 | 2012-11-13 12:56:27 -0800 | [diff] [blame] | 834 | } |
Jason Evans | 88c222c | 2013-02-06 11:59:30 -0800 | [diff] [blame] | 835 | return (false); |
Jason Evans | a3b3386 | 2012-11-13 12:56:27 -0800 | [diff] [blame] | 836 | } |
| 837 | |
Jason Evans | 88c222c | 2013-02-06 11:59:30 -0800 | [diff] [blame] | 838 | JEMALLOC_INLINE bool |
Jason Evans | a3b3386 | 2012-11-13 12:56:27 -0800 | [diff] [blame] | 839 | arena_prof_accum_locked(arena_t *arena, uint64_t accumbytes) |
| 840 | { |
| 841 | |
| 842 | cassert(config_prof); |
| 843 | |
| 844 | if (prof_interval == 0) |
Jason Evans | 88c222c | 2013-02-06 11:59:30 -0800 | [diff] [blame] | 845 | return (false); |
| 846 | return (arena_prof_accum_impl(arena, accumbytes)); |
Jason Evans | a3b3386 | 2012-11-13 12:56:27 -0800 | [diff] [blame] | 847 | } |
| 848 | |
Jason Evans | 88c222c | 2013-02-06 11:59:30 -0800 | [diff] [blame] | 849 | JEMALLOC_INLINE bool |
Jason Evans | a3b3386 | 2012-11-13 12:56:27 -0800 | [diff] [blame] | 850 | arena_prof_accum(arena_t *arena, uint64_t accumbytes) |
| 851 | { |
| 852 | |
| 853 | cassert(config_prof); |
| 854 | |
| 855 | if (prof_interval == 0) |
Jason Evans | 88c222c | 2013-02-06 11:59:30 -0800 | [diff] [blame] | 856 | return (false); |
| 857 | |
| 858 | { |
| 859 | bool ret; |
| 860 | |
| 861 | malloc_mutex_lock(&arena->lock); |
| 862 | ret = arena_prof_accum_impl(arena, accumbytes); |
| 863 | malloc_mutex_unlock(&arena->lock); |
| 864 | return (ret); |
| 865 | } |
Jason Evans | a3b3386 | 2012-11-13 12:56:27 -0800 | [diff] [blame] | 866 | } |
| 867 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 868 | JEMALLOC_ALWAYS_INLINE size_t |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 869 | arena_ptr_small_binind_get(const void *ptr, size_t mapbits) |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 870 | { |
| 871 | size_t binind; |
| 872 | |
| 873 | binind = (mapbits & CHUNK_MAP_BININD_MASK) >> CHUNK_MAP_BININD_SHIFT; |
| 874 | |
| 875 | if (config_debug) { |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 876 | arena_chunk_t *chunk; |
| 877 | arena_t *arena; |
| 878 | size_t pageind; |
| 879 | size_t actual_mapbits; |
| 880 | arena_run_t *run; |
| 881 | arena_bin_t *bin; |
| 882 | size_t actual_binind; |
| 883 | arena_bin_info_t *bin_info; |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 884 | |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 885 | assert(binind != BININD_INVALID); |
| 886 | assert(binind < NBINS); |
| 887 | chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr); |
| 888 | arena = chunk->arena; |
| 889 | pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE; |
| 890 | actual_mapbits = arena_mapbits_get(chunk, pageind); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 891 | assert(mapbits == actual_mapbits); |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 892 | assert(arena_mapbits_large_get(chunk, pageind) == 0); |
| 893 | assert(arena_mapbits_allocated_get(chunk, pageind) != 0); |
| 894 | run = (arena_run_t *)((uintptr_t)chunk + (uintptr_t)((pageind - |
| 895 | (actual_mapbits >> LG_PAGE)) << LG_PAGE)); |
| 896 | bin = run->bin; |
| 897 | actual_binind = bin - arena->bins; |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 898 | assert(binind == actual_binind); |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 899 | bin_info = &arena_bin_info[actual_binind]; |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 900 | assert(((uintptr_t)ptr - ((uintptr_t)run + |
| 901 | (uintptr_t)bin_info->reg0_offset)) % bin_info->reg_interval |
| 902 | == 0); |
| 903 | } |
| 904 | |
| 905 | return (binind); |
| 906 | } |
Jason Evans | 3541a90 | 2014-04-16 17:14:33 -0700 | [diff] [blame] | 907 | # endif /* JEMALLOC_ARENA_INLINE_B */ |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 908 | |
Jason Evans | 3541a90 | 2014-04-16 17:14:33 -0700 | [diff] [blame] | 909 | # ifdef JEMALLOC_ARENA_INLINE_C |
Jason Evans | 49f7e8f | 2011-03-15 13:59:15 -0700 | [diff] [blame] | 910 | JEMALLOC_INLINE size_t |
| 911 | arena_bin_index(arena_t *arena, arena_bin_t *bin) |
| 912 | { |
| 913 | size_t binind = bin - arena->bins; |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 914 | assert(binind < NBINS); |
Jason Evans | 49f7e8f | 2011-03-15 13:59:15 -0700 | [diff] [blame] | 915 | return (binind); |
| 916 | } |
| 917 | |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 918 | JEMALLOC_INLINE unsigned |
Jason Evans | b602daa | 2011-03-15 22:19:45 -0700 | [diff] [blame] | 919 | arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, const void *ptr) |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 920 | { |
| 921 | unsigned shift, diff, regind; |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 922 | size_t interval; |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 923 | |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 924 | /* |
| 925 | * Freeing a pointer lower than region zero can cause assertion |
| 926 | * failure. |
| 927 | */ |
| 928 | assert((uintptr_t)ptr >= (uintptr_t)run + |
| 929 | (uintptr_t)bin_info->reg0_offset); |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 930 | |
| 931 | /* |
| 932 | * Avoid doing division with a variable divisor if possible. Using |
| 933 | * actual division here can reduce allocator throughput by over 20%! |
| 934 | */ |
Jason Evans | 49f7e8f | 2011-03-15 13:59:15 -0700 | [diff] [blame] | 935 | diff = (unsigned)((uintptr_t)ptr - (uintptr_t)run - |
| 936 | bin_info->reg0_offset); |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 937 | |
| 938 | /* Rescale (factor powers of 2 out of the numerator and denominator). */ |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 939 | interval = bin_info->reg_interval; |
Richard Diamond | 9c3a10f | 2014-05-28 21:37:02 -0500 | [diff] [blame] | 940 | shift = jemalloc_ffs(interval) - 1; |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 941 | diff >>= shift; |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 942 | interval >>= shift; |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 943 | |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 944 | if (interval == 1) { |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 945 | /* The divisor was a power of 2. */ |
| 946 | regind = diff; |
| 947 | } else { |
| 948 | /* |
| 949 | * To divide by a number D that is not a power of two we |
| 950 | * multiply by (2^21 / D) and then right shift by 21 positions. |
| 951 | * |
| 952 | * X / D |
| 953 | * |
| 954 | * becomes |
| 955 | * |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 956 | * (X * interval_invs[D - 3]) >> SIZE_INV_SHIFT |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 957 | * |
| 958 | * We can omit the first three elements, because we never |
| 959 | * divide by 0, and 1 and 2 are both powers of two, which are |
| 960 | * handled above. |
| 961 | */ |
Jason Evans | 47e57f9 | 2011-03-22 09:00:56 -0700 | [diff] [blame] | 962 | #define SIZE_INV_SHIFT ((sizeof(unsigned) << 3) - LG_RUN_MAXREGS) |
| 963 | #define SIZE_INV(s) (((1U << SIZE_INV_SHIFT) / (s)) + 1) |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 964 | static const unsigned interval_invs[] = { |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 965 | SIZE_INV(3), |
| 966 | SIZE_INV(4), SIZE_INV(5), SIZE_INV(6), SIZE_INV(7), |
| 967 | SIZE_INV(8), SIZE_INV(9), SIZE_INV(10), SIZE_INV(11), |
| 968 | SIZE_INV(12), SIZE_INV(13), SIZE_INV(14), SIZE_INV(15), |
| 969 | SIZE_INV(16), SIZE_INV(17), SIZE_INV(18), SIZE_INV(19), |
| 970 | SIZE_INV(20), SIZE_INV(21), SIZE_INV(22), SIZE_INV(23), |
| 971 | SIZE_INV(24), SIZE_INV(25), SIZE_INV(26), SIZE_INV(27), |
| 972 | SIZE_INV(28), SIZE_INV(29), SIZE_INV(30), SIZE_INV(31) |
| 973 | }; |
| 974 | |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 975 | if (interval <= ((sizeof(interval_invs) / sizeof(unsigned)) + |
| 976 | 2)) { |
| 977 | regind = (diff * interval_invs[interval - 3]) >> |
| 978 | SIZE_INV_SHIFT; |
| 979 | } else |
| 980 | regind = diff / interval; |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 981 | #undef SIZE_INV |
| 982 | #undef SIZE_INV_SHIFT |
| 983 | } |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 984 | assert(diff == regind * interval); |
Jason Evans | 49f7e8f | 2011-03-15 13:59:15 -0700 | [diff] [blame] | 985 | assert(regind < bin_info->nregs); |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 986 | |
| 987 | return (regind); |
| 988 | } |
| 989 | |
Jason Evans | 602c8e0 | 2014-08-18 16:22:13 -0700 | [diff] [blame^] | 990 | JEMALLOC_INLINE prof_tctx_t * |
| 991 | arena_prof_tctx_get(const void *ptr) |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 992 | { |
Jason Evans | 602c8e0 | 2014-08-18 16:22:13 -0700 | [diff] [blame^] | 993 | prof_tctx_t *ret; |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 994 | arena_chunk_t *chunk; |
| 995 | size_t pageind, mapbits; |
| 996 | |
Jason Evans | 7372b15 | 2012-02-10 20:22:09 -0800 | [diff] [blame] | 997 | cassert(config_prof); |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 998 | assert(ptr != NULL); |
| 999 | assert(CHUNK_ADDR2BASE(ptr) != ptr); |
| 1000 | |
| 1001 | chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr); |
Jason Evans | ae4c7b4 | 2012-04-02 07:04:34 -0700 | [diff] [blame] | 1002 | pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE; |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 1003 | mapbits = arena_mapbits_get(chunk, pageind); |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 1004 | assert((mapbits & CHUNK_MAP_ALLOCATED) != 0); |
Jason Evans | 9b0cbf0 | 2014-04-11 14:24:51 -0700 | [diff] [blame] | 1005 | if ((mapbits & CHUNK_MAP_LARGE) == 0) |
Jason Evans | 602c8e0 | 2014-08-18 16:22:13 -0700 | [diff] [blame^] | 1006 | ret = (prof_tctx_t *)(uintptr_t)1U; |
Jason Evans | 9b0cbf0 | 2014-04-11 14:24:51 -0700 | [diff] [blame] | 1007 | else |
Jason Evans | 602c8e0 | 2014-08-18 16:22:13 -0700 | [diff] [blame^] | 1008 | ret = arena_mapp_get(chunk, pageind)->prof_tctx; |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 1009 | |
| 1010 | return (ret); |
| 1011 | } |
Jason Evans | e4f7846 | 2010-10-22 10:45:59 -0700 | [diff] [blame] | 1012 | |
| 1013 | JEMALLOC_INLINE void |
Jason Evans | 602c8e0 | 2014-08-18 16:22:13 -0700 | [diff] [blame^] | 1014 | arena_prof_tctx_set(const void *ptr, prof_tctx_t *tctx) |
Jason Evans | e4f7846 | 2010-10-22 10:45:59 -0700 | [diff] [blame] | 1015 | { |
| 1016 | arena_chunk_t *chunk; |
Jason Evans | 5fbad09 | 2013-12-15 22:08:44 -0800 | [diff] [blame] | 1017 | size_t pageind; |
Jason Evans | e4f7846 | 2010-10-22 10:45:59 -0700 | [diff] [blame] | 1018 | |
Jason Evans | 7372b15 | 2012-02-10 20:22:09 -0800 | [diff] [blame] | 1019 | cassert(config_prof); |
Jason Evans | e4f7846 | 2010-10-22 10:45:59 -0700 | [diff] [blame] | 1020 | assert(ptr != NULL); |
| 1021 | assert(CHUNK_ADDR2BASE(ptr) != ptr); |
| 1022 | |
| 1023 | chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr); |
Jason Evans | ae4c7b4 | 2012-04-02 07:04:34 -0700 | [diff] [blame] | 1024 | pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE; |
Jason Evans | 5fbad09 | 2013-12-15 22:08:44 -0800 | [diff] [blame] | 1025 | assert(arena_mapbits_allocated_get(chunk, pageind) != 0); |
Jason Evans | 6657693 | 2013-12-15 16:21:30 -0800 | [diff] [blame] | 1026 | |
Jason Evans | 9b0cbf0 | 2014-04-11 14:24:51 -0700 | [diff] [blame] | 1027 | if (arena_mapbits_large_get(chunk, pageind) != 0) |
Jason Evans | 602c8e0 | 2014-08-18 16:22:13 -0700 | [diff] [blame^] | 1028 | arena_mapp_get(chunk, pageind)->prof_tctx = tctx; |
Jason Evans | e4f7846 | 2010-10-22 10:45:59 -0700 | [diff] [blame] | 1029 | } |
Jason Evans | 81b4e6e | 2010-10-20 20:52:00 -0700 | [diff] [blame] | 1030 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 1031 | JEMALLOC_ALWAYS_INLINE void * |
Jason Evans | 01b3fe5 | 2012-04-03 09:28:00 -0700 | [diff] [blame] | 1032 | arena_malloc(arena_t *arena, size_t size, bool zero, bool try_tcache) |
Jason Evans | 962463d | 2012-02-13 12:29:49 -0800 | [diff] [blame] | 1033 | { |
Jason Evans | ef8897b | 2012-02-13 14:30:52 -0800 | [diff] [blame] | 1034 | tcache_t *tcache; |
Jason Evans | 962463d | 2012-02-13 12:29:49 -0800 | [diff] [blame] | 1035 | |
| 1036 | assert(size != 0); |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 1037 | assert(size <= arena_maxclass); |
Jason Evans | 962463d | 2012-02-13 12:29:49 -0800 | [diff] [blame] | 1038 | |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 1039 | if (size <= SMALL_MAXCLASS) { |
Jason Evans | 01b3fe5 | 2012-04-03 09:28:00 -0700 | [diff] [blame] | 1040 | if (try_tcache && (tcache = tcache_get(true)) != NULL) |
Jason Evans | 962463d | 2012-02-13 12:29:49 -0800 | [diff] [blame] | 1041 | return (tcache_alloc_small(tcache, size, zero)); |
Jason Evans | 01b3fe5 | 2012-04-03 09:28:00 -0700 | [diff] [blame] | 1042 | else { |
| 1043 | return (arena_malloc_small(choose_arena(arena), size, |
| 1044 | zero)); |
| 1045 | } |
Jason Evans | 962463d | 2012-02-13 12:29:49 -0800 | [diff] [blame] | 1046 | } else { |
Jason Evans | 7468689 | 2012-02-13 15:18:19 -0800 | [diff] [blame] | 1047 | /* |
| 1048 | * Initialize tcache after checking size in order to avoid |
| 1049 | * infinite recursion during tcache initialization. |
| 1050 | */ |
Jason Evans | 01b3fe5 | 2012-04-03 09:28:00 -0700 | [diff] [blame] | 1051 | if (try_tcache && size <= tcache_maxclass && (tcache = |
| 1052 | tcache_get(true)) != NULL) |
Jason Evans | 962463d | 2012-02-13 12:29:49 -0800 | [diff] [blame] | 1053 | return (tcache_alloc_large(tcache, size, zero)); |
Jason Evans | 01b3fe5 | 2012-04-03 09:28:00 -0700 | [diff] [blame] | 1054 | else { |
| 1055 | return (arena_malloc_large(choose_arena(arena), size, |
| 1056 | zero)); |
| 1057 | } |
Jason Evans | 962463d | 2012-02-13 12:29:49 -0800 | [diff] [blame] | 1058 | } |
| 1059 | } |
| 1060 | |
Jason Evans | f7088e6 | 2012-04-19 18:28:03 -0700 | [diff] [blame] | 1061 | /* Return the size of the allocation pointed to by ptr. */ |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 1062 | JEMALLOC_ALWAYS_INLINE size_t |
Jason Evans | f7088e6 | 2012-04-19 18:28:03 -0700 | [diff] [blame] | 1063 | arena_salloc(const void *ptr, bool demote) |
| 1064 | { |
| 1065 | size_t ret; |
| 1066 | arena_chunk_t *chunk; |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 1067 | size_t pageind, binind; |
Jason Evans | f7088e6 | 2012-04-19 18:28:03 -0700 | [diff] [blame] | 1068 | |
| 1069 | assert(ptr != NULL); |
| 1070 | assert(CHUNK_ADDR2BASE(ptr) != ptr); |
| 1071 | |
| 1072 | chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr); |
| 1073 | pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE; |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 1074 | assert(arena_mapbits_allocated_get(chunk, pageind) != 0); |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 1075 | binind = arena_mapbits_binind_get(chunk, pageind); |
| 1076 | if (binind == BININD_INVALID || (config_prof && demote == false && |
Jason Evans | 9b0cbf0 | 2014-04-11 14:24:51 -0700 | [diff] [blame] | 1077 | arena_mapbits_large_get(chunk, pageind) != 0)) { |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 1078 | /* |
| 1079 | * Large allocation. In the common case (demote == true), and |
| 1080 | * as this is an inline function, most callers will only end up |
| 1081 | * looking at binind to determine that ptr is a small |
| 1082 | * allocation. |
| 1083 | */ |
Jason Evans | f7088e6 | 2012-04-19 18:28:03 -0700 | [diff] [blame] | 1084 | assert(((uintptr_t)ptr & PAGE_MASK) == 0); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 1085 | ret = arena_mapbits_large_size_get(chunk, pageind); |
Jason Evans | f7088e6 | 2012-04-19 18:28:03 -0700 | [diff] [blame] | 1086 | assert(ret != 0); |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 1087 | assert(pageind + (ret>>LG_PAGE) <= chunk_npages); |
| 1088 | assert(ret == PAGE || arena_mapbits_large_size_get(chunk, |
| 1089 | pageind+(ret>>LG_PAGE)-1) == 0); |
| 1090 | assert(binind == arena_mapbits_binind_get(chunk, |
| 1091 | pageind+(ret>>LG_PAGE)-1)); |
| 1092 | assert(arena_mapbits_dirty_get(chunk, pageind) == |
| 1093 | arena_mapbits_dirty_get(chunk, pageind+(ret>>LG_PAGE)-1)); |
| 1094 | } else { |
Jason Evans | 9b0cbf0 | 2014-04-11 14:24:51 -0700 | [diff] [blame] | 1095 | /* Small allocation (possibly promoted to a large object). */ |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 1096 | assert(arena_mapbits_large_get(chunk, pageind) != 0 || |
| 1097 | arena_ptr_small_binind_get(ptr, arena_mapbits_get(chunk, |
| 1098 | pageind)) == binind); |
Jason Evans | 3541a90 | 2014-04-16 17:14:33 -0700 | [diff] [blame] | 1099 | ret = small_bin2size(binind); |
Jason Evans | f7088e6 | 2012-04-19 18:28:03 -0700 | [diff] [blame] | 1100 | } |
| 1101 | |
| 1102 | return (ret); |
| 1103 | } |
| 1104 | |
Jason Evans | 88393cb | 2013-01-22 08:45:43 -0800 | [diff] [blame] | 1105 | JEMALLOC_ALWAYS_INLINE void |
Ben Maurer | be8e59f | 2014-04-05 15:59:08 -0700 | [diff] [blame] | 1106 | arena_dalloc(arena_chunk_t *chunk, void *ptr, bool try_tcache) |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 1107 | { |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 1108 | size_t pageind, mapbits; |
Jason Evans | 01b3fe5 | 2012-04-03 09:28:00 -0700 | [diff] [blame] | 1109 | tcache_t *tcache; |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 1110 | |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 1111 | assert(ptr != NULL); |
| 1112 | assert(CHUNK_ADDR2BASE(ptr) != ptr); |
| 1113 | |
Jason Evans | ae4c7b4 | 2012-04-02 07:04:34 -0700 | [diff] [blame] | 1114 | pageind = ((uintptr_t)ptr - (uintptr_t)chunk) >> LG_PAGE; |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 1115 | mapbits = arena_mapbits_get(chunk, pageind); |
| 1116 | assert(arena_mapbits_allocated_get(chunk, pageind) != 0); |
| 1117 | if ((mapbits & CHUNK_MAP_LARGE) == 0) { |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 1118 | /* Small allocation. */ |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 1119 | if (try_tcache && (tcache = tcache_get(false)) != NULL) { |
| 1120 | size_t binind; |
Jason Evans | 86815df | 2010-03-13 20:32:56 -0800 | [diff] [blame] | 1121 | |
Jason Evans | 80737c3 | 2012-05-02 16:11:03 -0700 | [diff] [blame] | 1122 | binind = arena_ptr_small_binind_get(ptr, mapbits); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 1123 | tcache_dalloc_small(tcache, ptr, binind); |
| 1124 | } else |
Ben Maurer | be8e59f | 2014-04-05 15:59:08 -0700 | [diff] [blame] | 1125 | arena_dalloc_small(chunk->arena, chunk, ptr, pageind); |
Jason Evans | f00bb7f | 2010-03-15 16:38:27 -0700 | [diff] [blame] | 1126 | } else { |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 1127 | size_t size = arena_mapbits_large_size_get(chunk, pageind); |
Jason Evans | dafde14 | 2010-03-17 16:27:39 -0700 | [diff] [blame] | 1128 | |
Jason Evans | 962463d | 2012-02-13 12:29:49 -0800 | [diff] [blame] | 1129 | assert(((uintptr_t)ptr & PAGE_MASK) == 0); |
Jason Evans | dafde14 | 2010-03-17 16:27:39 -0700 | [diff] [blame] | 1130 | |
Jason Evans | 01b3fe5 | 2012-04-03 09:28:00 -0700 | [diff] [blame] | 1131 | if (try_tcache && size <= tcache_maxclass && (tcache = |
| 1132 | tcache_get(false)) != NULL) { |
Jason Evans | 962463d | 2012-02-13 12:29:49 -0800 | [diff] [blame] | 1133 | tcache_dalloc_large(tcache, ptr, size); |
Jason Evans | 203484e | 2012-05-02 00:30:36 -0700 | [diff] [blame] | 1134 | } else |
Ben Maurer | be8e59f | 2014-04-05 15:59:08 -0700 | [diff] [blame] | 1135 | arena_dalloc_large(chunk->arena, chunk, ptr); |
Jason Evans | f00bb7f | 2010-03-15 16:38:27 -0700 | [diff] [blame] | 1136 | } |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 1137 | } |
Jason Evans | 3541a90 | 2014-04-16 17:14:33 -0700 | [diff] [blame] | 1138 | # endif /* JEMALLOC_ARENA_INLINE_C */ |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 1139 | #endif |
| 1140 | |
| 1141 | #endif /* JEMALLOC_H_INLINES */ |
| 1142 | /******************************************************************************/ |