1 #include "jemalloc/internal/jemalloc_preamble.h"
2 #include "jemalloc/internal/sz.h"
4 JEMALLOC_ALIGNED(CACHELINE)
5 size_t sz_pind2sz_tab[SC_NPSIZES+1];
8 sz_boot_pind2sz_tab(const sc_data_t *sc_data) {
10 for (unsigned i = 0; i < SC_NSIZES; i++) {
11 const sc_t *sc = &sc_data->sc[i];
13 sz_pind2sz_tab[pind] = (ZU(1) << sc->lg_base)
14 + (ZU(sc->ndelta) << sc->lg_delta);
18 for (int i = pind; i <= (int)SC_NPSIZES; i++) {
19 sz_pind2sz_tab[pind] = sc_data->large_maxclass + PAGE;
23 JEMALLOC_ALIGNED(CACHELINE)
24 size_t sz_index2size_tab[SC_NSIZES];
27 sz_boot_index2size_tab(const sc_data_t *sc_data) {
28 for (unsigned i = 0; i < SC_NSIZES; i++) {
29 const sc_t *sc = &sc_data->sc[i];
30 sz_index2size_tab[i] = (ZU(1) << sc->lg_base)
31 + (ZU(sc->ndelta) << (sc->lg_delta));
36 * To keep this table small, we divide sizes by the tiny min size, which gives
37 * the smallest interval for which the result can change.
39 JEMALLOC_ALIGNED(CACHELINE)
40 uint8_t sz_size2index_tab[(SC_LOOKUP_MAXCLASS >> SC_LG_TINY_MIN) + 1];
43 sz_boot_size2index_tab(const sc_data_t *sc_data) {
44 size_t dst_max = (SC_LOOKUP_MAXCLASS >> SC_LG_TINY_MIN) + 1;
46 for (unsigned sc_ind = 0; sc_ind < SC_NSIZES && dst_ind < dst_max;
48 const sc_t *sc = &sc_data->sc[sc_ind];
49 size_t sz = (ZU(1) << sc->lg_base)
50 + (ZU(sc->ndelta) << sc->lg_delta);
51 size_t max_ind = ((sz + (ZU(1) << SC_LG_TINY_MIN) - 1)
53 for (; dst_ind <= max_ind && dst_ind < dst_max; dst_ind++) {
54 sz_size2index_tab[dst_ind] = sc_ind;
60 sz_boot(const sc_data_t *sc_data) {
61 sz_boot_pind2sz_tab(sc_data);
62 sz_boot_index2size_tab(sc_data);
63 sz_boot_size2index_tab(sc_data);