mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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.
This commit is contained in:
parent
18dfbd0357
commit
22988c323a
5 changed files with 181 additions and 72 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue