TAILLCALL VM: Do not return in ZEND_VM_ENTER_EX, ZEND_VM_LEAVE#21475
Open
arnaud-lb wants to merge 3 commits intophp:masterfrom
Open
TAILLCALL VM: Do not return in ZEND_VM_ENTER_EX, ZEND_VM_LEAVE#21475arnaud-lb wants to merge 3 commits intophp:masterfrom
arnaud-lb wants to merge 3 commits intophp:masterfrom
Conversation
dstogov
requested changes
Mar 23, 2026
Member
dstogov
left a comment
There was a problem hiding this comment.
As I understood, this affects only TAILCALL VM.
So, it should be fine, except for a single minor comment.
Zend/zend_vm_gen.php
Outdated
| out($f," } while (0)\n"); | ||
| out($f,"# define ZEND_VM_DISPATCH_TO_LEAVE_HELPER(helper) opline = &call_leave_op; SAVE_OPLINE(); ZEND_VM_CONTINUE()\n"); | ||
| out($f,"# define ZEND_VM_INTERRUPT() ZEND_VM_TAIL_CALL(zend_interrupt_helper".($spec?"_SPEC":"")."_TAILCALL(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU))\n"); | ||
| out($f,"# define ZEND_VM_ENTER_EX() ZEND_VM_CONTINUE()\n"); |
Member
There was a problem hiding this comment.
This misses ZEND_VM_INTERRUPT_CHECK();, otherwise a deeply recursive function couldn't be interrupted.
Member
Author
There was a problem hiding this comment.
Thank you, I forgot about this. In the CALL VM, ZEND_VM_ENTER_EX() relies on the interpreter loop to check for interrupts. Here we need to check interrupts in ZEND_VM_ENTER_EX() since we don't return to the loop anymore.
I've added ZEND_VM_INTERRUPT_CHECK(). Performance numbers are not impacted meaningfully.
dstogov
approved these changes
Mar 23, 2026
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.
The TAILLCALL VM returns in ZEND_VM_ENTER_EX and ZEND_VM_LEAVE, but that's not necessary.
Redefine ZEND_VM_ENTER_EX, ZEND_VM_LEAVE so that they tailcall instead.
This makes the Symfony and bench.php benchmarks about 1% and 3.5% faster.