aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/optimizer_cases.c.h
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2025-01-14 15:08:56 +0000
committerGitHub <noreply@github.com>2025-01-14 15:08:56 +0000
commitf49a1df6f3b1249bcaedfda8e000e27c6cdffd99 (patch)
tree154fa92c820b5d06bee762eb5778f8f1556318ba /Python/optimizer_cases.c.h
parentbbd3300ae82a71da483dbb0c345175ba090263c4 (diff)
downloadcpython-f49a1df6f3b1249bcaedfda8e000e27c6cdffd99.tar.gz
cpython-f49a1df6f3b1249bcaedfda8e000e27c6cdffd99.zip
GH-128682: Convert explicit loops closing arrays into `DECREF_INPUTS`. (GH-128822)
* Mark Py_DECREF and Py_XDECREF as escaping * Remove explicit loops for clearing array inputs
Diffstat (limited to 'Python/optimizer_cases.c.h')
-rw-r--r--Python/optimizer_cases.c.h69
1 files changed, 46 insertions, 23 deletions
diff --git a/Python/optimizer_cases.c.h b/Python/optimizer_cases.c.h
index a64dd465467..1a7cc6becfe 100644
--- a/Python/optimizer_cases.c.h
+++ b/Python/optimizer_cases.c.h
@@ -279,16 +279,19 @@
goto error;
}
res = sym_new_const(ctx, temp);
+ stack_pointer[-2] = res;
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
Py_DECREF(temp);
// TODO gh-115506:
// replace opcode with constant propagated one and add tests!
}
else {
res = sym_new_type(ctx, &PyLong_Type);
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
}
- stack_pointer[-2] = res;
- stack_pointer += -1;
- assert(WITHIN_STACK_BOUNDS());
+ stack_pointer[-1] = res;
break;
}
@@ -309,16 +312,19 @@
goto error;
}
res = sym_new_const(ctx, temp);
+ stack_pointer[-2] = res;
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
Py_DECREF(temp);
// TODO gh-115506:
// replace opcode with constant propagated one and add tests!
}
else {
res = sym_new_type(ctx, &PyLong_Type);
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
}
- stack_pointer[-2] = res;
- stack_pointer += -1;
- assert(WITHIN_STACK_BOUNDS());
+ stack_pointer[-1] = res;
break;
}
@@ -339,16 +345,19 @@
goto error;
}
res = sym_new_const(ctx, temp);
+ stack_pointer[-2] = res;
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
Py_DECREF(temp);
// TODO gh-115506:
// replace opcode with constant propagated one and add tests!
}
else {
res = sym_new_type(ctx, &PyLong_Type);
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
}
- stack_pointer[-2] = res;
- stack_pointer += -1;
- assert(WITHIN_STACK_BOUNDS());
+ stack_pointer[-1] = res;
break;
}
@@ -401,16 +410,19 @@
goto error;
}
res = sym_new_const(ctx, temp);
+ stack_pointer[-2] = res;
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
Py_DECREF(temp);
// TODO gh-115506:
// replace opcode with constant propagated one and update tests!
}
else {
res = sym_new_type(ctx, &PyFloat_Type);
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
}
- stack_pointer[-2] = res;
- stack_pointer += -1;
- assert(WITHIN_STACK_BOUNDS());
+ stack_pointer[-1] = res;
break;
}
@@ -432,16 +444,19 @@
goto error;
}
res = sym_new_const(ctx, temp);
+ stack_pointer[-2] = res;
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
Py_DECREF(temp);
// TODO gh-115506:
// replace opcode with constant propagated one and update tests!
}
else {
res = sym_new_type(ctx, &PyFloat_Type);
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
}
- stack_pointer[-2] = res;
- stack_pointer += -1;
- assert(WITHIN_STACK_BOUNDS());
+ stack_pointer[-1] = res;
break;
}
@@ -463,16 +478,19 @@
goto error;
}
res = sym_new_const(ctx, temp);
+ stack_pointer[-2] = res;
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
Py_DECREF(temp);
// TODO gh-115506:
// replace opcode with constant propagated one and update tests!
}
else {
res = sym_new_type(ctx, &PyFloat_Type);
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
}
- stack_pointer[-2] = res;
- stack_pointer += -1;
- assert(WITHIN_STACK_BOUNDS());
+ stack_pointer[-1] = res;
break;
}
@@ -503,14 +521,17 @@
goto error;
}
res = sym_new_const(ctx, temp);
+ stack_pointer[-2] = res;
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
Py_DECREF(temp);
}
else {
res = sym_new_type(ctx, &PyUnicode_Type);
+ stack_pointer += -1;
+ assert(WITHIN_STACK_BOUNDS());
}
- stack_pointer[-2] = res;
- stack_pointer += -1;
- assert(WITHIN_STACK_BOUNDS());
+ stack_pointer[-1] = res;
break;
}
@@ -527,15 +548,17 @@
goto error;
}
res = sym_new_const(ctx, temp);
+ stack_pointer += -2;
+ assert(WITHIN_STACK_BOUNDS());
Py_DECREF(temp);
}
else {
res = sym_new_type(ctx, &PyUnicode_Type);
+ stack_pointer += -2;
+ assert(WITHIN_STACK_BOUNDS());
}
// _STORE_FAST:
GETLOCAL(this_instr->operand0) = res;
- stack_pointer += -2;
- assert(WITHIN_STACK_BOUNDS());
break;
}