Skip to content

php-in-php: JIT StringReadfile — route readfile() through VmFs PHP not __compiler_readfile libc LLVM (#1492) #9188

Description

@PurHur

Category

php-in-php · stdlib

Problem

readfile() VM path already uses PHP (ext/standard/readfile.phpVmFs::readfile()), but JIT/AOT still calls LLVM helper __compiler_readfile implemented in lib/JIT/Builtin/StringReadfile.php with direct open/read/write libc FFI.

Workers should route JIT lowering through the same PHP semantics (ext/standard/JitReadfile.php → shared VmFs/VmFsReadNative) and delete/shrink the standalone libc LLVM body.

php-src reference

Repro (JIT divergence)

<?php
$path = sys_get_temp_dir() . '/phpc_readfile_' . getmypid() . '.txt';
file_put_contents($path, 'abc');
$n = readfile($path);
@unlink($path);
var_export($n);
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro_readfile.php
php bin/jit.php repro_readfile.php'

Today VM uses PHP VmFs; JIT uses __compiler_readfile LLVM — parity issue is JIT lowering path, not missing builtin.

Scope (this repo)

Layer Path
VM (source of truth) ext/standard/readfile.php, ext/standard/VmFs.php
JIT today ext/standard/JitReadfile.php, lib/JIT/Builtin/StringReadfile.php
Target JIT calls compiled PHP/native shim shared with VM; remove libc read loop from StringReadfile.php

Pairs #8920 (VmFsReadNative / file_get_contents PHP path).

Done when

  • JIT readfile() returns same byte count / false as VM on repro
  • AOT agrees when readfile is in compile unit
  • lib/JIT/Builtin/StringReadfile.php libc FFI removed or reduced to thin ABI trampoline
  • PR body notes lines removed from LLVM/C helper vs PHP path added
  • ./script/ci-fast.sh --filter Readfile (or new compliance PHPT) green

Related

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 & DevExphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions