Problem
lib/JIT/SuperglobalInit.php copies superglobals from the VM context at compile/init time into LLVM globals (sg_GET, etc.). For AOT, bin/compile.php -q 'name=World' bakes query data into the binary—see examples/001-SimpleWeb/example.php comments and test/fixtures/aot/cases/simple_web_get.phpt.
A real web server invokes the same binary per request with different QUERY_STRING / POST body. Today that requires recompiling or using VM mode only.
Goal
Support runtime superglobal population in JIT and AOT standalone binaries.
Design sketch
- At process start (or per CGI request), parse
QUERY_STRING / stdin POST via C/LLVM helpers or a small runtime init calling into existing PHPCompiler\Web\Superglobals logic ported to native code.
- Replace compile-time-only
SuperglobalInit::populateFromVm with:
- AOT: init function
__superglobals_init() called from main before user code
- JIT embed: refresh globals when CLI passes
-q/-p each run (already partially true via VM pre-populate)
- Keep optional compile-time specialization when
-q is passed (optimization, not requirement)
Tasks
Acceptance criteria
./compiled_binary with QUERY_STRING=name=Alice and QUERY_STRING=name=Bob produces different HTML without re-running bin/compile.php.
Key files
lib/JIT/SuperglobalInit.php
lib/Web/Superglobals.php
bin/compile.php, bin/jit.php
Problem
lib/JIT/SuperglobalInit.phpcopies superglobals from the VM context at compile/init time into LLVM globals (sg_GET, etc.). For AOT,bin/compile.php -q 'name=World'bakes query data into the binary—seeexamples/001-SimpleWeb/example.phpcomments andtest/fixtures/aot/cases/simple_web_get.phpt.A real web server invokes the same binary per request with different
QUERY_STRING/ POST body. Today that requires recompiling or using VM mode only.Goal
Support runtime superglobal population in JIT and AOT standalone binaries.
Design sketch
QUERY_STRING/ stdin POST via C/LLVM helpers or a small runtime init calling into existingPHPCompiler\Web\Superglobalslogic ported to native code.SuperglobalInit::populateFromVmwith:__superglobals_init()called frommainbefore user code-q/-peach run (already partially true via VM pre-populate)-qis passed (optimization, not requirement)Tasks
sg_*globals from env (getenv) in standalone binariesQUERY_STRINGvalues → different outputIssetHelper/empty()for dynamic keys (not onlycompileTimeOffsetIsSet)Acceptance criteria
./compiled_binarywithQUERY_STRING=name=AliceandQUERY_STRING=name=Bobproduces different HTML without re-runningbin/compile.php.Key files
lib/JIT/SuperglobalInit.phplib/Web/Superglobals.phpbin/compile.php,bin/jit.php