Skip to content

Commit 2cf4f58

Browse files
Add a test
1 parent a9eac0f commit 2cf4f58

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ def get_first_executor(func):
4040
pass
4141
return None
4242

43+
def get_all_executors(func):
44+
code = func.__code__
45+
co_code = code.co_code
46+
execs = []
47+
for i in range(0, len(co_code), 2):
48+
try:
49+
execs.append(_opcode.get_executor(code, i))
50+
except ValueError:
51+
pass
52+
return execs
53+
4354

4455
def iter_opnames(ex):
4556
for item in ex:
@@ -2629,6 +2640,18 @@ def gen():
26292640
next(g)
26302641
""" % _testinternalcapi.SPECIALIZATION_THRESHOLD))
26312642

2643+
def test_executor_side_exits_create_another_executor(self):
2644+
def f():
2645+
for x in range(TIER2_THRESHOLD + 3):
2646+
for y in range(TIER2_THRESHOLD + 3):
2647+
z = x + y
2648+
2649+
f()
2650+
# Inner loop warms up first.
2651+
# Outer loop warms up later, linking to the innter one.
2652+
# Therefore, at least two executors.
2653+
self.assertGreaterEqual(len(get_all_executors(f)), 2)
2654+
26322655

26332656
def global_identity(x):
26342657
return x

0 commit comments

Comments
 (0)