https://github.com/python/cpython/commit/46f823bb818b0e8f40b51c8fa9ef33f743915770
commit: 46f823bb818b0e8f40b51c8fa9ef33f743915770
branch: main
author: Ken Jin <[email protected]>
committer: Fidget-Spinner <[email protected]>
date: 2025-09-15T17:24:37+01:00
summary:
gh-132732: Clear errors in JIT optimizer on error (GH-136048)
files:
M Python/optimizer_analysis.c
diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c
index fd395d3c6c254f..9d43f2de41df78 100644
--- a/Python/optimizer_analysis.c
+++ b/Python/optimizer_analysis.c
@@ -462,7 +462,7 @@ const uint16_t op_without_decref_inputs[MAX_UOP_ID + 1] = {
[_BINARY_OP_SUBTRACT_FLOAT] = _BINARY_OP_SUBTRACT_FLOAT__NO_DECREF_INPUTS,
};
-/* 1 for success, 0 for not ready, cannot error at the moment. */
+/* >0 (length) for success, 0 for not ready, clears all possible errors. */
static int
optimize_uops(
PyCodeObject *co,
@@ -472,6 +472,7 @@ optimize_uops(
_PyBloomFilter *dependencies
)
{
+ assert(!PyErr_Occurred());
JitOptContext context;
JitOptContext *ctx = &context;
@@ -555,7 +556,11 @@ optimize_uops(
OPT_ERROR_IN_OPCODE(opcode);
}
_Py_uop_abstractcontext_fini(ctx);
- return -1;
+
+ assert(PyErr_Occurred());
+ PyErr_Clear();
+
+ return 0;
}
@@ -702,10 +707,12 @@ _Py_uop_analyze_and_optimize(
_PyFrame_GetCode(frame), buffer,
length, curr_stacklen, dependencies);
- if (length <= 0) {
+ if (length == 0) {
return length;
}
+ assert(length > 0);
+
length = remove_unneeded_uops(buffer, length);
assert(length > 0);
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]