Skip to content

php-in-php: JIT GcCollectCyclesNative — route gc_collect_cycles() through Vm CycleCollector PHP not phpc_gc.c LLVM (#1492) #9183

Description

@PurHur

Category

php-in-php · runtime

Problem

gc_collect_cycles() VM uses lib/VM/CycleCollector.php via ext/standard/gc_collect_cycles.php, but JIT declares native entrypoints in lib/JIT/Builtin/GcCollectCyclesNative.php (__compiler_gc_collect_cycles, phpc_gc_* from C runtime). GC cycle semantics belong in PHP for self-host (#1492); C should remain a thin ABI for destructor hooks only.

Pairs #9150 (gc_status() php-in-php).

php-src reference

Repro

<?php
$a = new stdClass();
$b = new stdClass();
$a->r = $b;
$b->r = $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_gc.php
php bin/jit.php repro_gc.php
'
Runtime Prints collected count ≥ 0; no fatal
VM yes
JIT must match VM collector results on same graph

Scope

Layer Path
VM SSOT lib/VM/CycleCollector.php, ext/standard/gc_collect_cycles.php
JIT ext/standard/JitGcCollectCycles.php — call PHP collector, not __compiler_gc_collect_cycles
Shrink lib/JIT/Builtin/GcCollectCyclesNative.php declarations where replaceable
Tests extend test/compliance/cases/runtime/gc_collect_cycles.phpt with JIT leg

PHP-in-PHP: shrink phpc_gc.c surface — document any remaining C-only destructor trampoline.

Done when (php-src-strict)

  • Repro runs on JIT without native __compiler_gc_collect_cycles body
  • VM/JIT collected counts agree on cyclic stdClass graph
  • PR notes C symbols removed or gated
  • ./script/ci-fast.sh --filter gc_collect_cycles green

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 / JITenhancementNew 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