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)
- Port bracket/multipart name parsing to
lib/Web/MultipartParser.php (or extend existing web helpers).
- AOT entry: thin C trampoline calling compiled PHP refresh helper, or pure PHP init when
PHP_COMPILER_AOT_USER_SCRIPT path allows.
- Delete corresponding C functions from
superglobals_refresh.c; target ≥800 lines removed (PR body must cite wc -l delta).
- 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
Category
php-in-php|runtime|bootstrapProblem
lib/AOT/runtime/superglobals_refresh.cis ~2594 lines of hand-written C for CGI superglobal refresh (#5330 phase 1 tracks the umbrella). A large subset (~900+ lines) implements$_FILESnested bracket parsing and multipart field name decoding — logic that belongs inlib/Web/+ext/standardPHP 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
main/php_variables.c—php_parse_multipart_datamain/rfc1867.c— multipart form parsinglib/Web/CgiAotDriver.php,examples/006-FileUploadWebRepro (C surface today)
Today: nested
$_FILES['user']['avatar']refresh depends on C bracket parser linked fromlib/AOT/Linker.php.Scope (PHP-in-PHP)
lib/Web/MultipartParser.php(or extend existing web helpers).PHP_COMPILER_AOT_USER_SCRIPTpath allows.superglobals_refresh.c; target ≥800 lines removed (PR body must citewc -ldelta).runtime/*.cwith new parser tables.Done when
NestedSuperglobalsAotTestgreen without C bracket parser bodiesexamples/006-FileUploadWebAOT smoke still passessuperglobals_refresh.cshrinks to env/string refresh ABI only (progress note testProgressNoteRuntimeStandaloneTestpattern)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