gh-134584: Eliminate redundant refcounting from _STORE_ATTR_WITH_HINT (GH-142767)

Signed-off-by: Manjusaka <me@manjusaka.me>
This commit is contained in:
Nadeshiko Manju 2025-12-17 07:21:04 +09:00 committed by GitHub
parent 8c87bcd7f2
commit 4345253981
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 69 additions and 17 deletions

View file

@ -2603,7 +2603,7 @@ dummy_func(
_STORE_ATTR_INSTANCE_VALUE +
POP_TOP;
op(_STORE_ATTR_WITH_HINT, (hint/1, value, owner --)) {
op(_STORE_ATTR_WITH_HINT, (hint/1, value, owner -- o)) {
PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner);
assert(Py_TYPE(owner_o)->tp_flags & Py_TPFLAGS_MANAGED_DICT);
PyDictObject *dict = _PyObject_GetManagedDict(owner_o);
@ -2633,14 +2633,16 @@ dummy_func(
// old_value should be DECREFed after GC track checking is done, if not, it could raise a segmentation fault,
// when dict only holds the strong reference to value in ep->me_value.
STAT_INC(STORE_ATTR, hit);
PyStackRef_CLOSE(owner);
o = owner;
DEAD(owner);
Py_XDECREF(old_value);
}
macro(STORE_ATTR_WITH_HINT) =
unused/1 +
_GUARD_TYPE_VERSION +
_STORE_ATTR_WITH_HINT;
_STORE_ATTR_WITH_HINT +
POP_TOP;
op(_STORE_ATTR_SLOT, (index/1, value, owner -- o)) {
PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner);