]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-106581: Fix instrumentation in tier 2 (GH-108493)
authorBrandt Bucher <brandtbucher@microsoft.com>
Fri, 25 Aug 2023 19:12:59 +0000 (12:12 -0700)
committerGitHub <noreply@github.com>
Fri, 25 Aug 2023 19:12:59 +0000 (19:12 +0000)
Misc/NEWS.d/next/Core and Builtins/2023-08-10-00-00-48.gh-issue-106581.o7zDty.rst [new file with mode: 0644]
Python/bytecodes.c
Python/executor_cases.c.h
Python/generated_cases.c.h

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 (file)
index 0000000..dff1ebd
--- /dev/null
@@ -0,0 +1,2 @@
+Fix possible assertion failures and missing instrumentation events when
+:envvar:`PYTHONUOPS` or :option:`-X uops <-X>` is enabled.
index a5cb117c7631c60064882980c0b85c1c40ab3cbd..a55460afea751ccca7909db80c5a17fb92ef2ab9 100644 (file)
@@ -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--;
+                #endif
+                #if TIER_TWO
+                goto deoptimize;
+                #endif
             }
-            else
-            #endif
-            if (oparg < 2) {
+            else if (oparg < 2) {
                 CHECK_EVAL_BREAKER();
             }
         }
index 85c60c276e0292f9a09850ab6af3fc35be007d56..1283cc7ebbf9c432f09eadb3eed996d8073e0178 100644 (file)
@@ -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--;
+                #endif
+                #if TIER_TWO
+                goto deoptimize;
+                #endif
             }
-            else
-            #endif
-            if (oparg < 2) {
+            else if (oparg < 2) {
                 CHECK_EVAL_BREAKER();
             }
             break;
index 4aa16f8311a2a02666727befb5e30c1ece4413a7..3f46f1a10a247f6a4124f6c08da8bb6cc803935a 100644 (file)
@@ -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--;
+                #endif
+                #if TIER_TWO
+                goto deoptimize;
+                #endif
             }
-            else
-            #endif
-            if (oparg < 2) {
+            else if (oparg < 2) {
                 CHECK_EVAL_BREAKER();
             }
             DISPATCH();