Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-108488: Initialize JUMP_BACKWARD cache to 0, not 17 #108591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/test/test_capi/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2478,7 +2478,7 @@ def testfunc(a):

opt = _testinternalcapi.get_uop_optimizer()
with temporary_optimizer(opt):
testfunc([1, 2, 3])
testfunc(range(10))

ex = get_first_executor(testfunc)
self.assertIsNotNone(ex)
Expand All @@ -2493,7 +2493,7 @@ def testfunc(a):

opt = _testinternalcapi.get_uop_optimizer()
with temporary_optimizer(opt):
testfunc([1, 2, 3])
testfunc(range(10))

ex = get_first_executor(testfunc)
self.assertIsNotNone(ex)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change the initialization of inline cache entries so that the cache entry for ``JUMP_BACKWARD`` is initialized to zero, instead of the ``adaptive_counter_warmup()`` value used for all other instructions. This counter, unique among instructions, counts up from zero.
4 changes: 3 additions & 1 deletion Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ _PyCode_Quicken(PyCodeObject *code)
assert(opcode < MIN_INSTRUMENTED_OPCODE);
int caches = _PyOpcode_Caches[opcode];
if (caches) {
instructions[i + 1].cache = adaptive_counter_warmup();
// JUMP_BACKWARD counter counts up from 0 until it is > backedge_threshold
instructions[i + 1].cache =
opcode == JUMP_BACKWARD ? 0 : adaptive_counter_warmup();
i += caches;
}
}
Expand Down