]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-104584: Change DEOPT_IF in uops executor (#106146)
authorGuido van Rossum <guido@python.org>
Tue, 27 Jun 2023 21:17:41 +0000 (14:17 -0700)
committerGitHub <noreply@github.com>
Tue, 27 Jun 2023 21:17:41 +0000 (14:17 -0700)
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!

Python/ceval.c
Python/ceval_macros.h

index 3e0dcf8c8629b961ad247cdc7e9d339d78908aab..e19860d04a7914a5935a98905d57da7f653f00af 100644 (file)
@@ -2767,10 +2767,11 @@ void Py_LeaveRecursiveCall(void)
 
 ///////////////////// Experimental UOp Interpreter /////////////////////
 
-// UPDATE_MISS_STATS (called by DEOPT_IF) uses next_instr
-// TODO: Make it do something useful
-#undef UPDATE_MISS_STATS
-#define UPDATE_MISS_STATS(INSTNAME) ((void)0)
+#undef DEOPT_IF
+#define DEOPT_IF(COND, INSTNAME) \
+    if ((COND)) {                \
+        goto deoptimize;         \
+    }
 
 _PyInterpreterFrame *
 _PyUopExecute(_PyExecutorObject *executor, _PyInterpreterFrame *frame, PyObject **stack_pointer)
@@ -2875,12 +2876,7 @@ error:
     Py_DECREF(self);
     return NULL;
 
-PREDICTED(UNPACK_SEQUENCE)
-PREDICTED(COMPARE_OP)
-PREDICTED(LOAD_SUPER_ATTR)
-PREDICTED(STORE_SUBSCR)
-PREDICTED(BINARY_SUBSCR)
-PREDICTED(BINARY_OP)
+deoptimize:
     // On DEOPT_IF we just repeat the last instruction.
     // This presumes nothing was popped from the stack (nor pushed).
 #ifdef LLTRACE
index f5c78fc65e17454abb55b2b36244c3e0fcac53f5..0d41ef5a14cef46416949155b944c167b52e81f7 100644 (file)
@@ -264,12 +264,11 @@ GETITEM(PyObject *v, Py_ssize_t i) {
 #define UPDATE_MISS_STATS(INSTNAME) ((void)0)
 #endif
 
-// NOTE: in the uops version, opcode may be > 255
 #define DEOPT_IF(COND, INSTNAME)                            \
     if ((COND)) {                                           \
         /* This is only a single jump on release builds! */ \
         UPDATE_MISS_STATS((INSTNAME));                      \
-        assert(opcode >= 256 || _PyOpcode_Deopt[opcode] == (INSTNAME)); \
+        assert(_PyOpcode_Deopt[opcode] == (INSTNAME));      \
         GO_TO_INSTRUCTION(INSTNAME);                        \
     }