diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2022-02-23 11:06:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-23 11:06:25 (GMT) |
commit | 375a56bd4015596c0cf44129c8842a1fe7199785 (patch) | |
tree | 4ba156b1f40ad1a87232d9a99644a804dd5ae631 | |
parent | 424023efee5b21567b4725015ef143b627112e3c (diff) | |
download | cpython-375a56bd4015596c0cf44129c8842a1fe7199785.zip cpython-375a56bd4015596c0cf44129c8842a1fe7199785.tar.gz cpython-375a56bd4015596c0cf44129c8842a1fe7199785.tar.bz2 |
bpo-45885: Don't un-adapt `COMPARE_OP` when collecting stats (GH-31516)
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2022-02-22-15-48-32.bpo-45885.W2vkaI.rst | 1 | ||||
-rw-r--r-- | Python/specialize.c | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-02-22-15-48-32.bpo-45885.W2vkaI.rst b/Misc/NEWS.d/next/Core and Builtins/2022-02-22-15-48-32.bpo-45885.W2vkaI.rst new file mode 100644 index 0000000..4339f50 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-02-22-15-48-32.bpo-45885.W2vkaI.rst @@ -0,0 +1 @@ +Don't un-adapt :opcode:`COMPARE_OP` when collecting specialization stats. diff --git a/Python/specialize.c b/Python/specialize.c index 91010a5..0fc992d 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -2013,9 +2013,15 @@ _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, int op = adaptive->original_oparg; int next_opcode = _Py_OPCODE(instr[1]); if (next_opcode != POP_JUMP_IF_FALSE && next_opcode != POP_JUMP_IF_TRUE) { - // Can't ever combine, so don't don't bother being adaptive. - SPECIALIZATION_FAIL(COMPARE_OP, SPEC_FAIL_COMPARE_OP_NOT_FOLLOWED_BY_COND_JUMP); + // Can't ever combine, so don't don't bother being adaptive (unless + // we're collecting stats, where it's more important to get accurate hit + // counts for the unadaptive version and each of the different failure + // types): +#ifndef Py_STATS *instr = _Py_MAKECODEUNIT(COMPARE_OP, adaptive->original_oparg); + return; +#endif + SPECIALIZATION_FAIL(COMPARE_OP, SPEC_FAIL_COMPARE_OP_NOT_FOLLOWED_BY_COND_JUMP); goto failure; } assert(op <= Py_GE); |