From 267ecf7d0cc52c367d2a6de9c57d5c6fd64eb997 Mon Sep 17 00:00:00 2001 From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Sat, 28 Jun 2025 00:18:23 +0800 Subject: [PATCH 1/5] Clear errors in JIT optimizer --- Python/optimizer_analysis.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c index fab6fef5ccda10..df7e9d61eddfe3 100644 --- a/Python/optimizer_analysis.c +++ b/Python/optimizer_analysis.c @@ -461,7 +461,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. */ +/* 1 for success, 0 for not ready, clears all possible errors. */ static int optimize_uops( PyCodeObject *co, @@ -471,6 +471,7 @@ optimize_uops( _PyBloomFilter *dependencies ) { + assert(!PyErr_Occurred()); JitOptContext context; JitOptContext *ctx = &context; @@ -557,6 +558,10 @@ optimize_uops( OPT_ERROR_IN_OPCODE(opcode); } _Py_uop_abstractcontext_fini(ctx); + + if (PyErr_Occurred()) { + PyErr_Clear(); + } return -1; } From 34c3f2b1c0269979bef81ff3e7cbbc4c7f630ba9 Mon Sep 17 00:00:00 2001 From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Sat, 28 Jun 2025 00:27:04 +0800 Subject: [PATCH 2/5] remove ability to return error --- Python/optimizer_analysis.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c index df7e9d61eddfe3..fa62c345efff97 100644 --- a/Python/optimizer_analysis.c +++ b/Python/optimizer_analysis.c @@ -484,7 +484,7 @@ optimize_uops( _Py_uop_abstractcontext_init(ctx); _Py_UOpsAbstractFrame *frame = _Py_uop_frame_new(ctx, co, curr_stacklen, NULL, 0); if (frame == NULL) { - return -1; + return 0; } ctx->curr_frame_depth++; ctx->frame = frame; @@ -562,7 +562,7 @@ optimize_uops( if (PyErr_Occurred()) { PyErr_Clear(); } - return -1; + return 0; } @@ -709,7 +709,7 @@ _Py_uop_analyze_and_optimize( _PyFrame_GetCode(frame), buffer, length, curr_stacklen, dependencies); - if (length <= 0) { + if (length == 0) { return length; } From 4eb978144e3247eef85c96a67ae41746f6864556 Mon Sep 17 00:00:00 2001 From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Sat, 28 Jun 2025 00:27:41 +0800 Subject: [PATCH 3/5] add assert --- Python/optimizer_analysis.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c index fa62c345efff97..28817aa4688287 100644 --- a/Python/optimizer_analysis.c +++ b/Python/optimizer_analysis.c @@ -713,6 +713,8 @@ _Py_uop_analyze_and_optimize( return length; } + assert(length > 0); + length = remove_unneeded_uops(buffer, length); assert(length > 0); From 412ec635e409ba5913ec4edf26a9a19acd84c38b Mon Sep 17 00:00:00 2001 From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Thu, 3 Jul 2025 19:00:10 +0800 Subject: [PATCH 4/5] Update optimizer_analysis.c --- Python/optimizer_analysis.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c index 28817aa4688287..e4f0b52ec7491f 100644 --- a/Python/optimizer_analysis.c +++ b/Python/optimizer_analysis.c @@ -559,9 +559,9 @@ optimize_uops( } _Py_uop_abstractcontext_fini(ctx); - if (PyErr_Occurred()) { - PyErr_Clear(); - } + assert(PyErr_Occurred()); + PyErr_Clear(); + return 0; } From 26e2978b595c443b14e4a8e1289f33c1f56bdd34 Mon Sep 17 00:00:00 2001 From: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Date: Thu, 3 Jul 2025 21:54:17 +0800 Subject: [PATCH 5/5] Update optimizer_analysis.c --- Python/optimizer_analysis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c index e4f0b52ec7491f..cffd4a18dd9996 100644 --- a/Python/optimizer_analysis.c +++ b/Python/optimizer_analysis.c @@ -561,7 +561,7 @@ optimize_uops( assert(PyErr_Occurred()); PyErr_Clear(); - + return 0; }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: