gh-134584: Eliminate redundant refcounting from _LOAD_ATTR_INSTANCE_VALUE (GH-142769)

Signed-off-by: Manjusaka <me@manjusaka.me>
This commit is contained in:
Nadeshiko Manju 2025-12-17 05:39:20 +09:00 committed by GitHub
parent 92d4aeafd5
commit 6ee51a36b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 451 additions and 331 deletions

View file

@ -2356,7 +2356,7 @@ dummy_func(
DEOPT_IF(!FT_ATOMIC_LOAD_UINT8(_PyObject_InlineValues(owner_o)->valid));
}
op(_LOAD_ATTR_INSTANCE_VALUE, (offset/1, owner -- attr)) {
op(_LOAD_ATTR_INSTANCE_VALUE, (offset/1, owner -- attr, o)) {
PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner);
PyObject **value_ptr = (PyObject**)(((char *)owner_o) + offset);
PyObject *attr_o = FT_ATOMIC_LOAD_PTR_ACQUIRE(*value_ptr);
@ -2370,7 +2370,8 @@ dummy_func(
attr = PyStackRef_FromPyObjectNew(attr_o);
#endif
STAT_INC(LOAD_ATTR, hit);
PyStackRef_CLOSE(owner);
o = owner;
DEAD(owner);
}
macro(LOAD_ATTR_INSTANCE_VALUE) =
@ -2378,6 +2379,7 @@ dummy_func(
_GUARD_TYPE_VERSION +
_CHECK_MANAGED_OBJECT_HAS_VALUES +
_LOAD_ATTR_INSTANCE_VALUE +
POP_TOP +
unused/5 +
_PUSH_NULL_CONDITIONAL;