Skip to content

php-in-php: superglobals_refresh.c FILES/multipart parser — migrate bracket parser to lib/Web (phase 2 of #5330) #7302

@PurHur

Description

@PurHur

Category

php-in-php | runtime | bootstrap

Problem

lib/AOT/runtime/superglobals_refresh.c is ~2594 lines of hand-written C for CGI superglobal refresh (#5330 phase 1 tracks the umbrella). A large subset (~900+ lines) implements $_FILES nested bracket parsing and multipart field name decoding — logic that belongs in lib/Web/ + ext/standard PHP and compiles through the normal pipeline.

Keeping multipart/bracket parsing in C blocks M5 self-host honesty and duplicates php-src semantics already partially mirrored in VM web tests (test/aot/NestedSuperglobalsAotTest.php).

php-src reference

Repro (C surface today)

wc -l lib/AOT/runtime/superglobals_refresh.c
grep -n 'FILES\|multipart\|bracket' lib/AOT/runtime/superglobals_refresh.c | head
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php vendor/bin/phpunit test/aot/NestedSuperglobalsAotTest.php --filter Nested
'

Today: nested $_FILES['user']['avatar'] refresh depends on C bracket parser linked from lib/AOT/Linker.php.

Scope (PHP-in-PHP)

  1. Port bracket/multipart name parsing to lib/Web/MultipartParser.php (or extend existing web helpers).
  2. AOT entry: thin C trampoline calling compiled PHP refresh helper, or pure PHP init when PHP_COMPILER_AOT_USER_SCRIPT path allows.
  3. Delete corresponding C functions from superglobals_refresh.c; target ≥800 lines removed (PR body must cite wc -l delta).
  4. Do not grow runtime/*.c with new parser tables.

Done when

Verification

make bootstrap-selfhost-helloworld
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php vendor/bin/phpunit test/aot/NestedSuperglobalsAotTest.php'

Related

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-1:web-runtimePhase 1 – CGI/web runtime

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions