summaryrefslogtreecommitdiffstats
path: root/Python/generated_cases.c.h
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-01-24 09:43:16 (GMT)
committerGitHub <noreply@github.com>2023-01-24 09:43:16 (GMT)
commit8c183cddd3d0031c6d397738f73c20ee6bf61ce8 (patch)
tree6e0f0242f2ca63a3b97b44a9b612ede620e8c104 /Python/generated_cases.c.h
parent7589d713a14a1efbb0cbb7caa9fdbad2b081cf18 (diff)
downloadcpython-8c183cddd3d0031c6d397738f73c20ee6bf61ce8.zip
cpython-8c183cddd3d0031c6d397738f73c20ee6bf61ce8.tar.gz
cpython-8c183cddd3d0031c6d397738f73c20ee6bf61ce8.tar.bz2
gh-98831: rewrite CHECK_EG_MATCH opcode in the instruction definition DSL (#101269)
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r--Python/generated_cases.c.h43
1 files changed, 16 insertions, 27 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index 46d421f..c1eb400 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -2251,43 +2251,32 @@
}
TARGET(CHECK_EG_MATCH) {
- PyObject *match_type = POP();
+ PyObject *match_type = PEEK(1);
+ PyObject *exc_value = PEEK(2);
+ PyObject *rest;
+ PyObject *match;
if (check_except_star_type_valid(tstate, match_type) < 0) {
+ Py_DECREF(exc_value);
Py_DECREF(match_type);
- goto error;
+ if (true) goto pop_2_error;
}
- PyObject *exc_value = TOP();
- PyObject *match = NULL, *rest = NULL;
+ match = NULL;
+ rest = NULL;
int res = exception_group_match(exc_value, match_type,
&match, &rest);
+ Py_DECREF(exc_value);
Py_DECREF(match_type);
- if (res < 0) {
- goto error;
- }
+ if (res < 0) goto pop_2_error;
- if (match == NULL || rest == NULL) {
- assert(match == NULL);
- assert(rest == NULL);
- goto error;
- }
- if (Py_IsNone(match)) {
- PUSH(match);
- Py_XDECREF(rest);
- }
- else {
- /* Total or partial match - update the stack from
- * [val]
- * to
- * [rest, match]
- * (rest can be Py_None)
- */
-
- SET_TOP(rest);
- PUSH(match);
+ assert((match == NULL) == (rest == NULL));
+ if (match == NULL) goto pop_2_error;
+
+ if (!Py_IsNone(match)) {
PyErr_SetExcInfo(NULL, Py_NewRef(match), NULL);
- Py_DECREF(exc_value);
}
+ POKE(1, match);
+ POKE(2, rest);
DISPATCH();
}