gh-148078: Fix uses of sym_is_not_null in JIT optimizer (GH-148079)

This commit is contained in:
Ken Jin 2026-04-04 18:16:23 +08:00 committed by GitHub
parent e7bf8eac0f
commit c50d6cd012
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 14 deletions

View file

@ -979,7 +979,7 @@ dummy_func(void) {
if (sym_is_null(self_or_null) || sym_is_not_null(self_or_null)) {
PyFunctionObject *func = (PyFunctionObject *)sym_get_const(ctx, callable);
PyCodeObject *co = (PyCodeObject *)func->func_code;
if (co->co_argcount == oparg + !sym_is_null(self_or_null)) {
if (co->co_argcount == oparg + sym_is_not_null(self_or_null)) {
ADD_OP(_NOP, 0 ,0);
}
}
@ -1266,9 +1266,10 @@ dummy_func(void) {
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)) {
if (callable_o && sym_matches_type(callable, &PyCFunction_Type) &&
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
int total_args = oparg;
if (!sym_is_null(self_or_null)) {
if (sym_is_not_null(self_or_null)) {
total_args++;
}
if (total_args == 1 && PyCFunction_GET_FLAGS(callable_o) == METH_O) {
@ -1321,7 +1322,8 @@ 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)) {
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
int total_args = oparg;
if (sym_is_not_null(self_or_null)) {
total_args++;
@ -1347,7 +1349,8 @@ dummy_func(void) {
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)) {
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
int total_args = oparg;
if (sym_is_not_null(self_or_null)) {
total_args++;
@ -1373,7 +1376,8 @@ dummy_func(void) {
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)) {
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
int total_args = oparg;
if (sym_is_not_null(self_or_null)) {
total_args++;
@ -1439,7 +1443,8 @@ dummy_func(void) {
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)) {
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
int total_args = oparg;
if (sym_is_not_null(self_or_null)) {
total_args++;

View file

@ -3565,7 +3565,7 @@
if (sym_is_null(self_or_null) || sym_is_not_null(self_or_null)) {
PyFunctionObject *func = (PyFunctionObject *)sym_get_const(ctx, callable);
PyCodeObject *co = (PyCodeObject *)func->func_code;
if (co->co_argcount == oparg + !sym_is_null(self_or_null)) {
if (co->co_argcount == oparg + sym_is_not_null(self_or_null)) {
ADD_OP(_NOP, 0 ,0);
}
}
@ -3835,9 +3835,10 @@
self_or_null = stack_pointer[-1 - oparg];
callable = stack_pointer[-2 - oparg];
PyObject *callable_o = sym_get_const(ctx, callable);
if (callable_o && sym_matches_type(callable, &PyCFunction_Type)) {
if (callable_o && sym_matches_type(callable, &PyCFunction_Type) &&
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
int total_args = oparg;
if (!sym_is_null(self_or_null)) {
if (sym_is_not_null(self_or_null)) {
total_args++;
}
if (total_args == 1 && PyCFunction_GET_FLAGS(callable_o) == METH_O) {
@ -4072,7 +4073,8 @@
self_or_null = stack_pointer[-1 - oparg];
callable = stack_pointer[-2 - oparg];
PyObject *callable_o = sym_get_const(ctx, callable);
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type)) {
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
int total_args = oparg;
if (sym_is_not_null(self_or_null)) {
total_args++;
@ -4171,7 +4173,8 @@
self_or_null = stack_pointer[-1 - oparg];
callable = stack_pointer[-2 - oparg];
PyObject *callable_o = sym_get_const(ctx, callable);
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type)) {
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
int total_args = oparg;
if (sym_is_not_null(self_or_null)) {
total_args++;
@ -4235,7 +4238,8 @@
self_or_null = stack_pointer[-1 - oparg];
callable = stack_pointer[-2 - oparg];
PyObject *callable_o = sym_get_const(ctx, callable);
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type)) {
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
int total_args = oparg;
if (sym_is_not_null(self_or_null)) {
total_args++;
@ -4299,7 +4303,8 @@
self_or_null = stack_pointer[-1 - oparg];
callable = stack_pointer[-2 - oparg];
PyObject *callable_o = sym_get_const(ctx, callable);
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type)) {
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
int total_args = oparg;
if (sym_is_not_null(self_or_null)) {
total_args++;