merge from dev3

This commit is contained in:
daanx 2024-12-22 17:38:48 -08:00
commit b920fc1b72
14 changed files with 103 additions and 42 deletions

View file

@ -398,8 +398,8 @@ typedef enum mi_option_e {
mi_option_reclaim_on_free, // allow to reclaim an abandoned segment on a free (=1)
mi_option_full_page_retain, // retain N full pages per size class (=2)
mi_option_max_page_candidates, // max candidate pages to consider for allocation (=4)
mi_option_max_vabits, // max virtual address bits to consider in user space (=48)
mi_option_debug_commit_full_pagemap, // commit the full pagemap to catch invalid pointer uses (=0)
mi_option_max_vabits, // max user space virtual address bits to consider (=48)
mi_option_pagemap_commit, // commit the full pagemap (to always catch invalid pointer uses) (=0)
_mi_option_last,
// legacy option names
mi_option_large_os_pages = mi_option_allow_large_os_pages,

View file

@ -120,7 +120,7 @@ typedef int32_t mi_ssize_t;
// use a flat page-map (or a 2-level one)
#ifndef MI_PAGE_MAP_FLAT
#if MI_MAX_VABITS <= 40
#if MI_MAX_VABITS <= 40 && !defined(__APPLE__)
#define MI_PAGE_MAP_FLAT 1
#else
#define MI_PAGE_MAP_FLAT 0

View file

@ -445,6 +445,7 @@ static inline mi_page_t* _mi_heap_get_free_small_page(mi_heap_t* heap, size_t si
#if MI_PAGE_MAP_FLAT
// flat page-map committed on demand
// single indirection and low commit, but large initial virtual reserve (4 GiB with 48 bit virtual addresses)
extern uint8_t* _mi_page_map;
static inline size_t _mi_page_map_index(const void* p) {
@ -471,6 +472,8 @@ static inline mi_page_t* _mi_unchecked_ptr_page(const void* p) {
#else
// 2-level page map:
// double indirection but low commit and low virtual reserve.
//
// The page-map is usually 4 MiB and points to sub maps of 64 KiB.
// The page-map is committed on-demand (in 64 KiB) parts (and sub-maps are committed on-demand as well)
// One sub page-map = 64 KiB => covers 2^13 * 2^16 = 2^32 = 512 MiB address space

View file

@ -46,11 +46,13 @@ terms of the MIT license. A copy of the license can be found in the file
// Define MI_STAT as 1 to maintain statistics; set it to 2 to have detailed statistics (but costs some performance).
// #define MI_STAT 1
// Define MI_SECURE to enable security mitigations
// #define MI_SECURE 1 // guard page around metadata
// #define MI_SECURE 2 // guard page around each mimalloc page
// #define MI_SECURE 3 // encode free lists (detect corrupted free list (buffer overflow), and invalid pointer free)
// #define MI_SECURE 4 // checks for double free. (may be more expensive)
// Define MI_SECURE to enable security mitigations. The lowest two have minimal performance impact:
// #define MI_SECURE 1 // guard page around metadata
// #define MI_SECURE 2 // guard page around each mimalloc page (can fragment VMA's with large heaps..)
//
// The next two levels can have more performance cost:
// #define MI_SECURE 3 // randomize allocations, encode free lists (detect corrupted free list (buffer overflow), and invalid pointer free)
// #define MI_SECURE 4 // checks for double free. (may be more expensive)
#if !defined(MI_SECURE)
#define MI_SECURE 0