Skip to content

Commit 83235f7

Browse files
authored
GH-115419: Move setting the instruction pointer to error exit stubs (GH-118088)
1 parent 77cd042 commit 83235f7

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def testfunc(x):
231231
ex = get_first_executor(testfunc)
232232
self.assertIsNotNone(ex)
233233
uops = get_opnames(ex)
234-
self.assertIn("_SET_IP", uops)
234+
self.assertIn("_JUMP_TO_TOP", uops)
235235
self.assertIn("_LOAD_FAST_0", uops)
236236

237237
def test_extended_arg(self):

Python/bytecodes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4226,7 +4226,8 @@ dummy_func(
42264226
EXIT_TO_TRACE();
42274227
}
42284228

4229-
tier2 op(_ERROR_POP_N, (unused[oparg] --)) {
4229+
tier2 op(_ERROR_POP_N, (target/2, unused[oparg] --)) {
4230+
frame->instr_ptr = ((_Py_CODEUNIT *)_PyFrame_GetCode(frame)->co_code_adaptive) + target;
42304231
SYNC_SP();
42314232
GOTO_UNWIND();
42324233
}

Python/executor_cases.c.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,7 @@ prepare_for_execution(_PyUOpInstruction *buffer, int length)
978978
current_error_target = target;
979979
make_exit(&buffer[next_spare], _ERROR_POP_N, 0);
980980
buffer[next_spare].oparg = popped;
981+
buffer[next_spare].operand = target;
981982
next_spare++;
982983
}
983984
buffer[i].error_target = current_error;

Python/optimizer_analysis.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,6 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
554554
needs_ip = true;
555555
may_have_escaped = true;
556556
}
557-
if (_PyUop_Flags[opcode] & HAS_ERROR_FLAG) {
558-
needs_ip = true;
559-
}
560557
if (needs_ip && last_set_ip >= 0) {
561558
if (buffer[last_set_ip].opcode == _CHECK_VALIDITY) {
562559
buffer[last_set_ip].opcode = _CHECK_VALIDITY_AND_SET_IP;

0 commit comments

Comments
 (0)