aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/optimizer_cases.c.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2025-02-12 17:44:59 +0000
committerGitHub <noreply@github.com>2025-02-12 17:44:59 +0000
commit72f56654d06a6d23c91e892c05f9e4d70009315b (patch)
treeb3e989cd2023ddceb9237ce0e1721538dca1d088 /Python/optimizer_cases.c.h
parent3e222e3a15959690a41847a1177ac424427815e5 (diff)
downloadcpython-72f56654d06a6d23c91e892c05f9e4d70009315b.tar.gz
cpython-72f56654d06a6d23c91e892c05f9e4d70009315b.zip
GH-128682: Account for escapes in `DECREF_INPUTS` (GH-129953)
* Handle escapes in DECREF_INPUTS * Mark a few more functions as escaping * Replace DECREF_INPUTS with PyStackRef_CLOSE where possible
Diffstat (limited to 'Python/optimizer_cases.c.h')
-rw-r--r--Python/optimizer_cases.c.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h
index fd8486785ed..51d0fa63e64 100644
--- a/Python/optimizer_cases.c.h
+++ b/Python/optimizer_cases.c.h
@@ -273,14 +273,16 @@
{
assert(PyLong_CheckExact(sym_get_const(left)));
assert(PyLong_CheckExact(sym_get_const(right)));
+ stack_pointer += -2;
+ assert(WITHIN_STACK_BOUNDS());
PyObject *temp = _PyLong_Multiply((PyLongObject *)sym_get_const(left),
(PyLongObject *)sym_get_const(right));
if (temp == NULL) {
goto error;
}
res = sym_new_const(ctx, temp);
- stack_pointer[-2] = res;
- stack_pointer += -1;
+ stack_pointer[0] = res;
+ stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
Py_DECREF(temp);
// TODO gh-115506:
@@ -306,14 +308,16 @@
{
assert(PyLong_CheckExact(sym_get_const(left)));
assert(PyLong_CheckExact(sym_get_const(right)));
+ stack_pointer += -2;
+ assert(WITHIN_STACK_BOUNDS());
PyObject *temp = _PyLong_Add((PyLongObject *)sym_get_const(left),
(PyLongObject *)sym_get_const(right));
if (temp == NULL) {
goto error;
}
res = sym_new_const(ctx, temp);
- stack_pointer[-2] = res;
- stack_pointer += -1;
+ stack_pointer[0] = res;
+ stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
Py_DECREF(temp);
// TODO gh-115506:
@@ -339,14 +343,16 @@
{
assert(PyLong_CheckExact(sym_get_const(left)));
assert(PyLong_CheckExact(sym_get_const(right)));
+ stack_pointer += -2;
+ assert(WITHIN_STACK_BOUNDS());
PyObject *temp = _PyLong_Subtract((PyLongObject *)sym_get_const(left),
(PyLongObject *)sym_get_const(right));
if (temp == NULL) {
goto error;
}
res = sym_new_const(ctx, temp);
- stack_pointer[-2] = res;
- stack_pointer += -1;
+ stack_pointer[0] = res;
+ stack_pointer += 1;
assert(WITHIN_STACK_BOUNDS());
Py_DECREF(temp);
// TODO gh-115506: