Author: Armin Rigo <[email protected]>
Branch:
Changeset: r86285:b4e83acb5f3c
Date: 2016-08-18 19:15 +0200
http://bitbucket.org/pypy/pypy/changeset/b4e83acb5f3c/
Log: Add a more precise assert: the computed stack depth must never be
negative. Fix the logic to avoid computing stack depths for
unreachable blocks.
diff --git a/pypy/interpreter/astcompiler/assemble.py
b/pypy/interpreter/astcompiler/assemble.py
--- a/pypy/interpreter/astcompiler/assemble.py
+++ b/pypy/interpreter/astcompiler/assemble.py
@@ -387,7 +387,8 @@
def _stacksize(self, blocks):
"""Compute co_stacksize."""
for block in blocks:
- block.initial_depth = 0
+ block.initial_depth = -99
+ blocks[0].initial_depth = 0
# Assumes that it is sufficient to walk the blocks in 'post-order'.
# This means we ignore all back-edges, but apart from that, we only
# look into a block when all the previous blocks have been done.
@@ -406,8 +407,11 @@
def _do_stack_depth_walk(self, block):
depth = block.initial_depth
+ if depth == -99: # this block is never reached, skip
+ return 0
for instr in block.instructions:
depth += _opcode_stack_effect(instr.opcode, instr.arg)
+ assert depth >= 0
if depth >= self._max_depth:
self._max_depth = depth
jump_op = instr.opcode
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit