From 4425f6ce4313358e865c8dfd95a23c001523f954 Mon Sep 17 00:00:00 2001 From: PuQing Date: Sat, 28 Jun 2025 12:33:17 +0800 Subject: [PATCH 1/6] eliminate refcount from _CALL_BUILTION_O --- Lib/test/test_capi/test_opt.py | 15 +++++++++++++++ Python/bytecodes.c | 11 +++++------ Python/executor_cases.c.h | 24 ++++++++++++------------ Python/generated_cases.c.h | 34 ++++++++++++++++++++++++---------- Python/optimizer_cases.c.h | 10 ++++++++-- 5 files changed, 64 insertions(+), 30 deletions(-) diff --git a/Lib/test/test_capi/test_opt.py b/Lib/test/test_capi/test_opt.py index 0e7fd62c28a065..e90a905bd46829 100644 --- a/Lib/test/test_capi/test_opt.py +++ b/Lib/test/test_capi/test_opt.py @@ -2119,6 +2119,21 @@ class C: self.assertNotIn("_COMPARE_OP_INT", uops) self.assertNotIn("_GUARD_IS_TRUE_POP", uops) + def test_call_builtin_o(self): + def testfunc(n): + x = 0 + for _ in range(n): + y = abs(1) + x += y + return x + + res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD) + self.assertEqual(res, TIER2_THRESHOLD) + self.assertIsNotNone(ex) + uops = get_opnames(ex) + self.assertIn("_CALL_BUILTIN_O", uops) + self.assertIn("_POP_TWO", uops) + def test_get_len_with_const_tuple(self): def testfunc(n): x = 0.0 diff --git a/Python/bytecodes.c b/Python/bytecodes.c index d96a1944cd516a..22c9f964cde03b 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -4186,7 +4186,7 @@ dummy_func( _CALL_BUILTIN_CLASS + _CHECK_PERIODIC_AT_END; - op(_CALL_BUILTIN_O, (callable, self_or_null, args[oparg] -- res)) { + op(_CALL_BUILTIN_O, (callable, self_or_null, args[oparg] -- res, a, c)) { /* Builtin METH_O functions */ PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable); @@ -4206,11 +4206,9 @@ dummy_func( PyObject *res_o = _PyCFunction_TrampolineCall(cfunc, PyCFunction_GET_SELF(callable_o), PyStackRef_AsPyObjectBorrow(arg)); _Py_LeaveRecursiveCallTstate(tstate); assert((res_o != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - - PyStackRef_CLOSE(arg); - DEAD(args); - DEAD(self_or_null); - PyStackRef_CLOSE(callable); + INPUTS_DEAD(); + a = arg; + c = callable; ERROR_IF(res_o == NULL); res = PyStackRef_FromPyObjectSteal(res_o); } @@ -4219,6 +4217,7 @@ dummy_func( unused/1 + unused/2 + _CALL_BUILTIN_O + + _POP_TWO + _CHECK_PERIODIC_AT_END; op(_CALL_BUILTIN_FAST, (callable, self_or_null, args[oparg] -- res)) { diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index fab23f358682eb..2ed6a277701988 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -13108,13 +13108,15 @@ break; } - case _CALL_BUILTIN_O_r01: { + case _CALL_BUILTIN_O_r03: { CHECK_CURRENT_CACHED_VALUES(0); assert(WITHIN_STACK_BOUNDS_WITH_CACHE()); _PyStackRef *args; _PyStackRef self_or_null; _PyStackRef callable; _PyStackRef res; + _PyStackRef a; + _PyStackRef c; oparg = CURRENT_OPARG(); args = &stack_pointer[-oparg]; self_or_null = stack_pointer[-1 - oparg]; @@ -13153,23 +13155,21 @@ stack_pointer = _PyFrame_GetStackPointer(frame); _Py_LeaveRecursiveCallTstate(tstate); assert((res_o != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - _PyFrame_SetStackPointer(frame, stack_pointer); - PyStackRef_CLOSE(arg); - stack_pointer = _PyFrame_GetStackPointer(frame); - stack_pointer += -2 - oparg; - ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); - _PyFrame_SetStackPointer(frame, stack_pointer); - PyStackRef_CLOSE(callable); - stack_pointer = _PyFrame_GetStackPointer(frame); + a = arg; + c = callable; if (res_o == NULL) { + stack_pointer += -2 - oparg; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_ERROR(); } res = PyStackRef_FromPyObjectSteal(res_o); + _tos_cache2 = c; + _tos_cache1 = a; _tos_cache0 = res; - _tos_cache1 = PyStackRef_ZERO_BITS; - _tos_cache2 = PyStackRef_ZERO_BITS; - SET_CURRENT_CACHED_VALUES(1); + SET_CURRENT_CACHED_VALUES(3); + stack_pointer += -2 - oparg; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); assert(WITHIN_STACK_BOUNDS_WITH_CACHE()); break; } diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 413593386583a8..19add07c67376b 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -2249,6 +2249,10 @@ _PyStackRef self_or_null; _PyStackRef *args; _PyStackRef res; + _PyStackRef a; + _PyStackRef c; + _PyStackRef nos; + _PyStackRef tos; /* Skip 1 cache entry */ /* Skip 2 cache entries */ // _CALL_BUILTIN_O @@ -2290,24 +2294,34 @@ stack_pointer = _PyFrame_GetStackPointer(frame); _Py_LeaveRecursiveCallTstate(tstate); assert((res_o != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); + a = arg; + c = callable; + if (res_o == NULL) { + stack_pointer += -2 - oparg; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); + JUMP_TO_LABEL(error); + } + res = PyStackRef_FromPyObjectSteal(res_o); + } + // _POP_TWO + { + tos = c; + nos = a; + stack_pointer[-2 - oparg] = res; + stack_pointer[-1 - oparg] = nos; + stack_pointer += -oparg; + ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); - PyStackRef_CLOSE(arg); + PyStackRef_CLOSE(tos); stack_pointer = _PyFrame_GetStackPointer(frame); - stack_pointer += -2 - oparg; + stack_pointer += -1; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); - PyStackRef_CLOSE(callable); + PyStackRef_CLOSE(nos); stack_pointer = _PyFrame_GetStackPointer(frame); - if (res_o == NULL) { - JUMP_TO_LABEL(error); - } - res = PyStackRef_FromPyObjectSteal(res_o); } // _CHECK_PERIODIC_AT_END { - stack_pointer[0] = res; - stack_pointer += 1; - ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); int err = check_periodics(tstate); stack_pointer = _PyFrame_GetStackPointer(frame); diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h index c3f122215ed7bd..53e7647ad2473c 100644 --- a/Python/optimizer_cases.c.h +++ b/Python/optimizer_cases.c.h @@ -2961,10 +2961,16 @@ case _CALL_BUILTIN_O: { JitOptRef res; + JitOptRef a; + JitOptRef c; res = sym_new_not_null(ctx); - CHECK_STACK_BOUNDS(-1 - oparg); + a = sym_new_not_null(ctx); + c = sym_new_not_null(ctx); + CHECK_STACK_BOUNDS(1 - oparg); stack_pointer[-2 - oparg] = res; - stack_pointer += -1 - oparg; + stack_pointer[-1 - oparg] = a; + stack_pointer[-oparg] = c; + stack_pointer += 1 - oparg; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); break; } From 02d06a1e056ac9c0aa5e2563c9cd0e01c772e70e Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 28 Jun 2025 04:32:39 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2025-06-28-04-32-38.gh-issue-134584.eZogqn.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-06-28-04-32-38.gh-issue-134584.eZogqn.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-06-28-04-32-38.gh-issue-134584.eZogqn.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-28-04-32-38.gh-issue-134584.eZogqn.rst new file mode 100644 index 00000000000000..550d70b79a97b0 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-28-04-32-38.gh-issue-134584.eZogqn.rst @@ -0,0 +1 @@ +Eliminate redundant refcounting from `_CALL_BUILTIN_O`. From 89e347590e323b9729d39c60f8fecdae303a9324 Mon Sep 17 00:00:00 2001 From: PuQing Date: Sat, 28 Jun 2025 12:39:36 +0800 Subject: [PATCH 3/6] fix news format --- .../2025-06-28-04-32-38.gh-issue-134584.eZogqn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-06-28-04-32-38.gh-issue-134584.eZogqn.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-28-04-32-38.gh-issue-134584.eZogqn.rst index 550d70b79a97b0..97e24e5f881b92 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-06-28-04-32-38.gh-issue-134584.eZogqn.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-06-28-04-32-38.gh-issue-134584.eZogqn.rst @@ -1 +1 @@ -Eliminate redundant refcounting from `_CALL_BUILTIN_O`. +Eliminate redundant refcounting from ``_CALL_BUILTIN_O``. From 1942e6aafc9bdac5aa0bbaf249084d328eb3bd62 Mon Sep 17 00:00:00 2001 From: PuQing Date: Sun, 14 Dec 2025 15:17:37 +0800 Subject: [PATCH 4/6] Update CALL_BUILTIN_O --- Include/internal/pycore_opcode_metadata.h | 2 +- Include/internal/pycore_uop_ids.h | 2 +- Include/internal/pycore_uop_metadata.h | 6 +++--- Lib/test/test_capi/test_opt.py | 2 +- Python/bytecodes.c | 5 +++-- Python/generated_cases.c.h | 18 ++++++++++-------- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h index 82c7cf486b1a00..e463424c88c063 100644 --- a/Include/internal/pycore_opcode_metadata.h +++ b/Include/internal/pycore_opcode_metadata.h @@ -1359,7 +1359,7 @@ _PyOpcode_macro_expansion[256] = { [CALL_BUILTIN_CLASS] = { .nuops = 2, .uops = { { _CALL_BUILTIN_CLASS, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, [CALL_BUILTIN_FAST] = { .nuops = 2, .uops = { { _CALL_BUILTIN_FAST, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { .nuops = 2, .uops = { { _CALL_BUILTIN_FAST_WITH_KEYWORDS, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, - [CALL_BUILTIN_O] = { .nuops = 2, .uops = { { _CALL_BUILTIN_O, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, + [CALL_BUILTIN_O] = { .nuops = 4, .uops = { { _CALL_BUILTIN_O, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _POP_TOP, OPARG_SIMPLE, 3 }, { _CHECK_PERIODIC_AT_END, OPARG_REPLACED, 3 } } }, [CALL_INTRINSIC_1] = { .nuops = 1, .uops = { { _CALL_INTRINSIC_1, OPARG_SIMPLE, 0 } } }, [CALL_INTRINSIC_2] = { .nuops = 1, .uops = { { _CALL_INTRINSIC_2, OPARG_SIMPLE, 0 } } }, [CALL_ISINSTANCE] = { .nuops = 3, .uops = { { _GUARD_THIRD_NULL, OPARG_SIMPLE, 3 }, { _GUARD_CALLABLE_ISINSTANCE, OPARG_SIMPLE, 3 }, { _CALL_ISINSTANCE, OPARG_SIMPLE, 3 } } }, diff --git a/Include/internal/pycore_uop_ids.h b/Include/internal/pycore_uop_ids.h index ce1ad5a4c8a5f6..c9a05eecc2d425 100644 --- a/Include/internal/pycore_uop_ids.h +++ b/Include/internal/pycore_uop_ids.h @@ -426,7 +426,7 @@ extern "C" { #define _CALL_BUILTIN_CLASS_r01 619 #define _CALL_BUILTIN_FAST_r01 620 #define _CALL_BUILTIN_FAST_WITH_KEYWORDS_r01 621 -#define _CALL_BUILTIN_O_r01 622 +#define _CALL_BUILTIN_O_r03 622 #define _CALL_INTRINSIC_1_r11 623 #define _CALL_INTRINSIC_2_r21 624 #define _CALL_ISINSTANCE_r31 625 diff --git a/Include/internal/pycore_uop_metadata.h b/Include/internal/pycore_uop_metadata.h index 0a37ce98c7eb48..97d77136523942 100644 --- a/Include/internal/pycore_uop_metadata.h +++ b/Include/internal/pycore_uop_metadata.h @@ -2585,7 +2585,7 @@ const _PyUopCachingInfo _PyUop_Caching[MAX_UOP_ID+1] = { [_CALL_BUILTIN_O] = { .best = { 0, 0, 0, 0 }, .entries = { - { 1, 0, _CALL_BUILTIN_O_r01 }, + { 3, 0, _CALL_BUILTIN_O_r03 }, { -1, -1, -1 }, { -1, -1, -1 }, { -1, -1, -1 }, @@ -3744,7 +3744,7 @@ const uint16_t _PyUop_Uncached[MAX_UOP_REGS_ID+1] = { [_CREATE_INIT_FRAME_r01] = _CREATE_INIT_FRAME, [_EXIT_INIT_CHECK_r10] = _EXIT_INIT_CHECK, [_CALL_BUILTIN_CLASS_r01] = _CALL_BUILTIN_CLASS, - [_CALL_BUILTIN_O_r01] = _CALL_BUILTIN_O, + [_CALL_BUILTIN_O_r03] = _CALL_BUILTIN_O, [_CALL_BUILTIN_FAST_r01] = _CALL_BUILTIN_FAST, [_CALL_BUILTIN_FAST_WITH_KEYWORDS_r01] = _CALL_BUILTIN_FAST_WITH_KEYWORDS, [_GUARD_CALLABLE_LEN_r03] = _GUARD_CALLABLE_LEN, @@ -4032,7 +4032,7 @@ const char *const _PyOpcode_uop_name[MAX_UOP_REGS_ID+1] = { [_CALL_BUILTIN_FAST_WITH_KEYWORDS] = "_CALL_BUILTIN_FAST_WITH_KEYWORDS", [_CALL_BUILTIN_FAST_WITH_KEYWORDS_r01] = "_CALL_BUILTIN_FAST_WITH_KEYWORDS_r01", [_CALL_BUILTIN_O] = "_CALL_BUILTIN_O", - [_CALL_BUILTIN_O_r01] = "_CALL_BUILTIN_O_r01", + [_CALL_BUILTIN_O_r03] = "_CALL_BUILTIN_O_r03", [_CALL_INTRINSIC_1] = "_CALL_INTRINSIC_1", [_CALL_INTRINSIC_1_r11] = "_CALL_INTRINSIC_1_r11", [_CALL_INTRINSIC_2] = "_CALL_INTRINSIC_2", diff --git a/Lib/test/test_capi/test_opt.py b/Lib/test/test_capi/test_opt.py index e90a905bd46829..b29860957732bc 100644 --- a/Lib/test/test_capi/test_opt.py +++ b/Lib/test/test_capi/test_opt.py @@ -2132,7 +2132,7 @@ def testfunc(n): self.assertIsNotNone(ex) uops = get_opnames(ex) self.assertIn("_CALL_BUILTIN_O", uops) - self.assertIn("_POP_TWO", uops) + self.assertIn("_POP_TOP", uops) def test_get_len_with_const_tuple(self): def testfunc(n): diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 22c9f964cde03b..2dbddee81f275e 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -4206,9 +4206,9 @@ dummy_func( PyObject *res_o = _PyCFunction_TrampolineCall(cfunc, PyCFunction_GET_SELF(callable_o), PyStackRef_AsPyObjectBorrow(arg)); _Py_LeaveRecursiveCallTstate(tstate); assert((res_o != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - INPUTS_DEAD(); a = arg; c = callable; + INPUTS_DEAD(); ERROR_IF(res_o == NULL); res = PyStackRef_FromPyObjectSteal(res_o); } @@ -4217,7 +4217,8 @@ dummy_func( unused/1 + unused/2 + _CALL_BUILTIN_O + - _POP_TWO + + POP_TOP + + POP_TOP + _CHECK_PERIODIC_AT_END; op(_CALL_BUILTIN_FAST, (callable, self_or_null, args[oparg] -- res)) { diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 19add07c67376b..b68f600f8b63f8 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -2251,8 +2251,7 @@ _PyStackRef res; _PyStackRef a; _PyStackRef c; - _PyStackRef nos; - _PyStackRef tos; + _PyStackRef value; /* Skip 1 cache entry */ /* Skip 2 cache entries */ // _CALL_BUILTIN_O @@ -2303,21 +2302,24 @@ } res = PyStackRef_FromPyObjectSteal(res_o); } - // _POP_TWO + // _POP_TOP { - tos = c; - nos = a; + value = c; stack_pointer[-2 - oparg] = res; - stack_pointer[-1 - oparg] = nos; + stack_pointer[-1 - oparg] = a; stack_pointer += -oparg; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); - PyStackRef_CLOSE(tos); + PyStackRef_XCLOSE(value); stack_pointer = _PyFrame_GetStackPointer(frame); + } + // _POP_TOP + { + value = a; stack_pointer += -1; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); - PyStackRef_CLOSE(nos); + PyStackRef_XCLOSE(value); stack_pointer = _PyFrame_GetStackPointer(frame); } // _CHECK_PERIODIC_AT_END From fd5c844c996a54708abf0773c92cd501eb367408 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Sun, 14 Dec 2025 09:36:29 +0000 Subject: [PATCH 5/6] Address review --- Python/bytecodes.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 2dbddee81f275e..aad2a577453165 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -4206,10 +4206,12 @@ dummy_func( PyObject *res_o = _PyCFunction_TrampolineCall(cfunc, PyCFunction_GET_SELF(callable_o), PyStackRef_AsPyObjectBorrow(arg)); _Py_LeaveRecursiveCallTstate(tstate); assert((res_o != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); + if (res_o == NULL) { + ERROR_NO_POP(); + } a = arg; c = callable; INPUTS_DEAD(); - ERROR_IF(res_o == NULL); res = PyStackRef_FromPyObjectSteal(res_o); } From 966676cf6c11558981d2ddef6f3b0164e3d0c807 Mon Sep 17 00:00:00 2001 From: Ken Jin Date: Sun, 14 Dec 2025 09:38:06 +0000 Subject: [PATCH 6/6] regen --- Include/internal/pycore_opcode_metadata.h | 2 +- Include/internal/pycore_uop_metadata.h | 2 +- Python/executor_cases.c.h | 6 ++---- Python/generated_cases.c.h | 6 ++---- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Include/internal/pycore_opcode_metadata.h b/Include/internal/pycore_opcode_metadata.h index e463424c88c063..5cb0e9c88f1399 100644 --- a/Include/internal/pycore_opcode_metadata.h +++ b/Include/internal/pycore_opcode_metadata.h @@ -1111,7 +1111,7 @@ const struct opcode_metadata _PyOpcode_opcode_metadata[267] = { [CALL_BUILTIN_CLASS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, [CALL_BUILTIN_FAST] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, [CALL_BUILTIN_FAST_WITH_KEYWORDS] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, - [CALL_BUILTIN_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, + [CALL_BUILTIN_O] = { true, INSTR_FMT_IBC00, HAS_ARG_FLAG | HAS_EVAL_BREAK_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG }, [CALL_FUNCTION_EX] = { true, INSTR_FMT_IX, HAS_EVAL_BREAK_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_SYNC_SP_FLAG | HAS_NEEDS_GUARD_IP_FLAG }, [CALL_INTRINSIC_1] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, [CALL_INTRINSIC_2] = { true, INSTR_FMT_IB, HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG }, diff --git a/Include/internal/pycore_uop_metadata.h b/Include/internal/pycore_uop_metadata.h index 97d77136523942..45d1c6b544b1fa 100644 --- a/Include/internal/pycore_uop_metadata.h +++ b/Include/internal/pycore_uop_metadata.h @@ -281,7 +281,7 @@ const uint32_t _PyUop_Flags[MAX_UOP_ID+1] = { [_CREATE_INIT_FRAME] = HAS_ARG_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG | HAS_SYNC_SP_FLAG, [_EXIT_INIT_CHECK] = HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_CALL_BUILTIN_CLASS] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, - [_CALL_BUILTIN_O] = HAS_ARG_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, + [_CALL_BUILTIN_O] = HAS_ARG_FLAG | HAS_EXIT_FLAG | HAS_ERROR_FLAG | HAS_ERROR_NO_POP_FLAG | HAS_ESCAPES_FLAG, [_CALL_BUILTIN_FAST] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, [_CALL_BUILTIN_FAST_WITH_KEYWORDS] = HAS_ARG_FLAG | HAS_DEOPT_FLAG | HAS_ERROR_FLAG | HAS_ESCAPES_FLAG, [_GUARD_CALLABLE_LEN] = HAS_DEOPT_FLAG, diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 2ed6a277701988..28b78e58a5b6d9 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -13155,14 +13155,12 @@ stack_pointer = _PyFrame_GetStackPointer(frame); _Py_LeaveRecursiveCallTstate(tstate); assert((res_o != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - a = arg; - c = callable; if (res_o == NULL) { - stack_pointer += -2 - oparg; - ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_ERROR(); } + a = arg; + c = callable; res = PyStackRef_FromPyObjectSteal(res_o); _tos_cache2 = c; _tos_cache1 = a; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index b68f600f8b63f8..ed73e51491a5e4 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -2293,13 +2293,11 @@ stack_pointer = _PyFrame_GetStackPointer(frame); _Py_LeaveRecursiveCallTstate(tstate); assert((res_o != NULL) ^ (_PyErr_Occurred(tstate) != NULL)); - a = arg; - c = callable; if (res_o == NULL) { - stack_pointer += -2 - oparg; - ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); JUMP_TO_LABEL(error); } + a = arg; + c = callable; res = PyStackRef_FromPyObjectSteal(res_o); } // _POP_TOP