summaryrefslogtreecommitdiffstats
path: root/Python/specialize.c
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2022-04-11 09:40:24 (GMT)
committerGitHub <noreply@github.com>2022-04-11 09:40:24 (GMT)
commitdd207a6ac52d4bd9a71cf178fc1d5c17a6f07aff (patch)
treec196769c21e856595b8c90adc5205b2372234f02 /Python/specialize.c
parent98ff4a68773c49619d486c7e758ebbe1662f8387 (diff)
downloadcpython-dd207a6ac52d4bd9a71cf178fc1d5c17a6f07aff.zip
cpython-dd207a6ac52d4bd9a71cf178fc1d5c17a6f07aff.tar.gz
cpython-dd207a6ac52d4bd9a71cf178fc1d5c17a6f07aff.tar.bz2
bpo-47120: make POP_JUMP_IF_TRUE/FALSE/NONE/NOT_NONE relative (GH-32400)
Diffstat (limited to 'Python/specialize.c')
-rw-r--r--Python/specialize.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Python/specialize.c b/Python/specialize.c
index 36b0502..3a8b768 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -1883,7 +1883,10 @@ _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
assert(_PyOpcode_Caches[COMPARE_OP] == INLINE_CACHE_ENTRIES_COMPARE_OP);
_PyCompareOpCache *cache = (_PyCompareOpCache *)(instr + 1);
int next_opcode = _Py_OPCODE(instr[INLINE_CACHE_ENTRIES_COMPARE_OP + 1]);
- if (next_opcode != POP_JUMP_IF_FALSE && next_opcode != POP_JUMP_IF_TRUE) {
+ if (next_opcode != POP_JUMP_FORWARD_IF_FALSE &&
+ next_opcode != POP_JUMP_BACKWARD_IF_FALSE &&
+ next_opcode != POP_JUMP_FORWARD_IF_TRUE &&
+ next_opcode != POP_JUMP_BACKWARD_IF_TRUE) {
// 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
@@ -1901,9 +1904,14 @@ _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
}
assert(oparg <= Py_GE);
int when_to_jump_mask = compare_masks[oparg];
- if (next_opcode == POP_JUMP_IF_FALSE) {
+ if (next_opcode == POP_JUMP_FORWARD_IF_FALSE ||
+ next_opcode == POP_JUMP_BACKWARD_IF_FALSE) {
when_to_jump_mask = (1 | 2 | 4) & ~when_to_jump_mask;
}
+ if (next_opcode == POP_JUMP_BACKWARD_IF_TRUE ||
+ next_opcode == POP_JUMP_BACKWARD_IF_FALSE) {
+ when_to_jump_mask <<= 3;
+ }
if (Py_TYPE(lhs) != Py_TYPE(rhs)) {
SPECIALIZATION_FAIL(COMPARE_OP, compare_op_fail_kind(lhs, rhs));
goto failure;
@@ -1931,7 +1939,7 @@ _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
}
else {
_Py_SET_OPCODE(*instr, COMPARE_OP_STR_JUMP);
- cache->mask = (when_to_jump_mask & 2) == 0;
+ cache->mask = when_to_jump_mask;
goto success;
}
}