]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-98831: Add DECREF_INPUTS(), expanding to DECREF() each stack input (#100205)
authorGuido van Rossum <guido@python.org>
Sat, 17 Dec 2022 04:45:55 +0000 (20:45 -0800)
committerGitHub <noreply@github.com>
Sat, 17 Dec 2022 04:45:55 +0000 (20:45 -0800)
commit9cdd2fa63b7549d00830bccf19a34e9d69d0b15e
treef0176ca0fa55305d05c3dfc829ad6281b20be3ee
parent5a991da32961ef5780996d58b8816d5f2085f540
GH-98831: Add DECREF_INPUTS(), expanding to DECREF() each stack input (#100205)

The presence of this macro indicates that a particular instruction
may be considered for conversion to a register-based format
(see https://github.com/faster-cpython/ideas/issues/485).

An invariant (currently unchecked) is that `DEOPT_IF()` may only
occur *before* `DECREF_INPUTS()`, and `ERROR_IF()` may only occur
*after* it. One reason not to check this is that there are a few
places where we insert *two* `DECREF_INPUTS()` calls, in different
branches of the code. The invariant checking would have to be able
to do some flow control analysis to understand this.

Note that many instructions, especially specialized ones,
can't be converted to use this macro straightforwardly.
This is because the generator currently only generates plain
`Py_DECREF(variable)` statements, and cannot generate
things like `_Py_DECREF_SPECIALIZED()` let alone deal with
`_PyList_AppendTakeRef()`.
Python/bytecodes.c
Tools/cases_generator/generate_cases.py