From 21cd7bb53184bf8acface28bdf56f511a8c1552e Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 28 Aug 2023 10:55:01 -0700 Subject: [PATCH 1/3] Initialize JUMP_BACKWARD cache to 0, not 17 --- Python/specialize.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/specialize.c b/Python/specialize.c index a467f163f2ca9d..a794f146c188ec 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; } } From d26a270a0518d62d6edc974b8fb5a5c7f78ad35a Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 28 Aug 2023 22:22:21 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2023-08-28-22-22-15.gh-issue-108488.e8-fxg.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2023-08-28-22-22-15.gh-issue-108488.e8-fxg.rst 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 00000000000000..f9d6f593b8eb9b --- /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. From 36701c307b35085c746ba3ce8805744174fb6060 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 29 Aug 2023 10:40:59 -0700 Subject: [PATCH 3/3] Fix test_pop_jump_if[_not]none by using more iterations --- Lib/test/test_capi/test_misc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py index 1cd4c56b49bba5..4148f15b2aa662 100644 --- a/Lib/test/test_capi/test_misc.py +++ b/Lib/test/test_capi/test_misc.py @@ -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) @@ -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)