Skip to content

Commit 375a56b

Browse files
authored
bpo-45885: Don't un-adapt COMPARE_OP when collecting stats (GH-31516)
1 parent 424023e commit 375a56b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Don't un-adapt :opcode:`COMPARE_OP` when collecting specialization stats.

Python/specialize.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -2013,9 +2013,15 @@ _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs,
20132013
int op = adaptive->original_oparg;
20142014
int next_opcode = _Py_OPCODE(instr[1]);
20152015
if (next_opcode != POP_JUMP_IF_FALSE && next_opcode != POP_JUMP_IF_TRUE) {
2016-
// Can't ever combine, so don't don't bother being adaptive.
2017-
SPECIALIZATION_FAIL(COMPARE_OP, SPEC_FAIL_COMPARE_OP_NOT_FOLLOWED_BY_COND_JUMP);
2016+
// Can't ever combine, so don't don't bother being adaptive (unless
2017+
// we're collecting stats, where it's more important to get accurate hit
2018+
// counts for the unadaptive version and each of the different failure
2019+
// types):
2020+
#ifndef Py_STATS
20182021
*instr = _Py_MAKECODEUNIT(COMPARE_OP, adaptive->original_oparg);
2022+
return;
2023+
#endif
2024+
SPECIALIZATION_FAIL(COMPARE_OP, SPEC_FAIL_COMPARE_OP_NOT_FOLLOWED_BY_COND_JUMP);
20192025
goto failure;
20202026
}
20212027
assert(op <= Py_GE);

0 commit comments

Comments
 (0)