Category
php-in-php
Problem
gc_collect_cycles() VM builtin already delegates to PHPCompiler\VM\CycleCollector from ext/standard/gc_collect_cycles.php, but JIT/AOT still links ~1280 lines of LLVM in lib/JIT/Builtin/GcCollectCyclesRuntime.php + GcCollectCyclesNative.php (__compiler_gc_collect_cycles, destructor lists, hashtable walks). GC semantics should live in PHP (lib/VM/CycleCollector.php) with a thin JIT trampoline — not a parallel native collector.
php-src reference
Zend/zend_gc.c — cycle collection, root buffer, destructor ordering
ext/standard/info.c — PHP_FUNCTION(gc_collect_cycles)
Repro
<?php
class Node { public ?Node $next = null; public function __destruct() { echo "dtor\n"; } }
$a = new Node; $b = new Node; $a->next = $b; $b->next = $a; unset($a, $b);
echo gc_collect_cycles(), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php repro.php'
Zend: prints 2 (two nodes collected) and destructor output order per GC flags.
This compiler VM: uses CycleCollector::collect() — JIT must call the same helper.
Scope (this repo)
| Area |
Path |
Action |
| VM SSOT |
lib/VM/CycleCollector.php |
Keep collector logic here |
| Stdlib |
ext/standard/gc_collect_cycles.php, JitGcCollectCycles.php |
JIT bridge → PHP collector |
| Delete/shrink |
lib/JIT/Builtin/GcCollectCyclesRuntime.php, GcCollectCyclesNative.php |
Remove LLVM collector |
| gc_status pair |
lib/JIT/Builtin/GcStatusRuntime.php |
Coordinate with #9150 |
Done when (php-src-strict)
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter GcCollectCycles'
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php test/compliance/cases/stdlib/gc_collect_cycles_basic.phpt'
Links
Category
php-in-phpProblem
gc_collect_cycles()VM builtin already delegates toPHPCompiler\VM\CycleCollectorfromext/standard/gc_collect_cycles.php, but JIT/AOT still links ~1280 lines of LLVM inlib/JIT/Builtin/GcCollectCyclesRuntime.php+GcCollectCyclesNative.php(__compiler_gc_collect_cycles, destructor lists, hashtable walks). GC semantics should live in PHP (lib/VM/CycleCollector.php) with a thin JIT trampoline — not a parallel native collector.php-src reference
Zend/zend_gc.c— cycle collection, root buffer, destructor orderingext/standard/info.c—PHP_FUNCTION(gc_collect_cycles)Repro
Zend: prints
2(two nodes collected) and destructor output order per GC flags.This compiler VM: uses
CycleCollector::collect()— JIT must call the same helper.Scope (this repo)
lib/VM/CycleCollector.phpext/standard/gc_collect_cycles.php,JitGcCollectCycles.phplib/JIT/Builtin/GcCollectCyclesRuntime.php,GcCollectCyclesNative.phplib/JIT/Builtin/GcStatusRuntime.phpDone when (php-src-strict)
gc_collect_cycles()invokesCycleCollector(or shared PHP helper), not LLVM hashtable walkGcCollectCyclesRuntime.phpdeleted or thin shim; PR cites lines removed fromlib/JIT/Builtin/test/unit/GcCollectCycles*.php+ compliance guards greenruntime/*.cVerification
Links