gh-134584: Eliminate redundant refcounting from _STORE_SUBSCR_DICT (GH-142712)

Co-authored-by: Ken Jin <kenjin4096@gmail.com>
This commit is contained in:
Donghee Na 2025-12-16 01:42:32 +09:00 committed by GitHub
parent 872ab51f32
commit abaaeee6a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 74 additions and 23 deletions

View file

@ -1158,9 +1158,9 @@ dummy_func(
}
macro(STORE_SUBSCR_DICT) =
_GUARD_NOS_DICT + unused/1 + _STORE_SUBSCR_DICT;
_GUARD_NOS_DICT + unused/1 + _STORE_SUBSCR_DICT + POP_TOP;
op(_STORE_SUBSCR_DICT, (value, dict_st, sub -- )) {
op(_STORE_SUBSCR_DICT, (value, dict_st, sub -- st)) {
PyObject *dict = PyStackRef_AsPyObjectBorrow(dict_st);
assert(PyDict_CheckExact(dict));
@ -1168,8 +1168,12 @@ dummy_func(
int err = _PyDict_SetItem_Take2((PyDictObject *)dict,
PyStackRef_AsPyObjectSteal(sub),
PyStackRef_AsPyObjectSteal(value));
PyStackRef_CLOSE(dict_st);
ERROR_IF(err);
if (err) {
PyStackRef_CLOSE(dict_st);
ERROR_IF(1);
}
DEAD(dict_st);
st = dict_st;
}
inst(DELETE_SUBSCR, (container, sub --)) {