mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
GH-131798: Optimize cached class attributes and methods in the JIT (GH-134403)
This commit is contained in:
parent
09e72cf091
commit
ec736e7dae
12 changed files with 365 additions and 130 deletions
|
@ -522,7 +522,7 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_LOAD_CONST, (-- value)) {
|
||||
PyObject *val = PyTuple_GET_ITEM(co->co_consts, this_instr->oparg);
|
||||
PyObject *val = PyTuple_GET_ITEM(co->co_consts, oparg);
|
||||
REPLACE_OP(this_instr, _LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)val);
|
||||
value = sym_new_const(ctx, val);
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ dummy_func(void) {
|
|||
op(_LOAD_ATTR, (owner -- attr, self_or_null[oparg&1])) {
|
||||
(void)owner;
|
||||
attr = sym_new_not_null(ctx);
|
||||
if (oparg &1) {
|
||||
if (oparg & 1) {
|
||||
self_or_null[0] = sym_new_unknown(ctx);
|
||||
}
|
||||
}
|
||||
|
@ -624,25 +624,59 @@ dummy_func(void) {
|
|||
}
|
||||
|
||||
op(_LOAD_ATTR_CLASS, (descr/4, owner -- attr)) {
|
||||
attr = sym_new_not_null(ctx);
|
||||
(void)descr;
|
||||
PyTypeObject *type = (PyTypeObject *)sym_get_const(ctx, owner);
|
||||
PyObject *name = PyTuple_GET_ITEM(co->co_names, oparg >> 1);
|
||||
attr = lookup_attr(ctx, this_instr, type, name,
|
||||
_POP_TOP_LOAD_CONST_INLINE_BORROW,
|
||||
_POP_TOP_LOAD_CONST_INLINE);
|
||||
}
|
||||
|
||||
op(_LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES, (descr/4, owner -- attr)) {
|
||||
(void)descr;
|
||||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = PyTuple_GET_ITEM(co->co_names, oparg >> 1);
|
||||
attr = lookup_attr(ctx, this_instr, type, name,
|
||||
_POP_TOP_LOAD_CONST_INLINE_BORROW,
|
||||
_POP_TOP_LOAD_CONST_INLINE);
|
||||
}
|
||||
|
||||
op(_LOAD_ATTR_NONDESCRIPTOR_NO_DICT, (descr/4, owner -- attr)) {
|
||||
(void)descr;
|
||||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = PyTuple_GET_ITEM(co->co_names, oparg >> 1);
|
||||
attr = lookup_attr(ctx, this_instr, type, name,
|
||||
_POP_TOP_LOAD_CONST_INLINE_BORROW,
|
||||
_POP_TOP_LOAD_CONST_INLINE);
|
||||
}
|
||||
|
||||
op(_LOAD_ATTR_METHOD_WITH_VALUES, (descr/4, owner -- attr, self)) {
|
||||
(void)descr;
|
||||
attr = sym_new_not_null(ctx);
|
||||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = PyTuple_GET_ITEM(co->co_names, oparg >> 1);
|
||||
attr = lookup_attr(ctx, this_instr, type, name,
|
||||
_LOAD_CONST_UNDER_INLINE_BORROW,
|
||||
_LOAD_CONST_UNDER_INLINE);
|
||||
self = owner;
|
||||
}
|
||||
|
||||
op(_LOAD_ATTR_METHOD_NO_DICT, (descr/4, owner -- attr, self)) {
|
||||
(void)descr;
|
||||
attr = sym_new_not_null(ctx);
|
||||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = PyTuple_GET_ITEM(co->co_names, oparg >> 1);
|
||||
attr = lookup_attr(ctx, this_instr, type, name,
|
||||
_LOAD_CONST_UNDER_INLINE_BORROW,
|
||||
_LOAD_CONST_UNDER_INLINE);
|
||||
self = owner;
|
||||
}
|
||||
|
||||
op(_LOAD_ATTR_METHOD_LAZY_DICT, (descr/4, owner -- attr, self)) {
|
||||
(void)descr;
|
||||
attr = sym_new_not_null(ctx);
|
||||
PyTypeObject *type = sym_get_type(owner);
|
||||
PyObject *name = PyTuple_GET_ITEM(co->co_names, oparg >> 1);
|
||||
attr = lookup_attr(ctx, this_instr, type, name,
|
||||
_LOAD_CONST_UNDER_INLINE_BORROW,
|
||||
_LOAD_CONST_UNDER_INLINE);
|
||||
self = owner;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue