Category
php-in-php · compile/runtime shared
Problem
lib/JIT/CoalesceHelper.php lowers the ?? null coalescing operator in LLVM with inline null/unset probes. VM path implements full php-src semantics in PHP (lib/VM.php). Duplicated logic drifts on edge cases (undefined variables, property hooks, ArrayAccess offsets).
Per #1492, coalesce behavior belongs in lib/VM/ with JIT as thin trampoline — same pattern as #10046 (CastHelper) and #10154 (NullsafeHelper).
php-src reference
Repro (architectural)
<?php
$x = null;
echo $x ?? 5, "\n";
echo ($undefined ?? 'd'), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
wc -l lib/JIT/CoalesceHelper.php
Scope (this repo)
| Layer |
Path |
| Extract VM |
lib/VM/VmCoalesce.php (new) — shared ?? semantics |
| JIT shrink |
lib/JIT/CoalesceHelper.php → trampoline |
| Tests |
test/compliance/cases/language/coalesce*.phpt |
Done when
Category
php-in-php· compile/runtime sharedProblem
lib/JIT/CoalesceHelper.phplowers the??null coalescing operator in LLVM with inline null/unset probes. VM path implements full php-src semantics in PHP (lib/VM.php). Duplicated logic drifts on edge cases (undefined variables, property hooks,ArrayAccessoffsets).Per #1492, coalesce behavior belongs in
lib/VM/with JIT as thin trampoline — same pattern as #10046 (CastHelper) and #10154 (NullsafeHelper).php-src reference
Zend/zend_compile.c—ZEND_AST_COALESCEcompilationZend/zend_execute.c—ZEND_COALESCEVM handlerRepro (architectural)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php' wc -l lib/JIT/CoalesceHelper.phpScope (this repo)
lib/VM/VmCoalesce.php(new) — shared ?? semanticslib/JIT/CoalesceHelper.php→ trampolinetest/compliance/cases/language/coalesce*.phptDone when
CoalesceHelper.phpshrinks to trampoline + types (target ≥50% line reduction vs current ~46 LLVM body + call sites)./script/ci-fast.sh --filter coalescegreen