forked from ircmaxell/php-compiler
-
Notifications
You must be signed in to change notification settings - Fork 1
Language: Reference assignment and by-ref parameters #140
Copy link
Copy link
Closed
Labels
area:compilerCompiler / CFG / JITCompiler / CFG / JITarea:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresPhase 2 – language features
Description
Activity
Metadata
Metadata
Assignees
Labels
area:compilerCompiler / CFG / JITCompiler / CFG / JITarea:vmVirtual machineVirtual machineenhancementNew feature or requestNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimSpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language featuresPhase 2 – language features
Category
languageProblem (May 2026 refresh)
VM v1 for by-reference semantics is landed — see
docs/capabilities-syntax.md:function f(&$x)foreach ($a as &$v)This issue tracks remaining reference gaps: JIT/AOT lowering for by-ref parameters, and deferred return-by-ref / global references.
php-src reference
Zend/zend_compile.c—zend_compile_param()byRefflag,zend_compile_foreach()ref iteratorZend/zend_execute.c—ZEND_RECV,ZVAL_MAKE_REF, argument binding by referenceZend/zend_operators.c— foreach by-reference iterator stateZend/zend_variables.c— return-by-ref (ZEND_RETURN_BY_REF)Repro — VM baseline (passes today)
Repro — JIT gap (this issue + #3161)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/jit.php repro.php'Zend / VM: prints
2.JIT today: does not preserve alias through compiled call (see capabilities-syntax row).
Foreach by-ref (VM/JIT ✅ per #1222):
Scope (this repo)
lib/Compiler.phpParam::byRef→TYPE_INDIRECT(VM ✅)lib/VM.php,lib/VM/Context.phplib/JIT.phpalloca+ pointer alias for by-ref params — #3161lib/AOT/test/compliance/cases/ref_param.phpt@group llvmJIT caseglobalrefs, arbitrary=&Workers: claim #3161 for JIT/AOT lowering; use this issue for VM regressions + return-by-ref when scoped.
Done when
2for by-ref param without VM fallback (Language: By-reference parameters JIT/AOT lowering (phase 2 post-#140) #3161)docs/capabilities-syntax.md— by-ref params JIT/AOT = yes./script/ci-fast.sh --filter ref_paramgreen; LLVM filter for JITVerification
Dependencies
Links