diff options
author | Guido van Rossum <guido@python.org> | 2023-08-29 18:14:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-29 18:14:56 (GMT) |
commit | 59e46932c8d2dc6fe84a8cf144dde962838c0204 (patch) | |
tree | f9d87d4f1f811d10dacb2011830a708a73a06273 /Python/specialize.c | |
parent | 4f22152713d008cdd7c1d373a0f0c8dcf30e217e (diff) | |
download | cpython-59e46932c8d2dc6fe84a8cf144dde962838c0204.zip cpython-59e46932c8d2dc6fe84a8cf144dde962838c0204.tar.gz cpython-59e46932c8d2dc6fe84a8cf144dde962838c0204.tar.bz2 |
gh-108488: Initialize JUMP_BACKWARD cache to 0, not 17 (#108591)
This mis-initialization caused the executor optimization to kick in sooner than intended. It also set the lower 4 bits of the counter to `1` -- those bits are supposed to be reserved (the actual counter is in the upper 12 bits).
Diffstat (limited to 'Python/specialize.c')
-rw-r--r-- | Python/specialize.c | 4 |
1 files changed, 3 insertions, 1 deletions
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; } } |