| 2400 | } |
| 2401 | |
| 2402 | JEMALLOC_ALWAYS_INLINE void * |
| 2403 | imalloc_sample(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd, |
| 2404 | size_t usize, szind_t ind) { |
| 2405 | void *ret; |
| 2406 | |
| 2407 | /* |
| 2408 | * For small allocations, sampling bumps the usize. If so, we allocate |
| 2409 | * from the ind_large bucket. |
| 2410 | */ |
| 2411 | szind_t ind_large; |
| 2412 | size_t bumped_usize = usize; |
| 2413 | |
| 2414 | dopts->alignment = prof_sample_align(dopts->alignment); |
| 2415 | if (usize <= SC_SMALL_MAXCLASS) { |
| 2416 | assert(((dopts->alignment == 0) ? |
| 2417 | sz_s2u(SC_LARGE_MINCLASS) : |
| 2418 | sz_sa2u(SC_LARGE_MINCLASS, dopts->alignment)) |
| 2419 | == SC_LARGE_MINCLASS); |
| 2420 | ind_large = sz_size2index(SC_LARGE_MINCLASS); |
| 2421 | bumped_usize = sz_s2u(SC_LARGE_MINCLASS); |
| 2422 | ret = imalloc_no_sample(sopts, dopts, tsd, bumped_usize, |
| 2423 | bumped_usize, ind_large); |
| 2424 | if (unlikely(ret == NULL)) { |
| 2425 | return NULL; |
| 2426 | } |
| 2427 | arena_prof_promote(tsd_tsdn(tsd), ret, usize); |
| 2428 | } else { |
| 2429 | ret = imalloc_no_sample(sopts, dopts, tsd, usize, usize, ind); |
| 2430 | } |
| 2431 | assert(prof_sample_aligned(ret)); |
| 2432 | |
| 2433 | return ret; |
| 2434 | } |
| 2435 | |
| 2436 | /* |
| 2437 | * Returns true if the allocation will overflow, and false otherwise. Sets |
no test coverage detected