Skip to content

php-in-php: phpc_stream.c wrapper stack — register/restore in ext/standard PHP before deleting ~867 lines (#5343) #6821

Closed

Description

@PurHur

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

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

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter stream_wrapper'

Related

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 6, 2026
  2. PurHur commented on Jun 8, 2026

    @PurHur
    OwnerAuthor

    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).

  3. PurHur commented on Jun 8, 2026

    @PurHur
    OwnerAuthor

    Merged via #7610.

    C shrink: 43 lines removed from lib/AOT/runtime/phpc_stream.c (771→728) — __compiler_get_resource_type / __compiler_get_resources deleted.

    PHP LLVM: lib/JIT/Builtin/StreamResourceJit.php + StreamResource.php, wired from Type::initialize().

    Verification (green):

    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter "StreamResourceRuntimeStandalone|StreamCapsRuntimeStandalone|get_resources_jit"'
    # OK (5 tests, 19 assertions)
    

    Handoff: remaining ~728 lines in phpc_stream.c (fopen/fread/fwrite handle table + wrapper stack per #6821).

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