Skip to content

Language: Generators (yield and yield from) #167

Description

@PurHur

Category

language

Problem (updated May 2026)

VM generators landedyield, keyed yield (#3085), and yield from iterate via GeneratorState + foreach. JIT and AOT remain no per docs/capabilities-syntax.md; bin/jit.php falls back to VM via Block::requiresVmLowering.

This umbrella issue tracks remaining parity; implement via child issues:

Do not duplicate VM work here.

php-src reference

  • Zend/zend_compile.czend_compile_generator(), yield / yield from opcodes
  • Zend/zend_generators.cGenerator object, send/throw, delegate

Repro (today)

<?php
function gen(): Generator {
    yield 1;
    yield 'a' => 2;
    yield from [3, 4];
}
echo implode(',', iterator_to_array(gen()));
# VM — passes
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'

# JIT — VM fallback (no native yield IR)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php repro.php'

# AOT — blocked
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/compile.php -o /tmp/gen repro.php && /tmp/gen'

Expected (Zend): 1,2,3,4
Actual (JIT/AOT): no LLVM suspend/resume; AOT may error at compile or runtime stub.

Existing compliance: test/compliance/cases/language/generator_*.phpt (VM).

Scope (this repo) — closure criteria for umbrella

  • #3074 closed — JIT yield opcodes
  • #3115 closed — AOT suspend/resume
  • php script/capability-syntax.php — Generators row JIT/AOT yes
  • docs/generators-jit-aot.md updated

Done when (this issue)

All generator compliance PHPTs pass under VM + JIT + AOT without VM fallback; child issues closed.

Dependencies

De-duplication

Issue Role
#167 Umbrella — close when JIT+AOT land
#3074 JIT lowering (claim this for JIT work)
#3115 AOT lowering (claim this for AOT work)
#72 Closures — separate capture model

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 / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions