summaryrefslogtreecommitdiffstats
path: root/Python/peephole.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2020-01-14 10:12:45 (GMT)
committerGitHub <noreply@github.com>2020-01-14 10:12:45 (GMT)
commit9af0e47b1705457bb6b327c197f2ec5737a1d8f6 (patch)
tree97378eee78d793d16bd19038d88371d776e720c3 /Python/peephole.c
parent62e3973395fb9fab2eb8f651bcd0fea4e695e1cf (diff)
downloadcpython-9af0e47b1705457bb6b327c197f2ec5737a1d8f6.zip
cpython-9af0e47b1705457bb6b327c197f2ec5737a1d8f6.tar.gz
cpython-9af0e47b1705457bb6b327c197f2ec5737a1d8f6.tar.bz2
bpo-39156: Break up COMPARE_OP into four logically distinct opcodes. (GH-17754)
Break up COMPARE_OP into four logically distinct opcodes: * COMPARE_OP for rich comparisons * IS_OP for 'is' and 'is not' tests * CONTAINS_OP for 'in' and 'is not' tests * JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except' statements.
Diffstat (limited to 'Python/peephole.c')
-rw-r--r--Python/peephole.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/peephole.c b/Python/peephole.c
index 714a452..baa217a 100644
--- a/Python/peephole.c
+++ b/Python/peephole.c
@@ -12,10 +12,10 @@
#define UNCONDITIONAL_JUMP(op) (op==JUMP_ABSOLUTE || op==JUMP_FORWARD)
#define CONDITIONAL_JUMP(op) (op==POP_JUMP_IF_FALSE || op==POP_JUMP_IF_TRUE \
- || op==JUMP_IF_FALSE_OR_POP || op==JUMP_IF_TRUE_OR_POP)
+ || op==JUMP_IF_FALSE_OR_POP || op==JUMP_IF_TRUE_OR_POP || op==JUMP_IF_NOT_EXC_MATCH)
#define ABSOLUTE_JUMP(op) (op==JUMP_ABSOLUTE \
|| op==POP_JUMP_IF_FALSE || op==POP_JUMP_IF_TRUE \
- || op==JUMP_IF_FALSE_OR_POP || op==JUMP_IF_TRUE_OR_POP)
+ || op==JUMP_IF_FALSE_OR_POP || op==JUMP_IF_TRUE_OR_POP || op==JUMP_IF_NOT_EXC_MATCH)
#define JUMPS_ON_TRUE(op) (op==POP_JUMP_IF_TRUE || op==JUMP_IF_TRUE_OR_POP)
#define GETJUMPTGT(arr, i) (get_arg(arr, i) / sizeof(_Py_CODEUNIT) + \
(ABSOLUTE_JUMP(_Py_OPCODE(arr[i])) ? 0 : i+1))
@@ -194,6 +194,7 @@ markblocks(_Py_CODEUNIT *code, Py_ssize_t len)
case JUMP_IF_TRUE_OR_POP:
case POP_JUMP_IF_FALSE:
case POP_JUMP_IF_TRUE:
+ case JUMP_IF_NOT_EXC_MATCH:
case JUMP_ABSOLUTE:
case SETUP_FINALLY:
case SETUP_WITH:
@@ -493,6 +494,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
case POP_JUMP_IF_TRUE:
case JUMP_IF_FALSE_OR_POP:
case JUMP_IF_TRUE_OR_POP:
+ case JUMP_IF_NOT_EXC_MATCH:
j = blocks[j / sizeof(_Py_CODEUNIT)] * sizeof(_Py_CODEUNIT);
break;