Category
php-in-php | runtime
Problem
JIT/AOT still embed a large generated LLVM module for zval refcount/typeinfo manipulation: lib/JIT/Builtin/Refcount.php (~1.7k lines, from Refcount.pre) defines __ref__ structs and helpers (__ref__init, __ref__separate, disableRefcount, …) used across Type/String_.php, SpaceshipCompareJit, and string/object builtins.
This is compiler runtime semantics that should live in PHP (lib/VM/Variable.php, ext/standard/VmString.php, shared value lifecycle) with JIT lowering calling thin ABI trampolines — not a growing hand-maintained LLVM refcount IR graph.
North star #1492: shrink C/LLVM runtime; port behavior into PHP sources this repo owns.
php-src reference
- Zend refcounting is in C (
Zend/zend_types.h, zend_string.h) — reference only; port semantics to PHP VM value model, do not grow runtime/*.c.
Repro (scope probe)
wc -l lib/JIT/Builtin/Refcount.php lib/JIT/Builtin/Refcount.pre
rg '__ref__' lib/JIT/Builtin/ --count | sort -t: -k2 -nr | head
Today: widespread __ref__* LLVM types; no consolidated PHP VmRefcount helper for JIT callbacks.
Scope (this repo)
| Area |
Work |
| Audit |
Map each Refcount.php symbol to VM PHP equivalent (COW, separate string, typeinfo) |
| PHP |
New lib/VM/VmRefcount.php or extend lib/VM/Variable.php with documented lifecycle API |
| JIT |
Replace inline LLVM refcount IR with calls to PHP-backed runtime helpers (pattern: #9515 PowInt, #9476 Spaceship) |
| Delete |
Shrink Refcount.pre / generated Refcount.php line count in PR body |
| Forbidden |
New permanent refcount logic in runtime/*.c |
Done when
Verification
make bootstrap-selfhost-vm-driver-execute-probe
./script/ci-fast.sh --filter VMTest
# targeted JIT string phpt as touched
Related
Category
php-in-php|runtimeProblem
JIT/AOT still embed a large generated LLVM module for zval refcount/typeinfo manipulation:
lib/JIT/Builtin/Refcount.php(~1.7k lines, fromRefcount.pre) defines__ref__structs and helpers (__ref__init,__ref__separate,disableRefcount, …) used acrossType/String_.php,SpaceshipCompareJit, and string/object builtins.This is compiler runtime semantics that should live in PHP (
lib/VM/Variable.php,ext/standard/VmString.php, shared value lifecycle) with JIT lowering calling thin ABI trampolines — not a growing hand-maintained LLVM refcount IR graph.North star #1492: shrink C/LLVM runtime; port behavior into PHP sources this repo owns.
php-src reference
Zend/zend_types.h,zend_string.h) — reference only; port semantics to PHP VM value model, do not growruntime/*.c.Repro (scope probe)
Today: widespread
__ref__*LLVM types; no consolidated PHPVmRefcounthelper for JIT callbacks.Scope (this repo)
Refcount.phpsymbol to VM PHP equivalent (COW, separate string, typeinfo)lib/VM/VmRefcount.phpor extendlib/VM/Variable.phpwith documented lifecycle APIRefcount.pre/ generatedRefcount.phpline count in PR bodyruntime/*.cDone when
wc -l lib/JIT/Builtin/Refcount.phpreduced materially (target: >30% vs baseline; cite count in PR)./script/ci-fast.shgreen; JIT string/compliance subset unchanged (php-src-strict)Verification
make bootstrap-selfhost-vm-driver-execute-probe ./script/ci-fast.sh --filter VMTest # targeted JIT string phpt as touchedRelated
lib/JIT/Builtin/Type/String_.php