mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #21523: Fix over-pessimistic computation of the stack effect of some opcodes in the compiler.
This also fixes a quadratic compilation time issue noticeable when compiling code with a large number of "and" and "or" operators.
This commit is contained in:
commit
5c8008e59d
3 changed files with 50 additions and 5 deletions
|
@ -3862,12 +3862,16 @@ stackdepth_walk(struct compiler *c, basicblock *b, int depth, int maxdepth)
|
|||
target_depth = depth;
|
||||
if (instr->i_opcode == FOR_ITER) {
|
||||
target_depth = depth-2;
|
||||
} else if (instr->i_opcode == SETUP_FINALLY ||
|
||||
instr->i_opcode == SETUP_EXCEPT) {
|
||||
}
|
||||
else if (instr->i_opcode == SETUP_FINALLY ||
|
||||
instr->i_opcode == SETUP_EXCEPT) {
|
||||
target_depth = depth+3;
|
||||
if (target_depth > maxdepth)
|
||||
maxdepth = target_depth;
|
||||
}
|
||||
else if (instr->i_opcode == JUMP_IF_TRUE_OR_POP ||
|
||||
instr->i_opcode == JUMP_IF_FALSE_OR_POP)
|
||||
depth = depth - 1;
|
||||
maxdepth = stackdepth_walk(c, instr->i_target,
|
||||
target_depth, maxdepth);
|
||||
if (instr->i_opcode == JUMP_ABSOLUTE ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue