Skip to content

Commit 2d735c3

Browse files
Fix test
1 parent ca89c3c commit 2d735c3

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ def get_first_executor(func):
4343
def get_all_executors(func):
4444
code = func.__code__
4545
co_code = code.co_code
46-
execs = []
46+
executors = []
4747
for i in range(0, len(co_code), 2):
4848
try:
49-
execs.append(_opcode.get_executor(code, i))
49+
executors.append(_opcode.get_executor(code, i))
5050
except ValueError:
5151
pass
52-
return execs
52+
return executors
5353

5454

5555
def iter_opnames(ex):
@@ -2647,10 +2647,23 @@ def f():
26472647
z = x + y
26482648

26492649
f()
2650+
all_executors = get_all_executors(f)
26502651
# Inner loop warms up first.
26512652
# Outer loop warms up later, linking to the inner one.
2652-
# Therefore, at least two executors.
2653-
self.assertGreaterEqual(len(get_all_executors(f)), 2)
2653+
# Therefore, we have at least two executors.
2654+
self.assertGreaterEqual(len(all_executors), 2)
2655+
for executor in all_executors:
2656+
opnames = list(get_opnames(executor))
2657+
# Assert all executors first terminator ends in
2658+
# _JUMP_TO_TOP or _EXIT_TRACE, not _DEOPT
2659+
for idx, op in enumerate(opnames):
2660+
if op == "_EXIT_TRACE" or op == "_JUMP_TO_TOP":
2661+
break
2662+
elif op == "_DEOPT":
2663+
self.fail(f"_DEOPT encountered first at executor"
2664+
f" {executor} at offset {idx} rather"
2665+
f" than expected _EXIT_TRACE")
2666+
26542667

26552668

26562669
def global_identity(x):

Python/optimizer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ _PyJit_translate_single_bytecode_to_trace(
574574
PyThreadState *tstate,
575575
_PyInterpreterFrame *frame,
576576
_Py_CODEUNIT *next_instr,
577-
int stop_tracing_opocde)
577+
int stop_tracing_opcode)
578578
{
579579

580580
#ifdef Py_DEBUG
@@ -637,8 +637,8 @@ _PyJit_translate_single_bytecode_to_trace(
637637
goto full;
638638
}
639639

640-
if (stop_tracing_opocde != 0) {
641-
ADD_TO_TRACE(stop_tracing_opocde, 0, 0, target);
640+
if (stop_tracing_opcode != 0) {
641+
ADD_TO_TRACE(stop_tracing_opcode, 0, 0, target);
642642
goto done;
643643
}
644644

0 commit comments

Comments
 (0)