Expand description
Core size constants, mirroring mimalloc v2.4.5 include/mimalloc/types.h.
Only constants verified against the oracle header live here. Anything still
unverified is introduced in the milestone that implements it, alongside the
G2 differential test that pins it (plan §4). In particular the full bin
geometry (bin(size) mapping) lands in M2 pinned by mi_good_size equality.
Constants§
- BIN_
FULL - The full-page queue index (
MI_BIN_FULL=BIN_HUGE + 1). - BIN_
HUGE - Index of the largest size bin (
MI_BIN_HUGE= 73). Bins1..=BIN_HUGEhold size-class page queues;BIN_FULLis the queue of full pages. - INTPTR_
SIZE - Word size in bytes (
MI_INTPTR_SIZE). We target 64-bit first. - LARGE_
OBJ_ SIZE_ MAX - Largest object served from an in-segment large page
(
MI_LARGE_OBJ_SIZE_MAX= SEGMENT_SIZE/2 = 16 MiB). Above this a dedicated huge segment is used. - MAX_
ALIGN_ SIZE - Guaranteed natural alignment of every allocation (
MI_MAX_ALIGN_SIZE= 16):mi_malloc(n)forn >= 16returns 16-byte-aligned memory, matchingmax_align_texpectations of C callers. - MEDIUM_
OBJ_ SIZE_ MAX - Largest binned object (
MI_MEDIUM_OBJ_SIZE_MAX= 64 KiB) — G2-verified: the oracle’smi_good_sizeswitches to page-rounding above this. - MEDIUM_
PAGE_ SIZE - Medium page size in bytes.
- MEDIUM_
PAGE_ SLICES - A medium page spans 8 slices (
MI_MEDIUM_PAGE_SIZE= 512 KiB). - SEGMENT_
SIZE - Segment size (
MI_SEGMENT_SIZE= 32 MiB on 64-bit): the unit of OS/arena allocation, and the shift+mask that takes any block pointer to its segment (which is why segments are segment-size-aligned). - SEGMENT_
SLICE_ SIZE - Segment slice size (
MI_SEGMENT_SLICE_SIZE= 64 KiB on 64-bit): the granularity v2 segments are carved in. A small page is one slice. - SLICES_
PER_ SEGMENT - Slices per segment (
MI_SLICES_PER_SEGMENT= 512). - SMALL_
OBJ_ SIZE_ MAX - Largest object served from a small page (
MI_SMALL_OBJ_SIZE_MAX= 8 KiB). - SMALL_
PAGE_ SIZE - A small page is one slice (
MI_SMALL_PAGE_SIZE= 64 KiB). - SMALL_
SIZE_ MAX - Maximum “small” allocation in bytes (
MI_SMALL_SIZE_MAX= 1 KiB on 64-bit).mi_malloc_small/mi_zalloc_smallrequiresize <= SMALL_SIZE_MAX. - SMALL_
WSIZE_ MAX - Maximum “small” allocation in machine words (
MI_SMALL_WSIZE_MAX= 128).
Functions§
- wsize_
from_ size - Size in machine words, rounded up (
_mi_wsize_from_size).