]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-148078: Fix uses of sym_is_not_null in JIT optimizer (GH-148079)
authorKen Jin <kenjin@python.org>
Sat, 4 Apr 2026 10:16:23 +0000 (18:16 +0800)
committerGitHub <noreply@github.com>
Sat, 4 Apr 2026 10:16:23 +0000 (18:16 +0800)
Python/optimizer_bytecodes.c
Python/optimizer_cases.c.h

index 4f16fa7a5ff4bfe37a9a1ff9e3ad39face88a8f2..dfb97625bf924fcbfecf773c581cc23b70688727 100644 (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++;
index 2b0efd9db252d7c3bb5c1ad8c9ce34366c7deddf..4643a0ed0c5f9d5adbf8c5780d325e414ccd5632 100644 (file)
                 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);
                     }
                 }
             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) {
             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++;
             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++;
             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++;
             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++;