gh-143995: Eliminate redundant refcounting in the JIT from LOAD_ATTR_MODULE (GH-143996)

This commit is contained in:
AN Long 2026-01-26 03:24:44 +09:00 committed by GitHub
parent a51bf70f95
commit 6e55337f8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 1163 additions and 1023 deletions

View file

@ -2452,7 +2452,7 @@ dummy_func(
unused/5 +
_PUSH_NULL_CONDITIONAL;
op(_LOAD_ATTR_MODULE, (dict_version/2, index/1, owner -- attr)) {
op(_LOAD_ATTR_MODULE, (dict_version/2, index/1, owner -- attr, o)) {
PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner);
DEOPT_IF(Py_TYPE(owner_o)->tp_getattro != PyModule_Type.tp_getattro);
PyDictObject *dict = (PyDictObject *)((PyModuleObject *)owner_o)->md_dict;
@ -2473,12 +2473,14 @@ dummy_func(
attr = PyStackRef_FromPyObjectNew(attr_o);
#endif
STAT_INC(LOAD_ATTR, hit);
PyStackRef_CLOSE(owner);
o = owner;
DEAD(owner);
}
macro(LOAD_ATTR_MODULE) =
unused/1 +
_LOAD_ATTR_MODULE +
POP_TOP +
unused/5 +
_PUSH_NULL_CONDITIONAL;
@ -5444,6 +5446,12 @@ dummy_func(
value = PyStackRef_FromPyObjectBorrow(ptr);
}
tier2 op(_INSERT_1_LOAD_CONST_INLINE, (ptr/4, left -- res, l)) {
res = PyStackRef_FromPyObjectNew(ptr);
l = left;
INPUTS_DEAD();
}
tier2 op(_INSERT_1_LOAD_CONST_INLINE_BORROW, (ptr/4, left -- res, l)) {
res = PyStackRef_FromPyObjectBorrow(ptr);
l = left;