Skip to content

Stdlib JIT: gc_collect_cycles() LLVM lowering (phase 2 of #3113) #3160

Description

@PurHur

Category

runtime / stdlib

Problem

#3113 landed VM gc_collect_cycles() via lib/VM/CycleCollector.php and ext/standard/gc_collect_cycles.php, but the JIT call() path throws:

LogicException: gc_collect_cycles() is not implemented for JIT in this compiler build

Scripts compiled with bin/jit.php cannot explicitly sweep cyclic object graphs even though VM mode can.

php-src reference

  • Zend/zend_gc.c — gc_collect_cycles(), zend_gc_collect_cycles()
  • ext/standard/info.c — PHP_FUNCTION(gc_collect_cycles)

Repro (today)

Use existing compliance fixture:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter gc_collect_cycles'

Expected: VM test passes; JIT test skipped or fails today.
Actual: test/compliance/JITTest.php skips gc_collect_cycles PHPT (#3113 comment).

Minimal script:

<?php
$a = new stdClass();
$b = new stdClass();
$a->b = $b;
$b->a = $a;
unset($a, $b);
echo gc_collect_cycles();
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php repro.php'

Scope (this repo)

  • ext/standard/gc_collect_cycles.php — implement call() delegating to native bridge
  • lib/JIT/Builtin/ or runtime symbol calling CycleCollector::collect() with active VM context
  • test/compliance/cases/runtime/gc_collect_cycles.phpt — enable JIT path (remove JITTest skip)
  • Update docs/capabilities.md JIT column

Done when

  • Repro prints collected cycle count under bin/jit.php (same as VM)
  • ./script/ci-local.sh --filter gc_collect_cycles green (VM + JIT)
  • No internal_* stub — real call into CycleCollector

Dependencies

Links

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions