]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-91719: Reload opcode on unknown error so that C can optimize the dispatching in...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 30 Jun 2022 16:11:05 +0000 (09:11 -0700)
committerGitHub <noreply@github.com>
Thu, 30 Jun 2022 16:11:05 +0000 (09:11 -0700)
(cherry picked from commit ea39b77de9fa25b447d0b4148f75f351076e890a)

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
Misc/NEWS.d/next/Core and Builtins/2022-06-29-22-18-36.gh-issue-91719.3APYYI.rst [new file with mode: 0644]
Python/ceval.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-06-29-22-18-36.gh-issue-91719.3APYYI.rst b/Misc/NEWS.d/next/Core and Builtins/2022-06-29-22-18-36.gh-issue-91719.3APYYI.rst
new file mode 100644 (file)
index 0000000..0d085e8
--- /dev/null
@@ -0,0 +1,2 @@
+Reload ``opcode`` when raising ``unknown opcode error`` in the interpreter main loop,\r
+for C compilers to generate dispatching code independently.\r
index 00fb02718d8a3795b5d091a70c9f1447cb57dd29..b8681617c8c22c26afb3de2f2cb834f28de4885c 100644 (file)
@@ -5661,6 +5661,9 @@ handle_eval_breaker:
 #else
         EXTRA_CASES  // From opcode.h, a 'case' for each unused opcode
 #endif
+            /* Tell C compilers not to hold the opcode variable in the loop.
+               next_instr points the current instruction without TARGET(). */
+            opcode = _Py_OPCODE(*next_instr);
             fprintf(stderr, "XXX lineno: %d, opcode: %d\n",
                     _PyInterpreterFrame_GetLine(frame),  opcode);
             _PyErr_SetString(tstate, PyExc_SystemError, "unknown opcode");