summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_capi/test_misc.py4
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2023-08-28-22-22-15.gh-issue-108488.e8-fxg.rst1
-rw-r--r--Python/specialize.c4
3 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py
index 1cd4c56..4148f15 100644
--- a/Lib/test/test_capi/test_misc.py
+++ b/Lib/test/test_capi/test_misc.py
@@ -2478,7 +2478,7 @@ class TestUops(unittest.TestCase):
opt = _testinternalcapi.get_uop_optimizer()
with temporary_optimizer(opt):
- testfunc([1, 2, 3])
+ testfunc(range(10))
ex = get_first_executor(testfunc)
self.assertIsNotNone(ex)
@@ -2493,7 +2493,7 @@ class TestUops(unittest.TestCase):
opt = _testinternalcapi.get_uop_optimizer()
with temporary_optimizer(opt):
- testfunc([1, 2, 3])
+ testfunc(range(10))
ex = get_first_executor(testfunc)
self.assertIsNotNone(ex)
diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-08-28-22-22-15.gh-issue-108488.e8-fxg.rst b/Misc/NEWS.d/next/Core and Builtins/2023-08-28-22-22-15.gh-issue-108488.e8-fxg.rst
new file mode 100644
index 0000000..f9d6f59
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2023-08-28-22-22-15.gh-issue-108488.e8-fxg.rst
@@ -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.
diff --git a/Python/specialize.c b/Python/specialize.c
index a467f16..a794f14 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -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;
}
}