]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-115419: Move setting the instruction pointer to error exit stubs (GH-118088)
authorMark Shannon <mark@hotpy.org>
Wed, 24 Apr 2024 13:41:30 +0000 (14:41 +0100)
committerGitHub <noreply@github.com>
Wed, 24 Apr 2024 13:41:30 +0000 (14:41 +0100)
Lib/test/test_capi/test_opt.py
Python/bytecodes.c
Python/executor_cases.c.h
Python/optimizer.c
Python/optimizer_analysis.c

index ae23eadb8aafa0711393fa5ac0b63ee36cb378c4..c004f4637700190da95a5c91f4fe45c48fabf02f 100644 (file)
@@ -231,7 +231,7 @@ class TestUops(unittest.TestCase):
         ex = get_first_executor(testfunc)
         self.assertIsNotNone(ex)
         uops = get_opnames(ex)
-        self.assertIn("_SET_IP", uops)
+        self.assertIn("_JUMP_TO_TOP", uops)
         self.assertIn("_LOAD_FAST_0", uops)
 
     def test_extended_arg(self):
index 1f908a991072931d0b50c24ab03e4996f67885e3..c31617d35b02f5c77a2f33fcc7412126fdfce4bc 100644 (file)
@@ -4226,7 +4226,8 @@ dummy_func(
             EXIT_TO_TRACE();
         }
 
-        tier2 op(_ERROR_POP_N, (unused[oparg] --)) {
+        tier2 op(_ERROR_POP_N, (target/2, unused[oparg] --)) {
+            frame->instr_ptr = ((_Py_CODEUNIT *)_PyFrame_GetCode(frame)->co_code_adaptive) + target;
             SYNC_SP();
             GOTO_UNWIND();
         }
index 43b022107a9ae6f97acc680743c3eb615cb0931a..7403d6fdaf0e2b220b401632800ad708418135b2 100644 (file)
 
         case _ERROR_POP_N: {
             oparg = CURRENT_OPARG();
+            uint32_t target = (uint32_t)CURRENT_OPERAND();
+            frame->instr_ptr = ((_Py_CODEUNIT *)_PyFrame_GetCode(frame)->co_code_adaptive) + target;
             stack_pointer += -oparg;
             GOTO_UNWIND();
             break;
index 6a8b4f3c9504ade0c63c15f645954b8c2622c9d6..b17c2998e2504bfa98b7db30eb1267c122573440 100644 (file)
@@ -978,6 +978,7 @@ prepare_for_execution(_PyUOpInstruction *buffer, int length)
                 current_error_target = target;
                 make_exit(&buffer[next_spare], _ERROR_POP_N, 0);
                 buffer[next_spare].oparg = popped;
+                buffer[next_spare].operand = target;
                 next_spare++;
             }
             buffer[i].error_target = current_error;
index 76de6e50f1f786c2556bac570dfecd8b7e14d006..a76edd62c94c13144718e7a7137582914c89af4e 100644 (file)
@@ -554,9 +554,6 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
                     needs_ip = true;
                     may_have_escaped = true;
                 }
-                if (_PyUop_Flags[opcode] & HAS_ERROR_FLAG) {
-                    needs_ip = true;
-                }
                 if (needs_ip && last_set_ip >= 0) {
                     if (buffer[last_set_ip].opcode == _CHECK_VALIDITY) {
                         buffer[last_set_ip].opcode = _CHECK_VALIDITY_AND_SET_IP;