Skip to content

php-in-php: delete JitFilePutContentsLibc/JitReadfileLibc — VmFsWritePure must not recurse via file_put_contents (#1492) #20266

Description

@PurHur

Category

php-in-php · runtime-shrink (#1492, follow #19339 FGC / #19966 / #20256 handoff)

Problem

StringFilePutContents / StringReadfile still fork isThinStandaloneAotMain() → Jit*Libc while embed uses helpers. Helpers call phpc_*_kernel which re-emits the same libc. Always-helper (FGC #19339 shape) was blocked because VmFsWritePure::write() calls host \file_put_contents(), which NestedJIT lowers back into __compiler_file_put_contents → helper → recursion (writes fail / return 0).

Mode Today Target
Embed / non-thin Helper → phpc_*_kernel libc Helper → VmFs::* (FGC/Unlink shape)
Thin standalone AOT Direct Jit*Libc on ABI Same helper bridge (no thin fork)
VmFsWritePure \file_put_contents (recurses under NestedJIT) fopen/fwrite/fclose (StreamIo / no FPC ABI)

php-src reference

PHP implementation target

  • ext/standard/VmFsWritePure.php — rewrite without \file_put_contents (fopen/fwrite/flock/fclose; keep APPEND + LOCK_EX)
  • ext/standard/FilePutContentsJitHelper.php — VmFs::filePutContents (false→-1)
  • ext/standard/ReadfileJitHelper.php — VmFs::readfile (false→-1)
  • lib/JIT/Builtin/StringFilePutContents.php / StringReadfile.php — always JitVmHelperLink; drop implementLibcBody / isThinStandaloneAotMain
  • Delete JitFilePutContentsLibc.php, JitReadfileLibc.php, phpc_file_put_contents_kernel.php, phpc_readfile_kernel.php; drop Module + spine requires
  • Update FilePutContentsRuntimeShrinkTest / ReadfileRuntimeShrinkTest

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
vendor/bin/phpunit test/unit/FilePutContentsRuntimeShrinkTest.php test/unit/ReadfileRuntimeShrinkTest.php
vendor/bin/phpunit test/aot/AotTest.php --filter file_put_contents
vendor/bin/phpunit test/aot/AotTest.php --filter readfile
PHP_COMPILER_HELPER_RUNTIME_O=1 PHP_COMPILER_AOT_USER_SCRIPT=1 ./phpc build -o /tmp/fpc-aot test/fixtures/aot/cases/file_put_contents.phpt
make bootstrap-selfhost-vm-driver-execute-probe
php script/bootstrap-inventory.php --check
'

Done when

  • VmFsWritePure no longer calls \file_put_contents
  • Both Jit*Libc + phpc_*_kernel files deleted
  • No isThinStandaloneAotMain / implementLibcBody on FPC/readfile ABI path
  • Helpers call VmFs; shrink + AOT fixtures green
  • make bootstrap-selfhost-vm-driver-execute-probe green
  • PR body cites lines/files removed

Refs #1492, #19339, #19966, #20256

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