Skip to content

Language: foreach by-reference — AOT lowering (phase 2 of #1222) #4364

Description

@PurHur

Category

language

Problem

#1222 closed VM + JIT lowering for foreach ($arr as $k => &$v). docs/capabilities-syntax.md still marks AOT = no for foreach by-reference: native phpc build binaries fall back or abort when scripts use reference foreach on hot paths (bootstrap inventory warnings on lib/ patterns).

php-src reference

Repro

Use existing compliance test/compliance/cases/language/foreach_by_ref*.phpt (or add foreach_by_ref_aot.phpt):

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
./vendor/bin/phpunit --filter foreach_by_ref
# AOT: compile fixture and run native binary — must match Zend output
'

Today: VM/JIT green; AOT column no in capability matrix.

Scope (this repo)

Layer Files
JIT/AOT lib/JIT.php — reference foreach loop IR (mirror VM indirect cells)
AOT lib/AOT/, runtime helpers for hashtable iterator + indirect write-back
Policy lib/JIT/SelfHostBuiltinPolicy.php — remove AOT block if present
Tests test/fixtures/aot/cases/foreach_by_ref.phpt
Docs script/capability-syntax.php — flip AOT to yes when green

Done when

  • AOT fixture foreach_by_ref.phpt passes in AotTest / ci-local llvm tail
  • docs/capabilities-syntax.md foreach by-reference row: AOT = yes
  • php script/bootstrap-inventory.php --check unchanged or improved (no new blockers)

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