Problem
bin/serve.php always uses VM (Runtime → lib/VM.php). Dev servers for Zend PHP often use OPcache; we have JIT (#153 cache) but no serve integration.
Contributors benchmarking 001-SimpleWeb cannot compare VM vs JIT latency under real HTTP without manually invoking bin/jit.php per script. 003-MiniWebApp phpc serve --jit remains blocked on project includes (#475, #1770) even after OOP compliance lands.
Goal
phpc serve --jit 127.0.0.1:8080 examples/001-SimpleWeb
Compiles .php scripts with bin/jit.php on first hit, caches (#153), falls back to VM on compile error. Output must match VM for the same request (superglobals, headers, static files).
Blocker matrix (May 2026)
| Blocker |
Issue |
Status |
Unblocks |
Static include in JIT |
#475 |
open |
flat examples 001 |
| Project graph JIT |
#1770 |
open |
003 multi-file |
| Runtime superglobals in JIT |
#49 |
partial |
per-request $_GET/$_POST |
| On-disk JIT cache |
#153 |
open |
warm second request |
| Serve tests in CI |
#234 |
closed |
local ci-local.sh |
Not required for North Star 1 — VM + AOT execute already green (#1044 ✅).
Implementation hints
| Area |
Files |
Notes |
| CLI |
bin/phpc.php, bin/serve.php |
--jit flag; document in phpc serve --help |
| Request path |
lib/Web/DevServer.php |
On cache miss: bin/jit.php compile → store artifact |
| Superglobals |
lib/Web/Superglobals.php, lib/JIT/SuperglobalInit.php |
Repopulate per request before JIT entry — verify not baked sg_* (#49) |
| Static assets |
existing static handler |
Unchanged — only .php hits JIT |
| Errors |
serve 500 mapping #152 |
JIT compile failure → VM fallback or 500 with PHP_COMPILER_DEBUG |
| Project mode |
lib/Web/ProjectManifest.php |
Defer until #1801 (phpc build --project --jit) |
Cache directory layout (v1)
.phpc/jit-cache/<sha256(realpath+mtime)>.so # or internal JIT artifact format
Invalidate when source file mtime changes.
Tests
Acceptance criteria
docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
vendor/bin/phpunit --group serve --filter ServeJit
Second request to same script is faster than first; HTML output matches VM.
Verification (local / Docker only)
./script/ci-local.sh --filter ServeJit
Do not require GitHub Actions.
Dependencies
Links
Problem
bin/serve.phpalways uses VM (Runtime→lib/VM.php). Dev servers for Zend PHP often use OPcache; we have JIT (#153 cache) but no serve integration.Contributors benchmarking 001-SimpleWeb cannot compare VM vs JIT latency under real HTTP without manually invoking
bin/jit.phpper script. 003-MiniWebAppphpc serve --jitremains blocked on project includes (#475, #1770) even after OOP compliance lands.Goal
Compiles
.phpscripts withbin/jit.phpon first hit, caches (#153), falls back to VM on compile error. Output must match VM for the same request (superglobals, headers, static files).Blocker matrix (May 2026)
includein JIT$_GET/$_POSTci-local.shNot required for North Star 1 — VM + AOT execute already green (#1044 ✅).
Implementation hints
bin/phpc.php,bin/serve.php--jitflag; document inphpc serve --helplib/Web/DevServer.phpbin/jit.phpcompile → store artifactlib/Web/Superglobals.php,lib/JIT/SuperglobalInit.phpsg_*(#49).phphits JITPHP_COMPILER_DEBUGlib/Web/ProjectManifest.phpphpc build --project --jit)Cache directory layout (v1)
Invalidate when source file mtime changes.
Tests
test/unit/ServeJitTest.php—@group llvm+@group serveexamples/001-SimpleWeb/example.php?name=DevLlvmToolchain::isReady()false (same as Testing: JIT smoke for phpc build --project on 003-MiniWebApp #587)Acceptance criteria
Second request to same script is faster than first; HTML output matches VM.
Verification (local / Docker only)
Do not require GitHub Actions.
Dependencies
Links