Skip to content

php-in-php: drop always-on LibcExtern malloc/realloc/free after NestedJIT module-local (#32092 shape) #32273

Description

@PurHur

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:

  1. User-script allocation is PHP (MemoryManager __mm__malloc / __mm__realloc / __mm__free) — not an always-on libc row on the user-script path.
  2. NestedJIT leaves (~22 files) call lookupFunction('malloc'|'realloc'|'free') for compile-time C buffers and currently rely on the always-on rows.
  3. 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

  • LibcExtern has no always-on 'malloc' => / 'realloc' => / 'free' => rows
  • All NestedJIT lookupFunction('malloc'|'realloc'|'free') sites call ensureMallocFamily() first
  • MemoryManager\Native::register() declares the trio module-locally
  • LibcExternDeadDeclsRuntimeShrinkTest + shrink guard green
  • php-src-strict; user-script alloc behavior unchanged
  • syscall / __phpc_host_php_write / __phpc_host_snprintf remain

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevEx

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions