gh-134584: Cleanups for GH-135860 (GH-142604)

This commit is contained in:
Ken Jin 2025-12-13 22:38:10 +08:00 committed by GitHub
parent c98182be8d
commit e02a35c365
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 41 additions and 35 deletions

View file

@ -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])) {

View file

@ -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;

View file

@ -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,21 +4072,24 @@
_PyFrame_SetStackPointer(frame, stack_pointer);
PyObject *res_o = PySequence_Tuple(arg_o);
stack_pointer = _PyFrame_GetStackPointer(frame);
stack_pointer += -1;
if (res_o == NULL) {
JUMP_TO_LABEL(error);
}
a = arg;
res = PyStackRef_FromPyObjectSteal(res_o);
}
// _POP_TOP
{
value = a;
stack_pointer[-3] = res;
stack_pointer += -2;
ASSERT_WITHIN_STACK_BOUNDS(__FILE__, __LINE__);
_PyFrame_SetStackPointer(frame, stack_pointer);
PyStackRef_CLOSE(arg);
PyStackRef_XCLOSE(value);
stack_pointer = _PyFrame_GetStackPointer(frame);
if (res_o == NULL) {
JUMP_TO_LABEL(pop_2_error);
}
res = PyStackRef_FromPyObjectSteal(res_o);
}
// _CHECK_PERIODIC_AT_END
{
stack_pointer[-2] = 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);

View file

@ -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)) {

View file

@ -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;
}