Skip to content

Language: yield from nested Generator — JIT resume/delegate (phase 2 of #3074) #4014

Description

@PurHur

Category

language

Problem

#3074 / #167 landed linear yield and yield from packed arrays in JIT. docs/capabilities-syntax.md and lib/JIT/GeneratorHelper.php still defer:

yield from generator + try/catch in generator JIT

yield from inner() where inner() is a user generator aborts or falls back while yield from [1,2] works.

php-src reference

Repro (today)

<?php
function inner(): Generator {
    yield 1;
    yield 2;
}
function outer(): Generator {
    yield from inner();
    yield 3;
}
foreach (outer() as $v) {
    echo $v;
}
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro_yield_from_gen.php'
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php repro_yield_from_gen.php'
Runtime Expected
Zend 123 + newline
VM same
JIT same (today: LogicException or VM fallback — document actual)

Scope (this repo)

Area Files
VM lib/VM/GeneratorState.php — delegate stack (reference)
JIT lib/JIT/GeneratorHelper.php — emitYieldFromGeneratorIter, resolveYieldFromGeneratorResumeName
Tests test/compliance/cases/language/generator_yield_from_generator.phpt
Docs docs/generators-jit-aot.md — remove deferred note when green

Done when

  • Repro green under bin/jit.php without full-script VM fallback
  • Nested yield from + single yield ordering matches Zend
  • Optional follow-up: try/catch inside delegated generator (separate issue if large)

Verification

./script/ci-fast.sh --filter generator_yield_from

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