summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2022-06-10 16:53:34 (GMT)
committerGitHub <noreply@github.com>2022-06-10 16:53:34 (GMT)
commitcf730b595eea0460a7305205f7dfb6ecf0346351 (patch)
tree9a82669efe06e9d7d988ed0a1861e3a71000e345 /Python
parent2ba0fd5767577954f331ecbd53596cd8035d7186 (diff)
downloadcpython-cf730b595eea0460a7305205f7dfb6ecf0346351.zip
cpython-cf730b595eea0460a7305205f7dfb6ecf0346351.tar.gz
cpython-cf730b595eea0460a7305205f7dfb6ecf0346351.tar.bz2
GH-93621: reorder code in with/async-with exception exit path to reduce the size of the exception table (GH-93622)
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/Python/compile.c b/Python/compile.c
index bbd7193..b922e01 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -5551,20 +5551,26 @@ compiler_visit_keyword(struct compiler *c, keyword_ty k)
static int
compiler_with_except_finish(struct compiler *c, basicblock * cleanup) {
UNSET_LOC(c);
- basicblock *exit;
- exit = compiler_new_block(c);
- if (exit == NULL)
+ basicblock *suppress = compiler_new_block(c);
+ if (suppress == NULL) {
return 0;
- ADDOP_JUMP(c, POP_JUMP_IF_TRUE, exit);
+ }
+ ADDOP_JUMP(c, POP_JUMP_IF_TRUE, suppress);
ADDOP_I(c, RERAISE, 2);
- compiler_use_next_block(c, cleanup);
- POP_EXCEPT_AND_RERAISE(c);
- compiler_use_next_block(c, exit);
+ compiler_use_next_block(c, suppress);
ADDOP(c, POP_TOP); /* exc_value */
ADDOP(c, POP_BLOCK);
ADDOP(c, POP_EXCEPT);
ADDOP(c, POP_TOP);
ADDOP(c, POP_TOP);
+ basicblock *exit = compiler_new_block(c);
+ if (exit == NULL) {
+ return 0;
+ }
+ ADDOP_JUMP(c, JUMP, exit);
+ compiler_use_next_block(c, cleanup);
+ POP_EXCEPT_AND_RERAISE(c);
+ compiler_use_next_block(c, exit);
return 1;
}