mirror of
https://github.com/python/cpython.git
synced 2026-04-14 15:50:50 +00:00
gh-131798: JIT: split call method and call builtin opcodes into smaller uops (#146463)
This commit is contained in:
parent
0e543055b0
commit
bfdaa3c565
10 changed files with 2324 additions and 1540 deletions
|
|
@ -1231,6 +1231,46 @@ dummy_func(void) {
|
|||
none = sym_new_const(ctx, Py_None);
|
||||
}
|
||||
|
||||
op(_GUARD_CALLABLE_BUILTIN_O, (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, &PyCFunction_Type)) {
|
||||
int total_args = oparg;
|
||||
if (!sym_is_null(self_or_null)) {
|
||||
total_args++;
|
||||
}
|
||||
if (total_args == 1 && PyCFunction_GET_FLAGS(callable_o) == METH_O) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sym_set_type(callable, &PyCFunction_Type);
|
||||
}
|
||||
}
|
||||
|
||||
op(_GUARD_CALLABLE_BUILTIN_FAST, (callable, unused, unused[oparg] -- callable, unused, unused[oparg])) {
|
||||
PyObject *callable_o = sym_get_const(ctx, callable);
|
||||
if (callable_o && sym_matches_type(callable, &PyCFunction_Type)) {
|
||||
if (PyCFunction_GET_FLAGS(callable_o) == METH_FASTCALL) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sym_set_type(callable, &PyCFunction_Type);
|
||||
}
|
||||
}
|
||||
|
||||
op(_GUARD_CALLABLE_BUILTIN_FAST_WITH_KEYWORDS, (callable, unused, unused[oparg] -- callable, unused, unused[oparg])) {
|
||||
PyObject *callable_o = sym_get_const(ctx, callable);
|
||||
if (callable_o && sym_matches_type(callable, &PyCFunction_Type)) {
|
||||
if (PyCFunction_GET_FLAGS(callable_o) == (METH_FASTCALL | METH_KEYWORDS)) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sym_set_type(callable, &PyCFunction_Type);
|
||||
}
|
||||
}
|
||||
|
||||
op(_CALL_BUILTIN_O, (callable, self_or_null, args[oparg] -- res, c, s)) {
|
||||
res = sym_new_not_null(ctx);
|
||||
c = callable;
|
||||
|
|
@ -1246,6 +1286,106 @@ dummy_func(void) {
|
|||
}
|
||||
}
|
||||
|
||||
op(_GUARD_CALLABLE_METHOD_DESCRIPTOR_O, (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)) {
|
||||
int total_args = oparg;
|
||||
if (!sym_is_null(self_or_null)) {
|
||||
total_args++;
|
||||
}
|
||||
PyObject *self = NULL;
|
||||
if (!sym_is_null(self_or_null)) {
|
||||
self = sym_get_const(ctx, self_or_null);
|
||||
} else {
|
||||
self = sym_get_const(ctx, args[0]);
|
||||
}
|
||||
PyTypeObject *d_type = ((PyMethodDescrObject *)callable_o)->d_common.d_type;
|
||||
if (total_args == 2 &&
|
||||
((PyMethodDescrObject *)callable_o)->d_method->ml_flags == METH_O &&
|
||||
self && Py_IS_TYPE(self, d_type)) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sym_set_type(callable, &PyMethodDescr_Type);
|
||||
}
|
||||
}
|
||||
|
||||
op(_GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, (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)) {
|
||||
int total_args = oparg;
|
||||
if (!sym_is_null(self_or_null)) {
|
||||
total_args++;
|
||||
}
|
||||
PyObject *self = NULL;
|
||||
if (!sym_is_null(self_or_null)) {
|
||||
self = sym_get_const(ctx, self_or_null);
|
||||
} else {
|
||||
self = sym_get_const(ctx, args[0]);
|
||||
}
|
||||
PyTypeObject *d_type = ((PyMethodDescrObject *)callable_o)->d_common.d_type;
|
||||
if (total_args != 0 &&
|
||||
((PyMethodDescrObject *)callable_o)->d_method->ml_flags == (METH_FASTCALL|METH_KEYWORDS) &&
|
||||
self && Py_IS_TYPE(self, d_type)) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sym_set_type(callable, &PyMethodDescr_Type);
|
||||
}
|
||||
}
|
||||
|
||||
op(_GUARD_CALLABLE_METHOD_DESCRIPTOR_NOARGS, (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)) {
|
||||
int total_args = oparg;
|
||||
if (!sym_is_null(self_or_null)) {
|
||||
total_args++;
|
||||
}
|
||||
PyObject *self = NULL;
|
||||
if (!sym_is_null(self_or_null)) {
|
||||
self = sym_get_const(ctx, self_or_null);
|
||||
} else {
|
||||
self = sym_get_const(ctx, args[0]);
|
||||
}
|
||||
PyTypeObject *d_type = ((PyMethodDescrObject *)callable_o)->d_common.d_type;
|
||||
if (total_args == 1 &&
|
||||
((PyMethodDescrObject *)callable_o)->d_method->ml_flags == METH_NOARGS &&
|
||||
self && Py_IS_TYPE(self, d_type)) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sym_set_type(callable, &PyMethodDescr_Type);
|
||||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
int total_args = oparg;
|
||||
if (!sym_is_null(self_or_null)) {
|
||||
total_args++;
|
||||
}
|
||||
PyObject *self = NULL;
|
||||
if (!sym_is_null(self_or_null)) {
|
||||
self = sym_get_const(ctx, self_or_null);
|
||||
} else {
|
||||
self = sym_get_const(ctx, args[0]);
|
||||
}
|
||||
PyTypeObject *d_type = ((PyMethodDescrObject *)callable_o)->d_common.d_type;
|
||||
if (total_args != 0 &&
|
||||
((PyMethodDescrObject *)callable_o)->d_method->ml_flags == METH_FASTCALL &&
|
||||
self && Py_IS_TYPE(self, d_type)) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sym_set_type(callable, &PyMethodDescr_Type);
|
||||
}
|
||||
}
|
||||
|
||||
op(_CALL_METHOD_DESCRIPTOR_O, (callable, self_or_null, args[oparg] -- res, c, s, a)) {
|
||||
res = sym_new_not_null(ctx);
|
||||
c = callable;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue