From 895b7a0f8fd7c85c293b6ff2117ea54b08944176 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Wed, 9 Aug 2023 23:55:12 -0700 Subject: [PATCH 1/3] Fix uop instrumentation --- Python/bytecodes.c | 10 ++++++---- Python/executor_cases.c.h | 10 ++++++---- Python/generated_cases.c.h | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index a5cb117c7631c6..110bf9451d9581 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -133,17 +133,19 @@ dummy_func( } inst(RESUME, (--)) { - #if TIER_ONE assert(frame == tstate->current_frame); /* Possibly combine this with eval breaker */ if (_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version) { int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp); ERROR_IF(err, error); + #if TIER_ONE next_instr--; - } - else #endif - if (oparg < 2) { + #if TIER_TWO + goto deoptimize; + #endif + } + else if (oparg < 2) { CHECK_EVAL_BREAKER(); } } diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 85c60c276e0292..45d2d39c3940b0 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -8,17 +8,19 @@ } case RESUME: { - #if TIER_ONE assert(frame == tstate->current_frame); /* Possibly combine this with eval breaker */ if (_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version) { int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp); if (err) goto error; + #if TIER_ONE next_instr--; - } - else #endif - if (oparg < 2) { + #if TIER_TWO + goto deoptimize; + #endif + } + else if (oparg < 2) { CHECK_EVAL_BREAKER(); } break; diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 4aa16f8311a2a0..06068b4dde17bd 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -8,17 +8,19 @@ } TARGET(RESUME) { - #if TIER_ONE assert(frame == tstate->current_frame); /* Possibly combine this with eval breaker */ if (_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version) { int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp); if (err) goto error; + #if TIER_ONE next_instr--; - } - else #endif - if (oparg < 2) { + #if TIER_TWO + goto deoptimize; + #endif + } + else if (oparg < 2) { CHECK_EVAL_BREAKER(); } DISPATCH(); From 50941711d50ed0396f61d22dbf636153967e87f5 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 10 Aug 2023 00:00:59 -0700 Subject: [PATCH 2/3] Blurb add --- .../2023-08-10-00-00-48.gh-issue-106581.o7zDty.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-08-10-00-00-48.gh-issue-106581.o7zDty.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-08-10-00-00-48.gh-issue-106581.o7zDty.rst b/Misc/NEWS.d/next/Core and Builtins/2023-08-10-00-00-48.gh-issue-106581.o7zDty.rst new file mode 100644 index 00000000000000..dff1ebd9cf70f0 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-08-10-00-00-48.gh-issue-106581.o7zDty.rst @@ -0,0 +1,2 @@ +Fix possible assertion failures and missing instrumentation events when +:envvar:`PYTHONUOPS` or :option:`-X uops <-X>` is enabled. From b9c2d7e57660f3262a2a8a251fa1c38e4dda5022 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Thu, 10 Aug 2023 00:42:38 -0700 Subject: [PATCH 3/3] Change indentation --- Python/bytecodes.c | 10 +++++----- Python/executor_cases.c.h | 10 +++++----- Python/generated_cases.c.h | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 110bf9451d9581..a55460afea751c 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -138,12 +138,12 @@ dummy_func( if (_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version) { int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp); ERROR_IF(err, error); - #if TIER_ONE + #if TIER_ONE next_instr--; - #endif - #if TIER_TWO - goto deoptimize; - #endif + #endif + #if TIER_TWO + goto deoptimize; + #endif } else if (oparg < 2) { CHECK_EVAL_BREAKER(); diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 45d2d39c3940b0..1283cc7ebbf9c4 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -13,12 +13,12 @@ if (_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version) { int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp); if (err) goto error; - #if TIER_ONE + #if TIER_ONE next_instr--; - #endif - #if TIER_TWO - goto deoptimize; - #endif + #endif + #if TIER_TWO + goto deoptimize; + #endif } else if (oparg < 2) { CHECK_EVAL_BREAKER(); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 06068b4dde17bd..3f46f1a10a247f 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -13,12 +13,12 @@ if (_PyFrame_GetCode(frame)->_co_instrumentation_version != tstate->interp->monitoring_version) { int err = _Py_Instrument(_PyFrame_GetCode(frame), tstate->interp); if (err) goto error; - #if TIER_ONE + #if TIER_ONE next_instr--; - #endif - #if TIER_TWO - goto deoptimize; - #endif + #endif + #if TIER_TWO + goto deoptimize; + #endif } else if (oparg < 2) { CHECK_EVAL_BREAKER();