Skip to content

php-in-php: drop always-on LibcExtern strlen after NestedJIT module-local (#31997 shape) #32068

Description

@PurHur

Category

php-in-php · runtime-shrink (#1492, peer #31997 strtod / #31988 strtol / #31971 strcmp)

Problem

Always-on LibcExtern still registers libc strlen(3) even though:

  1. User-script strlen() already lives in PHP (ext/types/strlen.php + JitStrlen / VmString::byteLength) — not libc on char*.
  2. ~65 NestedJIT leaves call lookupFunction('strlen') for compile-time C-string length (session/stream/ob/parse_str/CLI/Reflection/env) — they rely on the always-on row.
  3. ext/standard/Module.php jitInit still always-declares strlen as a fallback — that path should drop with the LibcExtern row (peer php-in-php: drop always-on LibcExtern strtod after NestedJIT module-local (#31988 shape) #31997 strtod).
Path Today Target
User-script strlen() ext/types PHP (JitStrlen) unchanged
LibcExtern always-on strlen row drop row
NestedJIT consumers rely on always-on LibcExtern::ensureStrlenDecl() before lookup
Module::jitInit always-on strlen fallback drop; comment peer #31997
EMBED MCJIT implementStrlenBody after always-on decl ensureStrlenDecl then body (#98 / #21109)

php-src reference

PHP implementation target

  • lib/JIT/LibcExtern.php — drop 'strlen' always-on row; add ensureStrlenDecl(); implementStrlenBody calls it first
  • NestedJIT consumers call LibcExtern::ensureStrlenDecl() before lookupFunction('strlen')
  • ext/standard/Module.php — drop always-on strlen jitInit fallback
  • test/unit/LibcExternDeadDeclsRuntimeShrinkTest.php + StrlenRuntimeShrinkTest — assert row gone + consumer wiring

Repro

./script/phpunit.sh --filter LibcExternDeadDeclsRuntimeShrinkTest
./script/phpunit.sh --filter StrlenRuntimeShrinkTest

Done when

  • LibcExtern has no always-on 'strlen' => row
  • All NestedJIT lookupFunction('strlen') sites call ensureStrlenDecl() first (or declare module-locally)
  • LibcExternDeadDeclsRuntimeShrinkTest + shrink guard green
  • php-src-strict; user-script strlen() behavior unchanged

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