Repository navigation
php-in-php: phpc_stream.c wrapper stack — register/restore in ext/standard PHP before deleting ~867 lines (#5343) #6821
Copy link
Copy link
Closed
Labels
area:compilerCompiler / CFG / JITCompiler / CFG / JITarea:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web appsPhase 4 – stdlib for web apps
Description
Category
php-in-PHP | stdlib
Problem
Custom stream protocol registration (#3383, #6805, #6818 stream_wrapper_restore) requires a per-scheme wrapper stack like Zend php_stream_wrappers.c. Today JIT/AOT link lib/AOT/runtime/phpc_stream.c (~867 lines) for FILE* tables and stream resources, while PHP VM stream helpers in ext/standard/VmFs.php / VmStream.php duplicate partial semantics.
Workers implementing #6818 must not grow phpc_stream.c with wrapper-class tables — implement the stack in PHP first, then delete C once JIT/AOT call compiled PHP (#5343).
php-src reference
- php/php-src
ext/standard/streams.c—stream_wrapper_register/unregister/restore - php/php-src
main/streams/php_stream_wrappers.c— wrapper ops vector + restore stack
Repro (motivation)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
wc -l lib/AOT/runtime/phpc_stream.c
php bin/vm.php -r "var_export(function_exists(\"stream_wrapper_restore\"));"
'| Metric | Today |
|---|---|
phpc_stream.c lines |
~867 |
stream_wrapper_restore |
undefined (#6818) |
| C growth risk | new wrapper logic would extend C |
Scope (this repo)
| Path | Work |
|---|---|
ext/standard/VmStreamWrapperRegistry.php (new) |
Scheme → stack of php_user_stream_wrapper equivalents |
ext/standard/stream_wrapper_*.php |
VM builtins delegating to registry |
lib/JIT/Builtin/ |
Phase 2: LLVM calls PHP registry, not new C tables |
lib/AOT/runtime/phpc_stream.c |
Delete wrapper-stack logic after PHP path green |
lib/AOT/Linker.php |
Drop C TU when parity proven |
Done when
- Stdlib: stream_wrapper_restore() — restore built-in stream protocol (ext/standard/streams.c, pairs #3383) #6818 repro passes using PHP-only wrapper stack (no new C symbols)
-
phpc_stream.cline count reduced (document lines removed in PR) -
./script/ci-fast.sh --filter stream_wrappergreen on VM - JIT/AOT stream open still works for
file://(regression guard)
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter stream_wrapper'Related
- Stdlib: stream_wrapper_restore() — restore built-in stream protocol (ext/standard/streams.c, pairs #3383) #6818 · Stdlib: stream_wrapper_register() — custom stream protocol handlers (ext/standard/streams.c parity) #3383 · php-in-php: stream handle registry — delete phpc_stream.c (~1059 lines), FILE* table in ext/standard #5343 · Epic: Self-host critical path — compiler compiles itself (M3→M5) #1492
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:compilerCompiler / CFG / JITCompiler / CFG / JITarea:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web appsPhase 4 – stdlib for web apps
Activity
PurHur commentedon Jun 8, 2026
claim: PHP Runtime → PHP — starting this run (#6821 phase: migrate __compiler_get_resource_type/__compiler_get_resources from phpc_stream.c to StreamResourceJit LLVM, ~70 lines C removed).
php-in-php: migrate get_resource_type/get_resources JIT off phpc_stre…
PurHur commentedon Jun 8, 2026
Merged via #7610.
C shrink: 43 lines removed from
lib/AOT/runtime/phpc_stream.c(771→728) —__compiler_get_resource_type/__compiler_get_resourcesdeleted.PHP LLVM:
lib/JIT/Builtin/StreamResourceJit.php+StreamResource.php, wired fromType::initialize().Verification (green):
Handoff: remaining ~728 lines in
phpc_stream.c(fopen/fread/fwrite handle table + wrapper stack per #6821).