Category
php-in-php · php-src-strict · compile/runtime shared
Problem
lib/JIT/FromCallableHelper.php (~214 lines) lowers PHP 8.1 TYPE_FROM_CALLABLE (first-class callable strlen(...), [$obj,'m'](...), invokable objects) into inline LLVM via BoundMethodCallableHelper / ClosureWithBinding paths. VM implements Closure::fromCallable() semantics in lib/VM/ClosureSupport.php and ClosureFromCallable builtin.
Duplicated binding/visibility checks drift from php-src and overlap #10185 (BoundMethodCallableHelper) without a single SSOT.
php-src reference
Repro
<?php
$f = strlen(...);
echo $f('abc'), "\n";
class C { public function m(): int { return 1; } }
$g = (new C())->m(...);
echo $g(), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
php bin/vm.php repro.php
php bin/jit.php repro.php 2>&1
wc -l lib/JIT/FromCallableHelper.php lib/JIT/BoundMethodCallableHelper.php
'
Scope (this repo)
| Shrink LLVM |
Grow PHP |
FromCallableHelper.php string/bound/invokable LLVM |
Route through lib/VM/ClosureSupport.php + compiled trampoline |
Overlap with BoundMethodCallableHelper |
Single VmCallable/VmClosure SSOT used by VM + JIT |
lib/JIT/Call/ClosureWithBinding.php branches |
Thin ABI only when unavoidable |
Do not grow runtime/*.c.
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/unit/JitFirstClassCallableTest.php'
make bootstrap-selfhost-vm-driver-execute-probe
Related
Category
php-in-php· php-src-strict · compile/runtime sharedProblem
lib/JIT/FromCallableHelper.php(~214 lines) lowers PHP 8.1TYPE_FROM_CALLABLE(first-class callablestrlen(...),[$obj,'m'](...), invokable objects) into inline LLVM viaBoundMethodCallableHelper/ClosureWithBindingpaths. VM implementsClosure::fromCallable()semantics inlib/VM/ClosureSupport.phpandClosureFromCallablebuiltin.Duplicated binding/visibility checks drift from php-src and overlap #10185 (
BoundMethodCallableHelper) without a single SSOT.php-src reference
Zend/zend_closures.c—Closure::fromCallable(), static/bound method rulesZend/zend_compile.c—ZEND_AST_CALLABLE_CONVERT/ first-class callable loweringRepro
Scope (this repo)
FromCallableHelper.phpstring/bound/invokable LLVMlib/VM/ClosureSupport.php+ compiled trampolineBoundMethodCallableHelperVmCallable/VmClosureSSOT used by VM + JITlib/JIT/Call/ClosureWithBinding.phpbranchesDo not grow
runtime/*.c.Done when
FromCallableHelper.phpLLVM drops materially; PR cites lines removedJitFirstClassCallableTestgreenVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit test/unit/JitFirstClassCallableTest.php' make bootstrap-selfhost-vm-driver-execute-probeRelated
strlen(...),Foo::bar(...)) must yield Closure objects (zend_compile.c) #4810 FCC compile · php-in-php: JIT BoundMethodCallableHelper — route [obj,method] FCC LLVM through VmCallable PHP not ~381-line helper (#1492) #10185 bound method helper · php-in-php: JIT ClosureBindHelper — route Closure::bind/bindTo LLVM through VmClosure PHP not ~715-line monolith (#1492) #10109ClosureBindHelper· North star Epic: Self-host critical path — compiler compiles itself (M3→M5) #1492