Skip to content

php-in-php: glob/scandir/chmod/touch — delete phpc_fs_dir.c (~760 lines), JIT from ext/standard/VmFsGlob.php #5459

Description

@PurHur

Category

php-in-php | stdlib

Problem

Directory and path builtins (glob, scandir, chmod, chown, chgrp, touch, utime, …) have PHP VM paths (ext/standard/VmFsGlob.php, VmFs.php) but AOT/JIT still link a large C helper table:

  • lib/AOT/runtime/phpc_fs_dir.c~760 lines (glob/scandir/chmod/…)
  • Registered in lib/AOT/Linker.php (phpc_fs_dir.c)

This duplicates logic already moving PHP-ward and blocks shrinking the C runtime per #1492 / PHP-in-PHP strategy.

php-src reference

Repro (C dependency today)

grep phpc_fs_dir lib/AOT/Linker.php
wc -l lib/AOT/runtime/phpc_fs_dir.c
# 760 lib/AOT/runtime/phpc_fs_dir.c

./script/docker-exec.sh bash -lc 'source script/ci-defaults.env && make bootstrap-selfhost-link'
# links phpc_fs_dir.o even when VM uses VmFsGlob.php

VM glob() already works via FFI (ext/standard/VmFsGlob.php, #4859); AOT should lower to the same PHP/FFI path, not __phpc_glob_vec C.

Scope (this repo)

Layer Path
Delete C lib/AOT/runtime/phpc_fs_dir.c, remove from lib/AOT/Linker.php
JIT/AOT lib/JIT/Builtin/ handlers calling VmFsGlob / VmFs (thin libc FFI only)
VM keep ext/standard/glob_.php, scandir.php, chmod_.php, …
Tests existing JIT/AOT PHPT for glob/scandir; add chmod/touch if missing
Matrix php script/capability-matrix.php

Done when

  • phpc_fs_dir.c removed; ~760 lines deleted from runtime/`
  • AOT link succeeds without __phpc_glob_vec / C dir helpers
  • glob(), scandir(), chmod() parity tests green on VM + AOT
  • ./script/ci-fast.sh --filter 'Glob|Scandir|Chmod' green (or targeted PHPT names)
  • No new logic added to runtime/*.c — libc calls stay in PHP FFI shims

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 / JITarea:vmVirtual machineenhancementNew 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