GH-112354: _GUARD_IS_TRUE_POP side-exits to target the next instruction, not themselves.#114078
Merged
Merged
Conversation
Closed
iritkatriel
reviewed
Jan 15, 2024
| ADD_TO_TRACE(uopcode, max_length, 0, INSTR_IP(next_instr, code)); | ||
| goto top; | ||
| } | ||
| ADD_TO_TRACE(uopcode, max_length, 0, INSTR_IP(target_instr, code)); |
Member
There was a problem hiding this comment.
I don't follow - why is the target different depending on whether jump_likely or not?
Member
Author
There was a problem hiding this comment.
Because if we expect to jump then the next instruction in the trace is the target, so if the guard fails we go to the following instruction.
Conversely, if we expect not to jump then the next instruction in the trace is the next instruction, so if the guard fails we go to the target.
POP_JUMP_IF_TRUE L2
L1 ...
Becomes:
If we expect TOS to be True:
_GUARD_IS_TRUE_POP L1
trace continues from L2
If we expect TOS to be False:
_GUARD_IS_FALSE_POP L2
trace continues from L1
gvanrossum
reviewed
Jan 15, 2024
gvanrossum
left a comment
Member
There was a problem hiding this comment.
PS. There's still an unused STORE_SP() definition in ceval_macros.h.
kulikjak
pushed a commit
to kulikjak/cpython
that referenced
this pull request
Jan 22, 2024
…nstruction, not themselves. (pythonGH-114078)
aisk
pushed a commit
to aisk/cpython
that referenced
this pull request
Feb 11, 2024
…nstruction, not themselves. (pythonGH-114078)
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this pull request
Sep 2, 2024
…nstruction, not themselves. (pythonGH-114078)
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.
In tier 2,
JUMP_IF_TRUEand friends are converted to guards. Currently if they fail, they resume execution in tier 1 at the same instruction. Apart from being inefficient, this doesn't guarantee forward progress if the jump is the first instruction, which will happen when we optimize side exits.This PR changes the
targetof_GUARD_IS_TRUE_POP, etc, to be the successor instruction, not the originalJUMP_IF_TRUE/FALSE.