Skip to content

php-in-php: drop always-on Builtin\Output sprintf after NestedJIT snprintf migration (#32092 shape) #32110

Description

@PurHur

Category

php-in-php · runtime-shrink (#1492, peer #32092 snprintf / #31706 printf)

Problem

Always-on Builtin\Output still registers libc sprintf(3) (Output.pre declare { function sprintf(char*, const char*, ...): int32; }) even though:

  1. User-script sprintf() already lives in PHP (JitPrintf / SprintfSnprintfRuntime / __compiler_sprintf) — not this always-on libc row.
  2. NestedJIT has only two lookupFunction('sprintf') consumers: HashTableWriteLlvm::objectPointerAsStringKey (bounded 32-byte SplObjectStorage key buffer) and ext/filter/JitFilter::jitScalarToString (native long/double → string). Both should use module-local snprintf like the php-in-php: drop always-on LibcExtern snprintf after NestedJIT module-local (#32068 shape) #32092 leaves.
  3. LibcExtern already dropped always-on snprintf (php-in-php: drop always-on LibcExtern snprintf after NestedJIT module-local (#32068 shape) #32092); this leftover sprintf row in Output is the sibling still declared on every module.
Path Today Target
User-script sprintf()/printf() PHP helpers (JitPrintf / SprintfSnprintfRuntime) unchanged
Builtin\Output always-on libc sprintf drop declare
NestedJIT consumers rely on always-on sprintf LibcExtern::ensureSnprintf() + snprintf
EMBED MCJIT __phpc_host_snprintf always-on alias unchanged (#98 / #21109 / #21124)

php-src reference

PHP implementation target

  • lib/JIT/Builtin/Output.pre / Output.php — drop always-on libc sprintf declare
  • lib/JIT/HashTableWriteLlvm.phpobjectPointerAsStringKey uses ensureSnprintf() + snprintf (drop sprintf/strlen)
  • ext/filter/JitFilter.phpjitScalarToString long/double uses ensureSnprintf() + __string__init
  • test/unit/SprintfRuntimeShrinkTest.php — assert Output no longer addFunction('sprintf'); consumers call ensureSnprintf

Repro

./script/phpunit.sh --filter 'SprintfRuntimeShrinkTest|LibcExternDeadDeclsRuntimeShrinkTest|SnprintfRuntimeShrinkTest'

Done when

  • Builtin\Output has no always-on libc sprintf declare
  • No NestedJIT lookupFunction('sprintf') remains
  • SplObjectStorage pointer keys and filter scalar-to-string still compile via snprintf
  • php-src-strict; user-script sprintf() behavior unchanged
  • __phpc_host_snprintf always-on alias remains for EMBED MCJIT

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