Skip to content

php-in-php: GcCollectCyclesRuntime implementCollectCyclesImpl — route cycle scan LLVM through CycleCollector PHP (#13403 follow-up) #13882

Closed

Description

@PurHur

Category

php-in-php · shrink LLVM · php-src-strict

Problem

lib/JIT/Builtin/GcCollectCyclesRuntime.php still emits ~640 LOC phpc_gc_collect_cycles_impl LLVM (Tarjan-style scan over registry globals). VM path uses lib/VM/CycleCollector.php PHP SSOT (#13403, #3113). Embed JIT only routes stats via GcCollectCyclesJitHelper::recordNativeCollect after native scan — duplicated semantics.

ext/standard/GcCollectCyclesJitHelper.php documents: "native cycle scan stays in GcCollectCyclesRuntime until full PHP graph walk."

php-src reference

Repro

wc -l lib/JIT/Builtin/GcCollectCyclesRuntime.php
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_gap_gc_collect_array_cycle.php
php vendor/bin/phpunit --filter GcCollectCycles
'

Scope

Path Work
lib/VM/CycleCollector.php expose JIT-callable collect bridge (registry already PHP via GcCollectCyclesRegistryJitHelper)
lib/JIT/Builtin/GcCollectCyclesRuntime.php delete/shrink implementCollectCyclesImpl LLVM; embed calls compiled PHP
lib/JIT/Builtin/GcCollectCyclesCollectRuntime.php route standalone quarantine only
Tests extend GcCollectCyclesCollectRuntimeShrinkTest LOC guard

Done when

  • Embed JIT gc_collect_cycles() uses PHP cycle walk — no implementCollectCyclesImpl body in embed path
  • VM/JIT parity on test/repro/maintainer_gap_gc_collect_array_cycle.php
  • ./script/ci-fast.sh --filter gc_collect green
  • PR lists LLVM lines removed from GcCollectCyclesRuntime.php

Refs #13403, #9269, #1492

Activity

  1. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch (issues #13882) — filed for next run; #13880 merged first.

  2. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch (issues #13882)

  3. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    Merged via #13893.

    Verification

    • php vendor/bin/phpunit test/unit/GcCollectCyclesCollectRuntimeShrinkTest.php — OK (5 tests)
    • php bin/vm.php test/repro/maintainer_gap_gc_collect_array_cycle.php → 1
    • php bin/jit.php test/repro/maintainer_gap_gc_collect_array_cycle.php → 1
    • php bin/jit.php test/compliance/cases/stdlib/gc_jit.phpt → 2 (object cycle)
    • php bin/vm.php test/compliance/cases/runtime/gc_collect_cycles_destruct.phpt → destructors invoked

    Embed JIT phpc_gc_collect_cycles_impl is now a thin bridge to compiled GcCollectCyclesJitHelper::collectCyclesEmbed() (CycleCollector VM walk + PHP native-registry scan). Standalone AOT retains LLVM scan.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions