Skip to content

Commit 6b5166f

Browse files
authored
gh-104584: Change DEOPT_IF in uops executor (#106146)
This effectively reverts bb578a0, restoring the original DEOPT_IF() macro in ceval_macros.h, and redefining it in the Tier 2 interpreter. We can get rid of the PREDICTED() macros there as well!
1 parent 5290881 commit 6b5166f

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

Python/ceval.c

+6-10
Original file line numberDiff line numberDiff line change
@@ -2767,10 +2767,11 @@ void Py_LeaveRecursiveCall(void)
27672767

27682768
///////////////////// Experimental UOp Interpreter /////////////////////
27692769

2770-
// UPDATE_MISS_STATS (called by DEOPT_IF) uses next_instr
2771-
// TODO: Make it do something useful
2772-
#undef UPDATE_MISS_STATS
2773-
#define UPDATE_MISS_STATS(INSTNAME) ((void)0)
2770+
#undef DEOPT_IF
2771+
#define DEOPT_IF(COND, INSTNAME) \
2772+
if ((COND)) { \
2773+
goto deoptimize; \
2774+
}
27742775

27752776
_PyInterpreterFrame *
27762777
_PyUopExecute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject **stack_pointer)
@@ -2875,12 +2876,7 @@ _PyUopExecute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject
28752876
Py_DECREF(self);
28762877
return NULL;
28772878

2878-
PREDICTED(UNPACK_SEQUENCE)
2879-
PREDICTED(COMPARE_OP)
2880-
PREDICTED(LOAD_SUPER_ATTR)
2881-
PREDICTED(STORE_SUBSCR)
2882-
PREDICTED(BINARY_SUBSCR)
2883-
PREDICTED(BINARY_OP)
2879+
deoptimize:
28842880
// On DEOPT_IF we just repeat the last instruction.
28852881
// This presumes nothing was popped from the stack (nor pushed).
28862882
#ifdef LLTRACE

Python/ceval_macros.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,11 @@ GETITEM(PyObject *v, Py_ssize_t i) {
264264
#define UPDATE_MISS_STATS(INSTNAME) ((void)0)
265265
#endif
266266

267-
// NOTE: in the uops version, opcode may be > 255
268267
#define DEOPT_IF(COND, INSTNAME) \
269268
if ((COND)) { \
270269
/* This is only a single jump on release builds! */ \
271270
UPDATE_MISS_STATS((INSTNAME)); \
272-
assert(opcode >= 256 || _PyOpcode_Deopt[opcode] == (INSTNAME)); \
271+
assert(_PyOpcode_Deopt[opcode] == (INSTNAME)); \
273272
GO_TO_INSTRUCTION(INSTNAME); \
274273
}
275274

0 commit comments

Comments
 (0)