gh-131798: JIT inline function addresses of builtin methods (#146906)

This commit is contained in:
Kumar Aditya 2026-04-04 09:12:13 +05:30 committed by GitHub
parent b8470deb5d
commit 7e275d4965
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 1724 additions and 1282 deletions

View file

@ -1394,6 +1394,39 @@ dummy_func(void) {
}
}
op(_CALL_METHOD_DESCRIPTOR_NOARGS, (callable, self_or_null, args[oparg] -- res)) {
PyObject *callable_o = sym_get_const(ctx, callable);
if (callable_o && Py_IS_TYPE(callable_o, &PyMethodDescr_Type)
&& sym_is_not_null(self_or_null)) {
PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o;
PyCFunction cfunc = method->d_method->ml_meth;
ADD_OP(_CALL_METHOD_DESCRIPTOR_NOARGS_INLINE, oparg + 1, (uintptr_t)cfunc);
}
res = sym_new_not_null(ctx);
}
op(_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, (callable, self_or_null, args[oparg] -- res)) {
PyObject *callable_o = sym_get_const(ctx, callable);
if (callable_o && Py_IS_TYPE(callable_o, &PyMethodDescr_Type)
&& sym_is_not_null(self_or_null)) {
PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o;
PyCFunction cfunc = method->d_method->ml_meth;
ADD_OP(_CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS_INLINE, oparg + 1, (uintptr_t)cfunc);
}
res = sym_new_not_null(ctx);
}
op(_CALL_METHOD_DESCRIPTOR_FAST, (callable, self_or_null, args[oparg] -- res)) {
PyObject *callable_o = sym_get_const(ctx, callable);
if (callable_o && Py_IS_TYPE(callable_o, &PyMethodDescr_Type)
&& sym_is_not_null(self_or_null)) {
PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o;
PyCFunction cfunc = method->d_method->ml_meth;
ADD_OP(_CALL_METHOD_DESCRIPTOR_FAST_INLINE, oparg + 1, (uintptr_t)cfunc);
}
res = sym_new_not_null(ctx);
}
op(_GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST, (callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) {
PyObject *callable_o = sym_get_const(ctx, callable);
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type)) {
@ -1420,6 +1453,13 @@ dummy_func(void) {
}
op(_CALL_METHOD_DESCRIPTOR_O, (callable, self_or_null, args[oparg] -- res, c, s, a)) {
PyObject *callable_o = sym_get_const(ctx, callable);
if (callable_o && Py_IS_TYPE(callable_o, &PyMethodDescr_Type)
&& sym_is_not_null(self_or_null)) {
PyMethodDescrObject *method = (PyMethodDescrObject *)callable_o;
PyCFunction cfunc = method->d_method->ml_meth;
ADD_OP(_CALL_METHOD_DESCRIPTOR_O_INLINE, oparg + 1, (uintptr_t)cfunc);
}
res = sym_new_not_null(ctx);
c = callable;
if (sym_is_not_null(self_or_null)) {