Language: closure use (&$var) JIT by-ref for native lvalues (#72) - #3274
Merged
Conversation
Promote enclosing native scalars to boxed __value__ slots at capture time so by-ref closure invokes pass __value__* to Native::compileArg, and assign through valueBoxAliasPtr writes literals into the shared cell. Adds VM compliance for mutating captures and extends LLVM module-verify fixtures. php-src: Zend/zend_closures.c (zend_bind_var), zend_compile_var_dep Co-authored-by: Cursor <cursoragent@cursor.com>
PurHur
force-pushed
the
agent/issue-72-closure-use-by-ref
branch
from
May 30, 2026 17:24
a75dd4d to
a05d518
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
use (&$var)when the enclosed variable is a native scalar ($x = 1): promote to a shared__value__box at capture time and pass__value__*throughClosureWithCaptures.JitValueBox::assignToPointer(native literals and boxed values).closure_use_byref_mutate.phptfor the issue repro ($f(); echo $x→2).php-src reference
Zend/zend_closures.c—zend_create_closure, bound variable tableZend/zend_compile.c—zend_compile_var_dep/use (&$x)Verification
Note:
bin/jit.phpMCJIT execute still segfaults in this harness (exit 139; pre-existing #98). LLVM module verify passes for all closure fixtures includingclosure_use_byref_mutate.phpt. AOT closure link remains out of scope (#1492).Closes #72
Made with Cursor