diff options
author | Guido van Rossum <guido@python.org> | 2023-07-10 23:04:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-10 23:04:26 (GMT) |
commit | 22988c323ad621b9f47b6cb640b80ac806e26368 (patch) | |
tree | 3df379493e053e266519e718d1c6d7829bea11ad /Python/ceval.c | |
parent | 18dfbd035775c15533d13a98e56b1d2bf5c65f00 (diff) | |
download | cpython-22988c323ad621b9f47b6cb640b80ac806e26368.zip cpython-22988c323ad621b9f47b6cb640b80ac806e26368.tar.gz cpython-22988c323ad621b9f47b6cb640b80ac806e26368.tar.bz2 |
gh-106529: Implement POP_JUMP_IF_XXX uops (#106551)
- Hand-written uops JUMP_IF_{TRUE,FALSE}.
These peek at the top of the stack.
The jump target (in superblock space) is absolute.
- Hand-written translation for POP_JUMP_IF_{TRUE,FALSE},
assuming the jump is unlikely.
Once we implement jump-likelihood profiling,
we can implement the jump-unlikely case (in another PR).
- Tests (including some test cleanup).
- Improvements to len(ex) and ex[i] to expose the whole trace.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index da11355..866acd2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2751,7 +2751,8 @@ _PyUopExecute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject operand = self->trace[pc].operand; oparg = (int)operand; DPRINTF(3, - " uop %s, operand %" PRIu64 ", stack_level %d\n", + "%4d: uop %s, operand %" PRIu64 ", stack_level %d\n", + pc, opcode < 256 ? _PyOpcode_OpName[opcode] : _PyOpcode_uop_name[opcode], operand, (int)(stack_pointer - _PyFrame_Stackbase(frame))); @@ -2763,6 +2764,25 @@ _PyUopExecute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject #define ENABLE_SPECIALIZATION 0 #include "executor_cases.c.h" + // NOTE: These pop-jumps move the uop pc, not the bytecode ip + case _POP_JUMP_IF_FALSE: + { + if (Py_IsFalse(stack_pointer[-1])) { + pc = oparg; + } + stack_pointer--; + break; + } + + case _POP_JUMP_IF_TRUE: + { + if (Py_IsTrue(stack_pointer[-1])) { + pc = oparg; + } + stack_pointer--; + break; + } + case SAVE_IP: { frame->prev_instr = ip_offset + oparg; |