Skip to content

Commit c50d6cd

Browse files
gh-148078: Fix uses of sym_is_not_null in JIT optimizer (GH-148079)
1 parent e7bf8ea commit c50d6cd

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

Python/optimizer_bytecodes.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ dummy_func(void) {
979979
if (sym_is_null(self_or_null) || sym_is_not_null(self_or_null)) {
980980
PyFunctionObject *func = (PyFunctionObject *)sym_get_const(ctx, callable);
981981
PyCodeObject *co = (PyCodeObject *)func->func_code;
982-
if (co->co_argcount == oparg + !sym_is_null(self_or_null)) {
982+
if (co->co_argcount == oparg + sym_is_not_null(self_or_null)) {
983983
ADD_OP(_NOP, 0 ,0);
984984
}
985985
}
@@ -1266,9 +1266,10 @@ dummy_func(void) {
12661266

12671267
op(_GUARD_CALLABLE_BUILTIN_O, (callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) {
12681268
PyObject *callable_o = sym_get_const(ctx, callable);
1269-
if (callable_o && sym_matches_type(callable, &PyCFunction_Type)) {
1269+
if (callable_o && sym_matches_type(callable, &PyCFunction_Type) &&
1270+
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
12701271
int total_args = oparg;
1271-
if (!sym_is_null(self_or_null)) {
1272+
if (sym_is_not_null(self_or_null)) {
12721273
total_args++;
12731274
}
12741275
if (total_args == 1 && PyCFunction_GET_FLAGS(callable_o) == METH_O) {
@@ -1321,7 +1322,8 @@ dummy_func(void) {
13211322

13221323
op(_GUARD_CALLABLE_METHOD_DESCRIPTOR_O, (callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) {
13231324
PyObject *callable_o = sym_get_const(ctx, callable);
1324-
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type)) {
1325+
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&
1326+
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
13251327
int total_args = oparg;
13261328
if (sym_is_not_null(self_or_null)) {
13271329
total_args++;
@@ -1347,7 +1349,8 @@ dummy_func(void) {
13471349

13481350
op(_GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS, (callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) {
13491351
PyObject *callable_o = sym_get_const(ctx, callable);
1350-
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type)) {
1352+
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&
1353+
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
13511354
int total_args = oparg;
13521355
if (sym_is_not_null(self_or_null)) {
13531356
total_args++;
@@ -1373,7 +1376,8 @@ dummy_func(void) {
13731376

13741377
op(_GUARD_CALLABLE_METHOD_DESCRIPTOR_NOARGS, (callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) {
13751378
PyObject *callable_o = sym_get_const(ctx, callable);
1376-
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type)) {
1379+
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&
1380+
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
13771381
int total_args = oparg;
13781382
if (sym_is_not_null(self_or_null)) {
13791383
total_args++;
@@ -1439,7 +1443,8 @@ dummy_func(void) {
14391443

14401444
op(_GUARD_CALLABLE_METHOD_DESCRIPTOR_FAST, (callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) {
14411445
PyObject *callable_o = sym_get_const(ctx, callable);
1442-
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type)) {
1446+
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&
1447+
(sym_is_not_null(self_or_null) || sym_is_null(self_or_null))) {
14431448
int total_args = oparg;
14441449
if (sym_is_not_null(self_or_null)) {
14451450
total_args++;

Python/optimizer_cases.c.h

Lines changed: 12 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)