Skip to content

php-in-php: drop always-on LibcExtern open/close/read/write after NestedJIT declares module-locally (#31764 shape) #31817

Description

@PurHur

Category

php-in-php · runtime-shrink (#1492, peer #31764 / #31606 / #31706)

Problem

Always-on LibcExtern still registers libc open/close/read/write even though:

  1. User-script file/stream I/O already routes through PHP (StreamIoJitHelper / FileGetContentsJitHelper / __compiler_* — not raw libc fd ops as the PHP builtin ABI).
  2. Several NestedJIT leaves already declare the symbols they need module-locally (TouchLibcRuntime, JitStreamIoKernel::ensureLibc close, JitTempnamKernel, ObStorageLlvm write); the rest only need a shared ensurePosixFd() before lookup (peer ensureStdioFile php-in-php: drop always-on LibcExtern fopen/fread/fwrite/fclose after stream kernels declare module-locally (#31606 shape) #31764).
Symbol NestedJIT lookupFunction consumers (sample) Already module-local
open SessionStorage, FileGetContentsLibc, ReadfileLibc, RandomBytes, Gethostname, TouchLibc TouchLibc
close same + StreamIoKernel, TempnamKernel TouchLibc, StreamIo, Tempnam
read SessionStorage, FileGetContentsLibc, ReadfileLibc, RandomBytes, Gethostname, SocketPairIo
write SessionStorage, ReadfileLibc, ObStorage, ObWriteStdout, ProgressNote, EmbedObEcho, SocketPairIo ObStorage
Path Today Target
User-script fopen/file_get_contents/readfile/… PHP helpers / __compiler_* unchanged
LibcExtern always-on open/close/read/write drop rows
NestedJIT fd leaves rely on always-on (or local ensure) LibcExtern::ensurePosixFd() + existing local ensures

php-src reference

  • php/php-src ext/standard/file.c — stream/file builtins (user-script semantics stay in PHP)
  • NestedJIT uses libc open/read/write/close only as thin platform ABI trampolines inside NestedJIT leaves

PHP implementation target

  • lib/JIT/LibcExtern.php — drop always-on rows; add ensurePosixFd()
  • NestedJIT consumers that still rely on always-on — call ensurePosixFd before lookup
  • test/unit/LibcExternDeadDeclsRuntimeShrinkTest.php (+ targeted shrink guards)
  • test/repro/issue_<n>_posix_fd.php — file_get_contents / echo smoke

Repro / verify

./script/phpunit.sh --filter 'LibcExternDeadDeclsRuntimeShrinkTest|LibcNameCollisionRuntimeShrinkTest'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/issue_NNNN_posix_fd.php'
./script/docker-exec.sh -- bash -lc 'php bin/jit.php test/repro/issue_NNNN_posix_fd.php'

Done when

  • LibcExtern has no 'open'|'close'|'read'|'write' => always-on rows
  • NestedJIT consumers declare via ensurePosixFd or existing module-local ensure before lookup
  • User-script file I/O / echo still matches Zend via VM/JIT
  • No new lib/AOT/runtime/*.c
  • php-src-strict; no php-compiler-strict shortcut

Note

#10533 comments are locked (2500+); candidate recorded here instead of a tracker comment.

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