gh-gh-131798: optimize LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN in the JIT (#148555)

This commit is contained in:
Kumar Aditya 2026-04-14 21:00:32 +05:30 committed by GitHub
parent c88c27b0c1
commit 1aa7e7ee6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 1353 additions and 1168 deletions

View file

@ -1016,6 +1016,27 @@ dummy_func(void) {
new_frame = PyJitRef_WrapInvalid(f);
}
op(_LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN_FRAME, (func_version/2, getattribute/4, owner -- new_frame)) {
PyFunctionObject *func = (PyFunctionObject *)getattribute;
if (sym_get_type_version(owner) == 0 ||
func->func_version != func_version) {
ctx->contradiction = true;
ctx->done = true;
break;
}
_Py_BloomFilter_Add(dependencies, func);
PyCodeObject *co = (PyCodeObject *)func->func_code;
_Py_UOpsAbstractFrame *f = frame_new(ctx, co, NULL, 0);
if (f == NULL) {
break;
}
PyObject *name = get_co_name(ctx, oparg >> 1);
f->locals[0] = owner;
f->locals[1] = sym_new_const(ctx, name);
f->func = func;
new_frame = PyJitRef_WrapInvalid(f);
}
op(_INIT_CALL_BOUND_METHOD_EXACT_ARGS, (callable, self_or_null, unused[oparg] -- callable, self_or_null, unused[oparg])) {
PyObject *bound_method = sym_get_probable_value(callable);
if (bound_method != NULL && Py_TYPE(bound_method) == &PyMethod_Type) {