mirror of
https://github.com/python/cpython.git
synced 2026-01-04 06:22:20 +00:00
gh-106701: Move the hand-written Tier 2 uops to bytecodes.c (#106702)
This moves EXIT_TRACE, SAVE_IP, JUMP_TO_TOP, and
_POP_JUMP_IF_{FALSE,TRUE} from ceval.c to bytecodes.c.
They are no less special than before, but this way
they are discoverable o the copy-and-patch tooling.
This commit is contained in:
parent
2f3ee02c22
commit
e6e0ea0113
5 changed files with 124 additions and 94 deletions
|
|
@ -3654,6 +3654,36 @@ dummy_func(
|
|||
Py_UNREACHABLE();
|
||||
}
|
||||
|
||||
///////// Tier-2 only opcodes /////////
|
||||
|
||||
op(_POP_JUMP_IF_FALSE, (flag -- )) {
|
||||
if (Py_IsFalse(flag)) {
|
||||
pc = oparg;
|
||||
}
|
||||
}
|
||||
|
||||
op(_POP_JUMP_IF_TRUE, (flag -- )) {
|
||||
if (Py_IsTrue(flag)) {
|
||||
pc = oparg;
|
||||
}
|
||||
}
|
||||
|
||||
op(JUMP_TO_TOP, (--)) {
|
||||
pc = 0;
|
||||
CHECK_EVAL_BREAKER();
|
||||
}
|
||||
|
||||
op(SAVE_IP, (--)) {
|
||||
frame->prev_instr = ip_offset + oparg;
|
||||
}
|
||||
|
||||
op(EXIT_TRACE, (--)) {
|
||||
frame->prev_instr--; // Back up to just before destination
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
Py_DECREF(self);
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
||||
// END BYTECODES //
|
||||
|
||||
|
|
|
|||
|
|
@ -2764,46 +2764,6 @@ _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 JUMP_TO_TOP:
|
||||
{
|
||||
pc = 0;
|
||||
CHECK_EVAL_BREAKER();
|
||||
break;
|
||||
}
|
||||
|
||||
case SAVE_IP:
|
||||
{
|
||||
frame->prev_instr = ip_offset + oparg;
|
||||
break;
|
||||
}
|
||||
|
||||
case EXIT_TRACE:
|
||||
{
|
||||
frame->prev_instr--; // Back up to just before destination
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
Py_DECREF(self);
|
||||
return frame;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
fprintf(stderr, "Unknown uop %d, operand %" PRIu64 "\n", opcode, operand);
|
||||
|
|
|
|||
36
Python/executor_cases.c.h
generated
36
Python/executor_cases.c.h
generated
|
|
@ -1987,3 +1987,39 @@
|
|||
stack_pointer[-(2 + (oparg-2))] = top;
|
||||
break;
|
||||
}
|
||||
|
||||
case _POP_JUMP_IF_FALSE: {
|
||||
PyObject *flag = stack_pointer[-1];
|
||||
if (Py_IsFalse(flag)) {
|
||||
pc = oparg;
|
||||
}
|
||||
STACK_SHRINK(1);
|
||||
break;
|
||||
}
|
||||
|
||||
case _POP_JUMP_IF_TRUE: {
|
||||
PyObject *flag = stack_pointer[-1];
|
||||
if (Py_IsTrue(flag)) {
|
||||
pc = oparg;
|
||||
}
|
||||
STACK_SHRINK(1);
|
||||
break;
|
||||
}
|
||||
|
||||
case JUMP_TO_TOP: {
|
||||
pc = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case SAVE_IP: {
|
||||
frame->prev_instr = ip_offset + oparg;
|
||||
break;
|
||||
}
|
||||
|
||||
case EXIT_TRACE: {
|
||||
frame->prev_instr--; // Back up to just before destination
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
Py_DECREF(self);
|
||||
return frame;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue