Skip to content

Commit 5102ab6

Browse files
fix a few tests and their exposed bugs
1 parent 9910b65 commit 5102ab6

File tree

9 files changed

+165
-170
lines changed

9 files changed

+165
-170
lines changed

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_ids.h

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

Lib/test/test_capi/test_opt.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
from _testinternalcapi import TIER2_THRESHOLD
1919

20-
# We need one more iteration as one iteration is spent on tracing.
21-
TIER2_THRESHOLD = TIER2_THRESHOLD + 1
2220
#For test of issue 136154
2321
GLOBAL_136154 = 42
2422

@@ -628,7 +626,7 @@ def testfunc(n):
628626
x = range(i)
629627
return x
630628
631-
testfunc(_testinternalcapi.TIER2_THRESHOLD + 1)
629+
testfunc(_testinternalcapi.TIER2_THRESHOLD)
632630
633631
ex = get_first_executor(testfunc)
634632
assert ex is not None
@@ -2463,7 +2461,7 @@ def testfunc(n):
24632461
del email.jit_testing
24642462
24652463
2466-
testfunc(_testinternalcapi.TIER2_THRESHOLD + 1)
2464+
testfunc(_testinternalcapi.TIER2_THRESHOLD)
24672465
ex = get_first_executor(testfunc)
24682466
assert ex is not None
24692467
"""))

Lib/test/test_sys.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,9 +2252,10 @@ def frame_2_jit(expected: bool) -> None:
22522252
22532253
def frame_3_jit() -> None:
22542254
# JITs just before the last loop:
2255-
for i in range(_testinternalcapi.TIER2_THRESHOLD + 1):
2255+
# 1 extra iteration for tracing.
2256+
for i in range(_testinternalcapi.TIER2_THRESHOLD + 2):
22562257
# Careful, doing this in the reverse order breaks tracing:
2257-
expected = {enabled} and i == _testinternalcapi.TIER2_THRESHOLD
2258+
expected = {enabled} and i >= _testinternalcapi.TIER2_THRESHOLD + 1
22582259
assert sys._jit.is_active() is expected
22592260
frame_2_jit(expected)
22602261
assert sys._jit.is_active() is expected

Modules/_testinternalcapi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,8 @@ module_exec(PyObject *module)
25432543
}
25442544

25452545
if (PyModule_Add(module, "TIER2_THRESHOLD",
2546-
PyLong_FromLong(JUMP_BACKWARD_INITIAL_VALUE + 1)) < 0) {
2546+
// + 1 more due to one loop spent on tracing.
2547+
PyLong_FromLong(JUMP_BACKWARD_INITIAL_VALUE + 2)) < 0) {
25472548
return 1;
25482549
}
25492550

0 commit comments

Comments
 (0)