Skip to content

Stdlib: gc_disable/gc_enable/gc_enabled/gc_collect_cycles — JIT/AOT (ext/standard + Zend/zend_gc.c) #4023

Closed

Description

@PurHur

Category

stdlib / runtime

Problem

Garbage-collection introspection builtins gc_disable(), gc_enable(), gc_enabled(), and gc_collect_cycles() run on VM (ext/standard/gc_*.php) but docs/capabilities.md marks them JIT=no. Long-running JIT/AOT services that toggle GC or collect cycles (tests, workers) silently diverge from Zend when executed natively.

php-src reference

Repro

<?php
class Node { public ?Node $next = null; }
$a = new Node();
$b = new Node();
$a->next = $b;
$b->next = $a;
unset($a, $b);
echo gc_enabled() ? "on\n" : "off\n";
gc_disable();
echo gc_enabled() ? "on\n" : "off\n";
gc_enable();
echo gc_collect_cycles(), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php repro.php
php bin/jit.php repro.php 2>&1
'
Call Zend (typical) VM JIT gap
gc_enabled() before disable on ✅ must match
after gc_disable() off ✅ must match
gc_collect_cycles() after cycle >= 1 ✅ must match

Scope

Path Work
VM reference ext/standard/gc_disable.php, gc_enable.php, gc_enabled.php, gc_collect_cycles.php
JIT lib/JIT/Builtin/ handlers calling lib/VM/GcSupport.php (or existing VM registry hooks)
AOT link same C/VM helpers as other builtins
Tests test/compliance/cases/stdlib/gc_jit.phpt

Done when

Related

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 1, 2026
  2. added a commit that references this issue on Jun 2, 2026
  3. PurHur commented on Jun 13, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — starting this run (#4023: gc_* JIT/AOT compliance tests + fix gc_enabled.phpt Mixed_ compile failure).

  4. added a commit that references this issue on Jun 13, 2026
    c6f9289
  5. PurHur commented on Jun 13, 2026

    @PurHur
    OwnerAuthor

    Merged via #8409

    Verification

    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    vendor/bin/phpunit test/compliance/VMTest.php --filter "stdlib/gc_enabled"
    vendor/bin/phpunit test/compliance/JITTest.php --filter "stdlib/gc_jit"
    vendor/bin/phpunit test/compliance/VMTest.php --filter "runtime/gc_collect_cycles"
    '

    → OK (3 tests). JIT inline repro: on/off/0.

    Implementation: GC JIT/AOT was already on master (GcCollectCyclesRuntime, JitGcToggle, JitGcCollectCycles). This PR fixes compliance PHPT compile failures (Mixed_ from untyped Node::$next) and adds gc_jit.phpt. No C runtime changes.

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-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions