summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-05-23 09:46:03 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-05-23 09:46:03 (GMT)
commitab4a69158b93ce8bae450a4d3b588d220aab7aea (patch)
treeab8a7fac013379caf0778a695e2c91a3db9536f1 /Python/compile.c
parentcc798377b76050d65e1a3c86b7f026d37bca63af (diff)
downloadcpython-ab4a69158b93ce8bae450a4d3b588d220aab7aea.zip
cpython-ab4a69158b93ce8bae450a4d3b588d220aab7aea.tar.gz
cpython-ab4a69158b93ce8bae450a4d3b588d220aab7aea.tar.bz2
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.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 8354c75..1cf53f9 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -3483,12 +3483,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 ||