mirror of
https://github.com/python/cpython.git
synced 2026-04-20 10:51:00 +00:00
gh-131798: fold super method lookups in JIT (#148231)
This commit is contained in:
parent
ee5232782f
commit
458aca9237
14 changed files with 1762 additions and 1278 deletions
|
|
@ -943,6 +943,34 @@ dummy_func(void) {
|
|||
self = owner;
|
||||
}
|
||||
|
||||
op(_GUARD_LOAD_SUPER_ATTR_METHOD, (global_super_st, class_st, unused -- global_super_st, class_st, unused)) {
|
||||
if (sym_get_const(ctx, global_super_st) == (PyObject *)&PySuper_Type) {
|
||||
PyTypeObject *probable = (PyTypeObject *)sym_get_probable_value(class_st);
|
||||
PyTypeObject *known = (PyTypeObject *)sym_get_const(ctx, class_st);
|
||||
// not known, but has a probable type, promote the probable type
|
||||
if (known == NULL && probable != NULL && PyType_Check(probable)) {
|
||||
ADD_OP(_GUARD_NOS_TYPE_VERSION, 0, probable->tp_version_tag);
|
||||
known = probable;
|
||||
}
|
||||
sym_set_const(class_st, (PyObject *)known);
|
||||
}
|
||||
else {
|
||||
sym_set_const(global_super_st, (PyObject *)&PySuper_Type);
|
||||
sym_set_type(class_st, &PyType_Type);
|
||||
}
|
||||
}
|
||||
|
||||
op(_LOAD_SUPER_ATTR_METHOD, (global_super_st, class_st, self_st -- attr, self_or_null)) {
|
||||
self_or_null = self_st;
|
||||
PyTypeObject *su_type = (PyTypeObject *)sym_get_const(ctx, class_st);
|
||||
PyTypeObject *obj_type = sym_get_type(self_st);
|
||||
PyObject *name = get_co_name(ctx, oparg >> 2);
|
||||
attr = lookup_super_attr(ctx, dependencies, this_instr,
|
||||
su_type, obj_type, name,
|
||||
_INSERT_1_LOAD_CONST_INLINE_BORROW,
|
||||
_INSERT_1_LOAD_CONST_INLINE);
|
||||
}
|
||||
|
||||
op(_LOAD_ATTR_PROPERTY_FRAME, (fget/4, owner -- new_frame)) {
|
||||
// + 1 for _SAVE_RETURN_OFFSET
|
||||
// FIX ME -- This needs a version check and function watcher
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue