Skip to content

Commit ff68109

Browse files
committed
Fix interaction of DEAD and DECREF_INPUTS
1 parent e389d6c commit ff68109

File tree

4 files changed

+39
-33
lines changed

4 files changed

+39
-33
lines changed

Python/bytecodes.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ dummy_func(
354354
(void)receiver;
355355
val = value;
356356
DEAD(value);
357-
PyStackRef_CLOSE(receiver);
357+
DECREF_INPUTS();
358358
}
359359

360360
tier1 inst(INSTRUMENTED_END_SEND, (receiver, value -- val)) {
@@ -2874,7 +2874,6 @@ dummy_func(
28742874
else {
28752875
/* `iterable` is not a generator. */
28762876
PyObject *iter_o = PyObject_GetIter(iterable_o);
2877-
DEAD(iterable);
28782877
if (iter_o == NULL) {
28792878
ERROR_NO_POP();
28802879
}
@@ -3827,27 +3826,27 @@ dummy_func(
38273826

38283827
op(_CALL_BUILTIN_CLASS, (callable[1], self_or_null[1], args[oparg] -- res)) {
38293828
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable[0]);
3830-
3829+
DEOPT_IF(!PyType_Check(callable_o));
3830+
PyTypeObject *tp = (PyTypeObject *)callable_o;
38313831
int total_args = oparg;
3832+
_PyStackRef *arguments = args;
38323833
if (!PyStackRef_IsNull(self_or_null[0])) {
3833-
args--;
3834+
arguments--;
38343835
total_args++;
38353836
}
3836-
DEAD(self_or_null);
3837-
DEOPT_IF(!PyType_Check(callable_o));
3838-
PyTypeObject *tp = (PyTypeObject *)callable_o;
38393837
DEOPT_IF(tp->tp_vectorcall == NULL);
38403838
STAT_INC(CALL, hit);
3841-
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
3839+
STACKREFS_TO_PYOBJECTS(arguments, total_args, args_o);
38423840
if (CONVERSION_FAILED(args_o)) {
38433841
DECREF_INPUTS();
38443842
ERROR_IF(true, error);
38453843
}
3844+
DEAD(self_or_null);
38463845
PyObject *res_o = tp->tp_vectorcall((PyObject *)tp, args_o, total_args, NULL);
38473846
STACKREFS_TO_PYOBJECTS_CLEANUP(args_o);
38483847
/* Free the arguments. */
38493848
for (int i = 0; i < total_args; i++) {
3850-
PyStackRef_CLOSE(args[i]);
3849+
PyStackRef_CLOSE(arguments[i]);
38513850
}
38523851
PyStackRef_CLOSE(callable[0]);
38533852
ERROR_IF(res_o == NULL, error);
@@ -3901,21 +3900,22 @@ dummy_func(
39013900
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable[0]);
39023901

39033902
int total_args = oparg;
3903+
_PyStackRef *arguments = args;
39043904
if (!PyStackRef_IsNull(self_or_null[0])) {
3905-
args--;
3905+
arguments--;
39063906
total_args++;
39073907
}
3908-
DEAD(self_or_null);
39093908
DEOPT_IF(!PyCFunction_CheckExact(callable_o));
39103909
DEOPT_IF(PyCFunction_GET_FLAGS(callable_o) != METH_FASTCALL);
39113910
STAT_INC(CALL, hit);
39123911
PyCFunction cfunc = PyCFunction_GET_FUNCTION(callable_o);
39133912
/* res = func(self, args, nargs) */
3914-
STACKREFS_TO_PYOBJECTS(args, total_args, args_o);
3913+
STACKREFS_TO_PYOBJECTS(arguments, total_args, args_o);
39153914
if (CONVERSION_FAILED(args_o)) {
39163915
DECREF_INPUTS();
39173916
ERROR_IF(true, error);
39183917
}
3918+
DEAD(self_or_null);
39193919
PyObject *res_o = ((PyCFunctionFast)(void(*)(void))cfunc)(
39203920
PyCFunction_GET_SELF(callable_o),
39213921
args_o,
@@ -3925,7 +3925,7 @@ dummy_func(
39253925

39263926
/* Free the arguments. */
39273927
for (int i = 0; i < total_args; i++) {
3928-
PyStackRef_CLOSE(args[i]);
3928+
PyStackRef_CLOSE(arguments[i]);
39293929
}
39303930
PyStackRef_CLOSE(callable[0]);
39313931
ERROR_IF(res_o == NULL, error);

Python/executor_cases.c.h

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

Python/generated_cases.c.h

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

Tools/cases_generator/generators_common.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,10 @@ def decref_inputs(
234234
next(tkn_iter)
235235
next(tkn_iter)
236236
self.out.emit_at("", tkn)
237-
for var in uop.stack.inputs:
238-
if var.name == "unused" or var.name == "null" or var.peek:
237+
for var in storage.inputs:
238+
if not var.defined:
239+
continue
240+
if var.name == "null":
239241
continue
240242
if var.size:
241243
if var.size == "1":

0 commit comments

Comments
 (0)