mirror of
https://github.com/python/cpython.git
synced 2025-07-16 07:45:20 +00:00
GH-93621: reorder code in with/async-with exception exit path to reduce the size of the exception table (GH-93622)
This commit is contained in:
parent
2ba0fd5767
commit
cf730b595e
3 changed files with 173 additions and 15 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue