mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
GH-123040: Specialize shadowed LOAD_ATTR
. (GH-123219)
This commit is contained in:
parent
90b6d0e0f8
commit
5d3201fe3f
7 changed files with 334 additions and 201 deletions
41
Python/generated_cases.c.h
generated
41
Python/generated_cases.c.h
generated
|
@ -4937,6 +4937,47 @@
|
|||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(LOAD_ATTR_CLASS_WITH_METACLASS_CHECK) {
|
||||
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
|
||||
next_instr += 10;
|
||||
INSTRUCTION_STATS(LOAD_ATTR_CLASS_WITH_METACLASS_CHECK);
|
||||
static_assert(INLINE_CACHE_ENTRIES_LOAD_ATTR == 9, "incorrect cache size");
|
||||
_PyStackRef owner;
|
||||
_PyStackRef attr;
|
||||
_PyStackRef null = PyStackRef_NULL;
|
||||
/* Skip 1 cache entry */
|
||||
// _CHECK_ATTR_CLASS
|
||||
owner = stack_pointer[-1];
|
||||
{
|
||||
uint32_t type_version = read_u32(&this_instr[2].cache);
|
||||
PyObject *owner_o = PyStackRef_AsPyObjectBorrow(owner);
|
||||
DEOPT_IF(!PyType_Check(owner_o), LOAD_ATTR);
|
||||
assert(type_version != 0);
|
||||
DEOPT_IF(((PyTypeObject *)owner_o)->tp_version_tag != type_version, LOAD_ATTR);
|
||||
}
|
||||
// _GUARD_TYPE_VERSION
|
||||
{
|
||||
uint32_t type_version = read_u32(&this_instr[4].cache);
|
||||
PyTypeObject *tp = Py_TYPE(PyStackRef_AsPyObjectBorrow(owner));
|
||||
assert(type_version != 0);
|
||||
DEOPT_IF(tp->tp_version_tag != type_version, LOAD_ATTR);
|
||||
}
|
||||
// _LOAD_ATTR_CLASS
|
||||
{
|
||||
PyObject *descr = read_obj(&this_instr[6].cache);
|
||||
STAT_INC(LOAD_ATTR, hit);
|
||||
assert(descr != NULL);
|
||||
attr = PyStackRef_FromPyObjectNew(descr);
|
||||
stack_pointer[-1] = attr;
|
||||
null = PyStackRef_NULL;
|
||||
PyStackRef_CLOSE(owner);
|
||||
}
|
||||
if (oparg & 1) stack_pointer[0] = null;
|
||||
stack_pointer += (oparg & 1);
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN) {
|
||||
_Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr;
|
||||
next_instr += 10;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue