Category
php-in-php · php-src-strict runtime · refs #1492
Problem
Fiber MCJIT lowering is a ~587-line monolith in lib/JIT/FiberHelper.php (resume-ip switch functions, suspend static sites, stack limits). VM fiber semantics already live in PHP: lib/VM/FiberSupport.php, lib/VM/FiberState.php, lib/VM/Builtin/Fiber*.php mirroring php/php-src Zend/zend_fibers.c.
Maintaining fiber edge cases twice (VM vs LLVM) blocks #3130 / #4019 parity and self-host compile of compiler sources using Fiber.
php-src reference
Repro
test/repro/fiber_jit_vm_agree.php:
<?php
declare(strict_types=1);
$fiber = new Fiber(function (): int {
Fiber::suspend('step1');
return 42;
});
var_export($fiber->start());
echo "\n";
var_export($fiber->resume());
echo "\n";
var_export($fiber->getReturn());
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/fiber_jit_vm_agree.php
php bin/jit.php test/repro/fiber_jit_vm_agree.php'
| Step |
Expected (Zend) |
start() |
'step1' |
resume() |
42 |
getReturn() |
42 |
Any JIT divergence from VM output is in scope for this migration.
Scope (PHP-in-PHP first)
| Path |
Work |
lib/VM/FiberSupport.php |
Canonical suspend/resume/throw state machine |
lib/JIT/FiberHelper.php |
Replace resume-ip LLVM switch with calls into compiled FiberSupport helpers |
lib/JIT/Call/Fiber*.php |
Trampoline to PHP lowering |
| Tests |
test/compliance/cases/language/fiber_jit_vm_agree.phpt |
No: no new runtime/*.c — fiber stack guard may stay as thin ABI only (#4019).
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter Fiber'
Related
Category
php-in-php· php-src-strict runtime · refs #1492Problem
Fiber MCJIT lowering is a ~587-line monolith in
lib/JIT/FiberHelper.php(resume-ip switch functions, suspend static sites, stack limits). VM fiber semantics already live in PHP:lib/VM/FiberSupport.php,lib/VM/FiberState.php,lib/VM/Builtin/Fiber*.phpmirroring php/php-srcZend/zend_fibers.c.Maintaining fiber edge cases twice (VM vs LLVM) blocks #3130 / #4019 parity and self-host compile of compiler sources using
Fiber.php-src reference
Zend/zend_fibers.c— suspend/resume/throw/getReturnext/reflection/php_reflection.c—ReflectionFiber(Stdlib: ReflectionFiber — introspection for Fiber objects (ext/reflection/php_reflection.c) #4609)Repro
test/repro/fiber_jit_vm_agree.php:start()'step1'resume()42getReturn()42Any JIT divergence from VM output is in scope for this migration.
Scope (PHP-in-PHP first)
lib/VM/FiberSupport.phplib/JIT/FiberHelper.phpFiberSupporthelperslib/JIT/Call/Fiber*.phptest/compliance/cases/language/fiber_jit_vm_agree.phptNo: no new
runtime/*.c— fiber stack guard may stay as thin ABI only (#4019).Done when
FiberHelper.phpshrinks to registration + trampoline (target ≤ ~150 lines)./script/ci-fast.sh --filter FiberJitgreenVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter Fiber'Related