Category
php-in-php · runtime-shrink (#1492 , peer #32092 snprintf / #31885 memcpy / #31863 memset)
Problem
Always-on LibcExtern still registers libc malloc(3) / realloc(3) / free(3) on every JIT/AOT module even though:
User-script allocation is PHP (MemoryManager __mm__malloc / __mm__realloc / __mm__free) — not an always-on libc row on the user-script path.
NestedJIT leaves (~22 files) call lookupFunction('malloc'|'realloc'|'free') for compile-time C buffers and currently rely on the always-on rows.
memcpy/memset already moved to ensureMemcpyDecl / ensureMemsetDecl after always-on drops (php-in-php: drop always-on LibcExtern memcpy after NestedJIT module-local (#31863 shape) #31885 / php-in-php: drop always-on LibcExtern memset after NestedJIT module-local (#31743 shape) #31863 ). The allocator trio is the remaining libc heap surface in the always-on table (keep syscall / __phpc_host_* MCJIT aliases).
Path
Today
Target
User-script alloc
MemoryManager __mm__*
unchanged
LibcExtern
always-on malloc/realloc/free rows
drop rows
NestedJIT consumers
rely on always-on
LibcExtern::ensureMallocFamily() before lookup
MemoryManager\Native
comment: registered by LibcExtern
ensureMallocFamily in register()
EMBED MCJIT aliases
syscall / __phpc_host_*
unchanged (#98 / #21109 / #21124 )
php-src reference
PHP implementation target
Repro
./script/phpunit.sh --filter ' LibcExternDeadDeclsRuntimeShrinkTest|MallocRuntimeShrinkTest'
Done when
Category
php-in-php· runtime-shrink (#1492, peer #32092 snprintf / #31885 memcpy / #31863 memset)Problem
Always-on
LibcExternstill registers libcmalloc(3)/realloc(3)/free(3)on every JIT/AOT module even though:MemoryManager__mm__malloc/__mm__realloc/__mm__free) — not an always-on libc row on the user-script path.lookupFunction('malloc'|'realloc'|'free')for compile-time C buffers and currently rely on the always-on rows.memcpy/memsetalready moved toensureMemcpyDecl/ensureMemsetDeclafter always-on drops (php-in-php: drop always-on LibcExtern memcpy after NestedJIT module-local (#31863 shape) #31885 / php-in-php: drop always-on LibcExtern memset after NestedJIT module-local (#31743 shape) #31863). The allocator trio is the remaining libc heap surface in the always-on table (keepsyscall/__phpc_host_*MCJIT aliases).MemoryManager__mm__*LibcExternmalloc/realloc/freerowsLibcExtern::ensureMallocFamily()before lookupMemoryManager\NativeensureMallocFamilyinregister()syscall/__phpc_host_*php-src reference
Zend/zend_alloc.c— Zend heap (emalloc/erealloc/efree); libcmallocis the native floor this compiler still uses for LLVM C buffersZend/zend_alloc.hPHP implementation target
lib/JIT/LibcExtern.php— drop'malloc'/'realloc'/'free'always-on rows; addensureMallocFamily()(peerensurePosixFdphp-in-php: drop always-on LibcExtern open/close/read/write after NestedJIT declares module-locally (#31764 shape) #31817 /ensureMemcpyDeclphp-in-php: drop always-on LibcExtern memcpy after NestedJIT module-local (#31863 shape) #31885)LibcExtern::ensureMallocFamily()beforelookupFunction('malloc'|'realloc'|'free')lib/JIT/Builtin/MemoryManager/Native.pre— callensureMallocFamilyfromregister()test/unit/LibcExternDeadDeclsRuntimeShrinkTest.php+ shrink guard — assert rows gone + consumer wiringruntime/*.clogicRepro
./script/phpunit.sh --filter 'LibcExternDeadDeclsRuntimeShrinkTest|MallocRuntimeShrinkTest'Done when
LibcExternhas no always-on'malloc' =>/'realloc' =>/'free' =>rowslookupFunction('malloc'|'realloc'|'free')sites callensureMallocFamily()firstMemoryManager\Native::register()declares the trio module-locallyLibcExternDeadDeclsRuntimeShrinkTest+ shrink guard greensyscall/__phpc_host_php_write/__phpc_host_snprintfremain