Skip to content

php-in-php: gc_collect_cycles() JIT — delete phpc_gc.c (~368 lines), sweep in lib/VM/CycleCollector.php #5315

Description

@PurHur

Category

php-in-php | runtime | stdlib

Problem

VM gc_collect_cycles() uses PHP (lib/VM/CycleCollector.php, ext/standard/gc_collect_cycles.php) but JIT/AOT link lib/AOT/runtime/phpc_gc.c (~368 lines) duplicating Tarjan sweep, weakref clearing, and object graph walks in C. #3160 tracks JIT parity; this issue tracks deleting the C TU once native lowering calls the PHP collector.

php-src reference

Repro (failure today)

C runtime still linked:

./script/docker-exec.sh -- bash -lc 'grep phpc_gc lib/AOT/Linker.php; wc -l lib/AOT/runtime/phpc_gc.c'

VM vs JIT count mismatch on cyclic graph — save as test/repro-maintainer/parity_gc_collect_cycles_jit.php:

<?php
class Node { public ?Node $next = null; }
$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 test/repro-maintainer/parity_gc_collect_cycles_jit.php
php bin/jit.php test/repro-maintainer/parity_gc_collect_cycles_jit.php 2>&1 | head -5
'
Runtime Expected (Zend) This compiler
VM positive int (cycles collected) ✅ PHP collector
JIT same count as VM ❌ C overlay or stub

Scope (this repo)

Area Files
VM (source of truth) lib/VM/CycleCollector.php
JIT lib/JIT/Builtin/GcCollectCyclesRuntime.php — call PHP collector, not C
Delete lib/AOT/runtime/phpc_gc.c
Tests test/compliance/cases/stdlib/gc_collect_cycles_cyclic.phpt

Done when

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions