mirror of
https://github.com/python/cpython.git
synced 2025-09-06 08:51:39 +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
74
Python/optimizer_cases.c.h
generated
74
Python/optimizer_cases.c.h
generated
|
@ -68,7 +68,7 @@
|
|||
|
||||
case _LOAD_CONST: {
|
||||
JitOptSymbol *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);
|
||||
stack_pointer[0] = value;
|
||||
|
@ -1174,7 +1174,7 @@
|
|||
self_or_null = &stack_pointer[0];
|
||||
(void)owner;
|
||||
attr = sym_new_not_null(ctx);
|
||||
if (oparg &1) {
|
||||
if (oparg & 1) {
|
||||
self_or_null[0] = sym_new_unknown(ctx);
|
||||
}
|
||||
stack_pointer[-1] = attr;
|
||||
|
@ -1284,10 +1284,16 @@
|
|||
}
|
||||
|
||||
case _LOAD_ATTR_CLASS: {
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
owner = stack_pointer[-1];
|
||||
PyObject *descr = (PyObject *)this_instr->operand0;
|
||||
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);
|
||||
stack_pointer[-1] = attr;
|
||||
break;
|
||||
}
|
||||
|
@ -1701,7 +1707,11 @@
|
|||
owner = stack_pointer[-1];
|
||||
PyObject *descr = (PyObject *)this_instr->operand0;
|
||||
(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;
|
||||
stack_pointer[-1] = attr;
|
||||
stack_pointer[0] = self;
|
||||
|
@ -1717,7 +1727,11 @@
|
|||
owner = stack_pointer[-1];
|
||||
PyObject *descr = (PyObject *)this_instr->operand0;
|
||||
(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;
|
||||
stack_pointer[-1] = attr;
|
||||
stack_pointer[0] = self;
|
||||
|
@ -1727,15 +1741,31 @@
|
|||
}
|
||||
|
||||
case _LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES: {
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
attr = sym_new_not_null(ctx);
|
||||
owner = stack_pointer[-1];
|
||||
PyObject *descr = (PyObject *)this_instr->operand0;
|
||||
(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);
|
||||
stack_pointer[-1] = attr;
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_ATTR_NONDESCRIPTOR_NO_DICT: {
|
||||
JitOptSymbol *owner;
|
||||
JitOptSymbol *attr;
|
||||
attr = sym_new_not_null(ctx);
|
||||
owner = stack_pointer[-1];
|
||||
PyObject *descr = (PyObject *)this_instr->operand0;
|
||||
(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);
|
||||
stack_pointer[-1] = attr;
|
||||
break;
|
||||
}
|
||||
|
@ -1751,7 +1781,11 @@
|
|||
owner = stack_pointer[-1];
|
||||
PyObject *descr = (PyObject *)this_instr->operand0;
|
||||
(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;
|
||||
stack_pointer[-1] = attr;
|
||||
stack_pointer[0] = self;
|
||||
|
@ -2594,6 +2628,30 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _LOAD_CONST_UNDER_INLINE: {
|
||||
JitOptSymbol *value;
|
||||
JitOptSymbol *new;
|
||||
value = sym_new_not_null(ctx);
|
||||
new = sym_new_not_null(ctx);
|
||||
stack_pointer[-1] = value;
|
||||
stack_pointer[0] = new;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_CONST_UNDER_INLINE_BORROW: {
|
||||
JitOptSymbol *value;
|
||||
JitOptSymbol *new;
|
||||
value = sym_new_not_null(ctx);
|
||||
new = sym_new_not_null(ctx);
|
||||
stack_pointer[-1] = value;
|
||||
stack_pointer[0] = new;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
case _CHECK_FUNCTION: {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue