Repository navigation
JIT: fix vm_interrupt resumption in TAILCALL/CALL VMs #24793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
arnaud-lb
merged 4 commits into
php:PHP-8.5
from
morrisonlevi:tailcall_vm_interrupt_jit
Oct 28, 2026
+105
−2
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
349fc2c
JIT: fix vm_interrupt on TAILCALL VM
morrisonlevi 33e8eeb
Function JIT: clear VM-enter bit after interrupt
morrisonlevi 1ceb87b
perf: avoid checking the enter bit when there is no interrupt functio…
morrisonlevi 7fae817
Merge remote-tracking branch 'origin/PHP-8.5' into tailcall_vm_interr…
morrisonlevi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
25 changes: 25 additions & 0 deletions
25
ext/opcache/tests/jit/function_vm_interrupt_enter_001.phpt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| --TEST-- | ||
| Function JIT: decode the VM-enter bit after an interrupt callback | ||
| --EXTENSIONS-- | ||
| opcache | ||
| zend_test | ||
| --INI-- | ||
| opcache.enable=1 | ||
| opcache.enable_cli=1 | ||
| opcache.file_update_protection=0 | ||
| opcache.jit=1201 | ||
| opcache.jit_buffer_size=64M | ||
| zend_test.observer.set_vm_interrupt_on_begin=1 | ||
| --FILE-- | ||
| <?php | ||
| function compare($left, $right) { | ||
| if ($left == $right) { | ||
| return 11; | ||
| } | ||
| return 22; | ||
| } | ||
|
|
||
| var_dump(compare(new VmInterruptComparable(1), new VmInterruptComparable(2))); | ||
| ?> | ||
| --EXPECT-- | ||
| int(22) |
39 changes: 39 additions & 0 deletions
39
ext/opcache/tests/jit/tailcall_vm_interrupt_opline_001.phpt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| --TEST-- | ||
| Tracing JIT: preserve the next opline when handling a VM interrupt | ||
| --DESCRIPTION-- | ||
| The object comparison raises an interrupt; the observer INI setting installs | ||
| an interrupt callback without enabling observer events. While recording the | ||
| caller, the backward jump must save its target before the interrupt helper | ||
| reloads the opline. Otherwise it revisits the already executed call opcode, | ||
| whose pending call frame has been consumed. | ||
|
|
||
| At the time of writing this was failing on the TAILCALL VM, but this should | ||
| pass on all VMs. | ||
| --EXTENSIONS-- | ||
| opcache | ||
| zend_test | ||
| --INI-- | ||
| opcache.enable=1 | ||
| opcache.enable_cli=1 | ||
| opcache.file_update_protection=0 | ||
| opcache.jit=tracing | ||
| opcache.jit_buffer_size=64M | ||
| opcache.jit_hot_func=1 | ||
| opcache.jit_hot_loop=1 | ||
| zend_test.observer.set_vm_interrupt_on_begin=1 | ||
| --FILE-- | ||
| <?php | ||
| function trigger(VmInterruptComparable $left, VmInterruptComparable $right): void { | ||
| // Raise an interrupt without an internal call that would handle it immediately. | ||
| $result = $left == $right; | ||
| } | ||
|
|
||
| $left = new VmInterruptComparable(1); | ||
| $right = new VmInterruptComparable(2); | ||
| foreach ([1, 2, 3] as $i) { | ||
| trigger($left, $right); | ||
| } | ||
| echo "Done\n"; | ||
| ?> | ||
| --EXPECT-- | ||
| Done |
29 changes: 29 additions & 0 deletions
29
ext/opcache/tests/jit/tailcall_vm_interrupt_opline_002.phpt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| --TEST-- | ||
| Function JIT: preserve the next opline when handling a VM interrupt | ||
| --DESCRIPTION-- | ||
| The object comparison raises an interrupt while the minimal function JIT | ||
| executes a callable opcode handler. The interrupt helper must resume at the | ||
| branch target, not reload the saved comparison opcode. No interrupt callback | ||
| is installed, isolating the saved-opline bug from callback resume-tag handling. | ||
| --EXTENSIONS-- | ||
| opcache | ||
| zend_test | ||
| --INI-- | ||
| opcache.enable=1 | ||
| opcache.enable_cli=1 | ||
| opcache.file_update_protection=0 | ||
| opcache.jit=1201 | ||
| opcache.jit_buffer_size=64M | ||
| --FILE-- | ||
| <?php | ||
| function compare($left, $right) { | ||
| if ($left == $right) { | ||
| return 11; | ||
| } | ||
| return 22; | ||
| } | ||
|
|
||
| var_dump(compare(new VmInterruptComparable(1), new VmInterruptComparable(2))); | ||
| ?> | ||
| --EXPECT-- | ||
| int(22) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively we can handle this in zend_interrupt_helper:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that win us anything? The current patch only adds the unconditional save when it's anyway tailcalling to the interrupt helper. And here you introduce a branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't win us much, it just reduces code size slightly.