mirror of
https://github.com/python/cpython.git
synced 2026-04-15 08:11:10 +00:00
gh-131798: relax GUARD_CALLABLE checks for self type checks (#148069)
This commit is contained in:
parent
7e275d4965
commit
7bcc1c4920
2 changed files with 64 additions and 56 deletions
|
|
@ -1323,19 +1323,20 @@ dummy_func(void) {
|
|||
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)) {
|
||||
if (sym_is_not_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 *self_type = NULL;
|
||||
if (sym_is_not_null(self_or_null)) {
|
||||
self_type = sym_get_type(self_or_null);
|
||||
}
|
||||
else {
|
||||
self_type = sym_get_type(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)) {
|
||||
self_type == d_type) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1348,19 +1349,20 @@ dummy_func(void) {
|
|||
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)) {
|
||||
if (sym_is_not_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 *self_type = NULL;
|
||||
if (sym_is_not_null(self_or_null)) {
|
||||
self_type = sym_get_type(self_or_null);
|
||||
}
|
||||
else {
|
||||
self_type = sym_get_type(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)) {
|
||||
self_type == d_type) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1373,19 +1375,20 @@ dummy_func(void) {
|
|||
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)) {
|
||||
if (sym_is_not_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 *self_type = NULL;
|
||||
if (sym_is_not_null(self_or_null)) {
|
||||
self_type = sym_get_type(self_or_null);
|
||||
}
|
||||
else {
|
||||
self_type = sym_get_type(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)) {
|
||||
self_type == d_type) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -1431,19 +1434,20 @@ dummy_func(void) {
|
|||
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)) {
|
||||
if (sym_is_not_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 *self_type = NULL;
|
||||
if (sym_is_not_null(self_or_null)) {
|
||||
self_type = sym_get_type(self_or_null);
|
||||
}
|
||||
else {
|
||||
self_type = sym_get_type(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)) {
|
||||
self_type == d_type) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
60
Python/optimizer_cases.c.h
generated
60
Python/optimizer_cases.c.h
generated
|
|
@ -4074,19 +4074,20 @@
|
|||
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)) {
|
||||
if (sym_is_not_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 *self_type = NULL;
|
||||
if (sym_is_not_null(self_or_null)) {
|
||||
self_type = sym_get_type(self_or_null);
|
||||
}
|
||||
else {
|
||||
self_type = sym_get_type(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)) {
|
||||
self_type == d_type) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -4164,19 +4165,20 @@
|
|||
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)) {
|
||||
if (sym_is_not_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 *self_type = NULL;
|
||||
if (sym_is_not_null(self_or_null)) {
|
||||
self_type = sym_get_type(self_or_null);
|
||||
}
|
||||
else {
|
||||
self_type = sym_get_type(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)) {
|
||||
self_type == d_type) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -4227,19 +4229,20 @@
|
|||
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)) {
|
||||
if (sym_is_not_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 *self_type = NULL;
|
||||
if (sym_is_not_null(self_or_null)) {
|
||||
self_type = sym_get_type(self_or_null);
|
||||
}
|
||||
else {
|
||||
self_type = sym_get_type(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)) {
|
||||
self_type == d_type) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -4290,19 +4293,20 @@
|
|||
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)) {
|
||||
if (sym_is_not_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 *self_type = NULL;
|
||||
if (sym_is_not_null(self_or_null)) {
|
||||
self_type = sym_get_type(self_or_null);
|
||||
}
|
||||
else {
|
||||
self_type = sym_get_type(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)) {
|
||||
self_type == d_type) {
|
||||
ADD_OP(_NOP, 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue