GH-111772: Specialize slot loads and stores for `_Py_T_OBJECT` (GH-111773)

This commit is contained in:
Mark Shannon 2023-11-06 13:55:04 +00:00 committed by GitHub
parent d78c872e0d
commit a7b0f63cdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -0,0 +1 @@
Specialize slot loads and stores for _Py_T_OBJECT as well as Py_T_OBJECT_EX

View File

@ -742,7 +742,7 @@ analyze_descriptor(PyTypeObject *type, PyObject *name, PyObject **descr, int sto
if (desc_cls == &PyMemberDescr_Type) {
PyMemberDescrObject *member = (PyMemberDescrObject *)descriptor;
struct PyMemberDef *dmem = member->d_member;
if (dmem->type == Py_T_OBJECT_EX) {
if (dmem->type == Py_T_OBJECT_EX || dmem->type == _Py_T_OBJECT) {
return OBJECT_SLOT;
}
return OTHER_SLOT;
@ -942,7 +942,7 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name)
SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_OUT_OF_RANGE);
goto fail;
}
assert(dmem->type == Py_T_OBJECT_EX);
assert(dmem->type == Py_T_OBJECT_EX || dmem->type == _Py_T_OBJECT);
assert(offset > 0);
cache->index = (uint16_t)offset;
write_u32(cache->version, type->tp_version_tag);
@ -1082,7 +1082,7 @@ _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name)
SPECIALIZATION_FAIL(STORE_ATTR, SPEC_FAIL_OUT_OF_RANGE);
goto fail;
}
assert(dmem->type == Py_T_OBJECT_EX);
assert(dmem->type == Py_T_OBJECT_EX || dmem->type == _Py_T_OBJECT);
assert(offset > 0);
cache->index = (uint16_t)offset;
write_u32(cache->version, type->tp_version_tag);