https://github.com/python/cpython/commit/83235f7791fbe6ee2618192f2341de9cd22d0511
commit: 83235f7791fbe6ee2618192f2341de9cd22d0511
branch: main
author: Mark Shannon <[email protected]>
committer: markshannon <[email protected]>
date: 2024-04-24T14:41:30+01:00
summary:
GH-115419: Move setting the instruction pointer to error exit stubs (GH-118088)
files:
M Lib/test/test_capi/test_opt.py
M Python/bytecodes.c
M Python/executor_cases.c.h
M Python/optimizer.c
M Python/optimizer_analysis.c
diff --git a/Lib/test/test_capi/test_opt.py b/Lib/test/test_capi/test_opt.py
index ae23eadb8aafa0..c004f463770019 100644
--- a/Lib/test/test_capi/test_opt.py
+++ b/Lib/test/test_capi/test_opt.py
@@ -231,7 +231,7 @@ def testfunc(x):
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):
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 1f908a99107293..c31617d35b02f5 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -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();
}
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index 43b022107a9ae6..7403d6fdaf0e2b 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -4210,6 +4210,8 @@
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;
diff --git a/Python/optimizer.c b/Python/optimizer.c
index 6a8b4f3c9504ad..b17c2998e2504b 100644
--- a/Python/optimizer.c
+++ b/Python/optimizer.c
@@ -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;
diff --git a/Python/optimizer_analysis.c b/Python/optimizer_analysis.c
index 76de6e50f1f786..a76edd62c94c13 100644
--- a/Python/optimizer_analysis.c
+++ b/Python/optimizer_analysis.c
@@ -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;
_______________________________________________
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]