summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2022-04-01 12:59:38 (GMT)
committerGitHub <noreply@github.com>2022-04-01 12:59:38 (GMT)
commit04e07c258f4f2ac85e25355242a113f98a706f04 (patch)
tree166df77e0d1e0bbaf6c4fcd8b1f3584010cf6c26 /Python
parentae9de82e321581e1906c6ef2a7ad83ab30ae3325 (diff)
downloadcpython-04e07c258f4f2ac85e25355242a113f98a706f04.zip
cpython-04e07c258f4f2ac85e25355242a113f98a706f04.tar.gz
cpython-04e07c258f4f2ac85e25355242a113f98a706f04.tar.bz2
bpo-47186: Replace JUMP_IF_NOT_EXC_MATCH by CHECK_EXC_MATCH + jump (GH-32231)
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c6
-rw-r--r--Python/compile.c10
-rw-r--r--Python/opcode_targets.h14
3 files changed, 15 insertions, 15 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 8c1f21b..43080f8 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -3853,7 +3853,7 @@ handle_eval_breaker:
DISPATCH();
}
- TARGET(JUMP_IF_NOT_EXC_MATCH) {
+ TARGET(CHECK_EXC_MATCH) {
PyObject *right = POP();
PyObject *left = TOP();
assert(PyExceptionInstance_Check(left));
@@ -3864,9 +3864,7 @@ handle_eval_breaker:
int res = PyErr_GivenExceptionMatches(left, right);
Py_DECREF(right);
- if (res == 0) {
- JUMPTO(oparg);
- }
+ PUSH(Py_NewRef(res ? Py_True : Py_False));
DISPATCH();
}
diff --git a/Python/compile.c b/Python/compile.c
index 7a07377..bdf886b 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -977,8 +977,8 @@ stack_effect(int opcode, int oparg, int jump)
case IS_OP:
case CONTAINS_OP:
return -1;
- case JUMP_IF_NOT_EXC_MATCH:
- return -1;
+ case CHECK_EXC_MATCH:
+ return 0;
case JUMP_IF_NOT_EG_MATCH:
return jump > 0 ? -1 : 0;
case IMPORT_NAME:
@@ -3352,7 +3352,8 @@ compiler_try_star_finally(struct compiler *c, stmt_ty s)
[] JUMP L0
[exc] L1: <evaluate E1> )
- [exc, E1] JUMP_IF_NOT_EXC_MATCH L2 ) only if E1
+ [exc, E1] CHECK_EXC_MATCH )
+ [exc, bool] POP_JUMP_IF_FALSE L2 ) only if E1
[exc] <assign to V1> (or POP if no V1)
[] <code for S1>
JUMP L0
@@ -3410,7 +3411,8 @@ compiler_try_except(struct compiler *c, stmt_ty s)
return 0;
if (handler->v.ExceptHandler.type) {
VISIT(c, expr, handler->v.ExceptHandler.type);
- ADDOP_JUMP(c, JUMP_IF_NOT_EXC_MATCH, except);
+ ADDOP(c, CHECK_EXC_MATCH);
+ ADDOP_JUMP(c, POP_JUMP_IF_FALSE, except);
}
if (handler->v.ExceptHandler.name) {
basicblock *cleanup_end, *cleanup_body;
diff --git a/Python/opcode_targets.h b/Python/opcode_targets.h
index 3afaf0b..2eba553 100644
--- a/Python/opcode_targets.h
+++ b/Python/opcode_targets.h
@@ -35,6 +35,7 @@ static void *opcode_targets[256] = {
&&TARGET_MATCH_KEYS,
&&TARGET_JUMP_BACKWARD_QUICK,
&&TARGET_PUSH_EXC_INFO,
+ &&TARGET_CHECK_EXC_MATCH,
&&TARGET_LOAD_ATTR_ADAPTIVE,
&&TARGET_LOAD_ATTR_INSTANCE_VALUE,
&&TARGET_LOAD_ATTR_MODULE,
@@ -47,40 +48,39 @@ static void *opcode_targets[256] = {
&&TARGET_LOAD_GLOBAL_BUILTIN,
&&TARGET_LOAD_GLOBAL_MODULE,
&&TARGET_LOAD_METHOD_ADAPTIVE,
- &&TARGET_LOAD_METHOD_CLASS,
&&TARGET_WITH_EXCEPT_START,
&&TARGET_GET_AITER,
&&TARGET_GET_ANEXT,
&&TARGET_BEFORE_ASYNC_WITH,
&&TARGET_BEFORE_WITH,
&&TARGET_END_ASYNC_FOR,
+ &&TARGET_LOAD_METHOD_CLASS,
&&TARGET_LOAD_METHOD_MODULE,
&&TARGET_LOAD_METHOD_NO_DICT,
&&TARGET_LOAD_METHOD_WITH_DICT,
&&TARGET_LOAD_METHOD_WITH_VALUES,
- &&TARGET_PRECALL_ADAPTIVE,
&&TARGET_STORE_SUBSCR,
&&TARGET_DELETE_SUBSCR,
+ &&TARGET_PRECALL_ADAPTIVE,
&&TARGET_PRECALL_BOUND_METHOD,
&&TARGET_PRECALL_BUILTIN_CLASS,
&&TARGET_PRECALL_BUILTIN_FAST_WITH_KEYWORDS,
&&TARGET_PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS,
&&TARGET_PRECALL_NO_KW_BUILTIN_FAST,
- &&TARGET_PRECALL_NO_KW_BUILTIN_O,
&&TARGET_GET_ITER,
&&TARGET_GET_YIELD_FROM_ITER,
&&TARGET_PRINT_EXPR,
&&TARGET_LOAD_BUILD_CLASS,
+ &&TARGET_PRECALL_NO_KW_BUILTIN_O,
&&TARGET_PRECALL_NO_KW_ISINSTANCE,
- &&TARGET_PRECALL_NO_KW_LEN,
&&TARGET_LOAD_ASSERTION_ERROR,
&&TARGET_RETURN_GENERATOR,
+ &&TARGET_PRECALL_NO_KW_LEN,
&&TARGET_PRECALL_NO_KW_LIST_APPEND,
&&TARGET_PRECALL_NO_KW_METHOD_DESCRIPTOR_FAST,
&&TARGET_PRECALL_NO_KW_METHOD_DESCRIPTOR_NOARGS,
&&TARGET_PRECALL_NO_KW_METHOD_DESCRIPTOR_O,
&&TARGET_PRECALL_NO_KW_STR_1,
- &&TARGET_PRECALL_NO_KW_TUPLE_1,
&&TARGET_LIST_TO_TUPLE,
&&TARGET_RETURN_VALUE,
&&TARGET_IMPORT_STAR,
@@ -112,7 +112,7 @@ static void *opcode_targets[256] = {
&&TARGET_JUMP_FORWARD,
&&TARGET_JUMP_IF_FALSE_OR_POP,
&&TARGET_JUMP_IF_TRUE_OR_POP,
- &&TARGET_PRECALL_NO_KW_TYPE_1,
+ &&TARGET_PRECALL_NO_KW_TUPLE_1,
&&TARGET_POP_JUMP_IF_FALSE,
&&TARGET_POP_JUMP_IF_TRUE,
&&TARGET_LOAD_GLOBAL,
@@ -120,7 +120,7 @@ static void *opcode_targets[256] = {
&&TARGET_CONTAINS_OP,
&&TARGET_RERAISE,
&&TARGET_COPY,
- &&TARGET_JUMP_IF_NOT_EXC_MATCH,
+ &&TARGET_PRECALL_NO_KW_TYPE_1,
&&TARGET_BINARY_OP,
&&TARGET_SEND,
&&TARGET_LOAD_FAST,