diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2022-09-01 21:36:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-01 21:36:47 +0100 |
commit | 4c72517cada147b215cf30ff8dac70ea0f08f1e0 (patch) | |
tree | 1012522409ed719a8d8ba0b5eab4e5f3bce77bd6 /Python/specialize.c | |
parent | a91f25577c71ab8797a4b42f22c43bbaffc2604d (diff) | |
download | cpython-4c72517cada147b215cf30ff8dac70ea0f08f1e0.tar.gz cpython-4c72517cada147b215cf30ff8dac70ea0f08f1e0.zip |
gh-93554: Conditional jump opcodes only jump forward (GH-96318)
Diffstat (limited to 'Python/specialize.c')
-rw-r--r-- | Python/specialize.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/Python/specialize.c b/Python/specialize.c index 8a2f9054cad..e8c3f468fea 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -1999,10 +1999,8 @@ _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_FORWARD_IF_FALSE && - next_opcode != POP_JUMP_BACKWARD_IF_FALSE && - next_opcode != POP_JUMP_FORWARD_IF_TRUE && - next_opcode != POP_JUMP_BACKWARD_IF_TRUE) { + 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 (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 @@ -2021,14 +2019,9 @@ _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_FORWARD_IF_FALSE || - next_opcode == POP_JUMP_BACKWARD_IF_FALSE) { + if (next_opcode == POP_JUMP_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; @@ -2056,7 +2049,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; + cache->mask = (when_to_jump_mask & 2) == 0; goto success; } } |