diff options
| author | Ken Jin <kenjin@python.org> | 2025-12-13 14:38:10 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-13 14:38:10 (GMT) |
| commit | e02a35c36535330bb86b4067104f537aa6da00e4 (patch) | |
| tree | 23ee4d6781201953e5c57246e4143e18e0518d5e /Python | |
| parent | c98182be8d47a69b9a43c08f58bac7a70c109cc9 (diff) | |
| download | cpython-e02a35c36535330bb86b4067104f537aa6da00e4.zip cpython-e02a35c36535330bb86b4067104f537aa6da00e4.tar.gz cpython-e02a35c36535330bb86b4067104f537aa6da00e4.tar.bz2 | |
gh-134584: Cleanups for GH-135860 (GH-142604)
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/bytecodes.c | 9 | ||||
| -rw-r--r-- | Python/executor_cases.c.h | 17 | ||||
| -rw-r--r-- | Python/generated_cases.c.h | 23 | ||||
| -rw-r--r-- | Python/optimizer_bytecodes.c | 3 | ||||
| -rw-r--r-- | Python/optimizer_cases.c.h | 7 |
5 files changed, 33 insertions, 26 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 3e7b7d5..d96a194 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -4068,15 +4068,17 @@ dummy_func( DEOPT_IF(callable_o != (PyObject *)&PyTuple_Type); } - op(_CALL_TUPLE_1, (callable, null, arg -- res)) { + op(_CALL_TUPLE_1, (callable, null, arg -- res, a)) { PyObject *arg_o = PyStackRef_AsPyObjectBorrow(arg); assert(oparg == 1); STAT_INC(CALL, hit); PyObject *res_o = PySequence_Tuple(arg_o); - PyStackRef_CLOSE(arg); + if (res_o == NULL) { + ERROR_NO_POP(); + } + a = arg; INPUTS_DEAD(); - ERROR_IF(res_o == NULL); res = PyStackRef_FromPyObjectSteal(res_o); } @@ -4086,6 +4088,7 @@ dummy_func( _GUARD_NOS_NULL + _GUARD_CALLABLE_TUPLE_1 + _CALL_TUPLE_1 + + POP_TOP + _CHECK_PERIODIC_AT_END; op(_CHECK_AND_ALLOCATE_OBJECT, (type_version/2, callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) { diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 9c2bffb..fab23f3 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -12888,11 +12888,12 @@ break; } - case _CALL_TUPLE_1_r31: { + case _CALL_TUPLE_1_r32: { CHECK_CURRENT_CACHED_VALUES(3); assert(WITHIN_STACK_BOUNDS_WITH_CACHE()); _PyStackRef arg; _PyStackRef res; + _PyStackRef a; _PyStackRef _stack_item_0 = _tos_cache0; _PyStackRef _stack_item_1 = _tos_cache1; _PyStackRef _stack_item_2 = _tos_cache2; @@ -12909,23 +12910,17 @@ _PyFrame_SetStackPointer(frame, stack_pointer); PyObject *res_o = PySequence_Tuple(arg_o); stack_pointer = _PyFrame_GetStackPointer(frame); - stack_pointer += -1; - ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); - _PyFrame_SetStackPointer(frame, stack_pointer); - PyStackRef_CLOSE(arg); - stack_pointer = _PyFrame_GetStackPointer(frame); if (res_o == NULL) { - stack_pointer += -2; - ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); SET_CURRENT_CACHED_VALUES(0); JUMP_TO_ERROR(); } + a = arg; res = PyStackRef_FromPyObjectSteal(res_o); + _tos_cache1 = a; _tos_cache0 = res; - _tos_cache1 = PyStackRef_ZERO_BITS; _tos_cache2 = PyStackRef_ZERO_BITS; - SET_CURRENT_CACHED_VALUES(1); - stack_pointer += -2; + SET_CURRENT_CACHED_VALUES(2); + stack_pointer += -3; 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 e72c621..4135933 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -4040,6 +4040,8 @@ _PyStackRef callable; _PyStackRef arg; _PyStackRef res; + _PyStackRef a; + _PyStackRef value; /* Skip 1 cache entry */ /* Skip 2 cache entries */ // _GUARD_NOS_NULL @@ -4070,22 +4072,25 @@ _PyFrame_SetStackPointer(frame, stack_pointer); PyObject *res_o = PySequence_Tuple(arg_o); stack_pointer = _PyFrame_GetStackPointer(frame); - stack_pointer += -1; - ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); - _PyFrame_SetStackPointer(frame, stack_pointer); - PyStackRef_CLOSE(arg); - stack_pointer = _PyFrame_GetStackPointer(frame); if (res_o == NULL) { - JUMP_TO_LABEL(pop_2_error); + JUMP_TO_LABEL(error); } + a = arg; res = PyStackRef_FromPyObjectSteal(res_o); } - // _CHECK_PERIODIC_AT_END + // _POP_TOP { - stack_pointer[-2] = res; - stack_pointer += -1; + value = a; + stack_pointer[-3] = res; + stack_pointer += -2; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); _PyFrame_SetStackPointer(frame, stack_pointer); + PyStackRef_XCLOSE(value); + stack_pointer = _PyFrame_GetStackPointer(frame); + } + // _CHECK_PERIODIC_AT_END + { + _PyFrame_SetStackPointer(frame, stack_pointer); int err = check_periodics(tstate); stack_pointer = _PyFrame_GetStackPointer(frame); if (err != 0) { diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c index 61f2dd1..9e76746 100644 --- a/Python/optimizer_bytecodes.c +++ b/Python/optimizer_bytecodes.c @@ -1097,7 +1097,7 @@ dummy_func(void) { } } - op(_CALL_TUPLE_1, (callable, null, arg -- res)) { + op(_CALL_TUPLE_1, (callable, null, arg -- res, a)) { if (sym_matches_type(arg, &PyTuple_Type)) { // e.g. tuple((1, 2)) or tuple(foo) where foo is known to be a tuple // Note: we must strip the reference information because it goes @@ -1107,6 +1107,7 @@ dummy_func(void) { else { res = sym_new_type(ctx, &PyTuple_Type); } + a = arg; } op(_GUARD_TOS_LIST, (tos -- tos)) { diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h index 7d95bce..c3f1222 100644 --- a/Python/optimizer_cases.c.h +++ b/Python/optimizer_cases.c.h @@ -2882,6 +2882,7 @@ case _CALL_TUPLE_1: { JitOptRef arg; JitOptRef res; + JitOptRef a; arg = stack_pointer[-1]; if (sym_matches_type(arg, &PyTuple_Type)) { res = PyJitRef_StripReferenceInfo(arg); @@ -2889,9 +2890,11 @@ else { res = sym_new_type(ctx, &PyTuple_Type); } - CHECK_STACK_BOUNDS(-2); + a = arg; + CHECK_STACK_BOUNDS(-1); stack_pointer[-3] = res; - stack_pointer += -2; + stack_pointer[-2] = a; + stack_pointer += -1; ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__); break; } |
