AK: Adopt mimalloc v2 as main allocator

Use mimalloc for Ladybird-owned allocations without overriding malloc().
Route kmalloc(), kcalloc(), krealloc(), and kfree() through mimalloc,
and put the embedded Rust crates on the same allocator via a shared
shim in AK/kmalloc.cpp.

This also lets us drop kfree_sized(), since it no longer used its size
argument. StringData, Utf16StringData, JS object storage, Rust error
strings, and the CoreAudio playback helpers can all free their AK-backed
storage with plain kfree().

Sanitizer builds still use the system allocator. LeakSanitizer does not
reliably trace references stored in mimalloc-managed AK containers, so
static caches and other long-lived roots can look leaked. Pass the old
size into the Rust realloc shim so aligned fallback reallocations can
move posix_memalign-backed blocks safely.

Static builds still need a little linker help. macOS app binaries need
the Rust allocator entry points forced in from liblagom-ak.a, while
static ELF links can pull in identical allocator shim definitions from
multiple Rust staticlibs. Keep the Apple -u flags and allow those
duplicate shim symbols for LibJS and LibRegex links on Linux and BSD.
This commit is contained in:
Andreas Kling
2026-04-03 17:06:58 +02:00
committed by Andreas Kling
parent 648ececa62
commit b23aa38546
Notes: github-actions[bot] 2026-04-08 07:58:49 +00:00
27 changed files with 349 additions and 53 deletions

View File

@@ -113,6 +113,7 @@
"name": "mman",
"platform": "windows"
},
"mimalloc",
"openssl",
{
"name": "pthread",
@@ -309,6 +310,10 @@
"name": "libxml2",
"version": "2.13.8#1"
},
{
"name": "mimalloc",
"version": "2.2.7"
},
{
"name": "mman",
"version": "git-f5ff813#5"