summaryrefslogtreecommitdiffstats
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorDonghee Na <donghee.na@python.org>2025-12-15 16:42:32 (GMT)
committerGitHub <noreply@github.com>2025-12-15 16:42:32 (GMT)
commitabaaeee6a0abe96ed4c4cfb22018e8b871a67102 (patch)
tree2d723d9e99852b94af8d4addef732cba051a65fb /Python/bytecodes.c
parent872ab51f32ab1128c4941e23b66c3ebc07855883 (diff)
downloadcpython-abaaeee6a0abe96ed4c4cfb22018e8b871a67102.zip
cpython-abaaeee6a0abe96ed4c4cfb22018e8b871a67102.tar.gz
cpython-abaaeee6a0abe96ed4c4cfb22018e8b871a67102.tar.bz2
gh-134584: Eliminate redundant refcounting from _STORE_SUBSCR_DICT (GH-142712)
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index ba94a4c..3e61479 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -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 --)) {