Skip to content

php-in-php: GcCollectCyclesRuntime phase 2 — shrink collect/mark LLVM via GcCollectCyclesJitHelper PHP #15852

Description

@PurHur

Category

php-in-php · runtime-shrink · php-compiler-strict (JIT/AOT collect path)

Problem

lib/JIT/Builtin/GcCollectCyclesRuntime.php is still ~1550 LOC of LLVM after registry helpers moved to GcCollectCyclesRegistryJitHelper.php (#9183). The cycle collect/mark/inbound walk and destructor invocation remain inline LLVM — the largest remaining non-Refcount runtime monolith.

C runtime phpc_gc.c is already deleted (RuntimeShrinkCloseoutTest); this issue finishes shrinking the replacement LLVM layer into compiled PHP.

php-src reference

  • php/php-src Zend/zend_gc.c — gc_collect_cycles, mark/sweep
  • Existing SSOT: ext/standard/GcCollectCyclesJitHelper.php, lib/VM/CycleCollector.php

PHP implementation target

  • Extend ext/standard/GcCollectCyclesJitHelper.php (or sibling helper) for mark/inbound/collect phases currently in GcCollectCyclesRuntime::implement*
  • Thin ABI bridges only in GcCollectCyclesRuntime.php (target <400 LOC, mirror CopyRuntime / StreamReadRuntime)
  • Keep GcCollectCyclesCollectRuntime.php stats bridge unchanged

Repro / verification

./vendor/bin/phpunit test/compliance/cases/runtime/gc_collect_cycles.phpt --no-configuration 2>/dev/null || \
  php bin/vm.php test/compliance/cases/runtime/gc_collect_cycles.php
./vendor/bin/phpunit test/unit/GcCollectCyclesCollectRuntimeShrinkTest.php
make bootstrap-selfhost-vm-driver-execute-probe

Done when

  • GcCollectCyclesRuntime.php net shrink ≥800 LOC; collect semantics unchanged
  • Existing GC compliance + GcCollectCyclesCollectRuntimeShrinkTest green
  • RuntimeShrinkCloseoutTest still passes (no C runtime reintroduced)
  • VM/JIT/AOT agree on gc_collect_cycles() when JIT path in scope

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 & DevEx

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions