From fdc008138e50eab987217b79ddac303877e81869 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Thu, 30 Jun 2022 09:11:05 -0700 Subject: gh-91719: Reload opcode on unknown error so that C can optimize the dispatching in ceval.c (GH-94364) (#94453) (cherry picked from commit ea39b77de9fa25b447d0b4148f75f351076e890a) Co-authored-by: neonene <53406459+neonene@users.noreply.github.com> --- .../Core and Builtins/2022-06-29-22-18-36.gh-issue-91719.3APYYI.rst | 2 ++ Python/ceval.c | 3 +++ 2 files changed, 5 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-06-29-22-18-36.gh-issue-91719.3APYYI.rst 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 index 0000000..0d085e8 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-06-29-22-18-36.gh-issue-91719.3APYYI.rst @@ -0,0 +1,2 @@ +Reload ``opcode`` when raising ``unknown opcode error`` in the interpreter main loop, +for C compilers to generate dispatching code independently. diff --git a/Python/ceval.c b/Python/ceval.c index 00fb027..b868161 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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"); -- cgit v0.12