Author: Ronan Lamy <[email protected]>
Branch: framestate
Changeset: r74712:67c2646feb72
Date: 2014-11-24 17:25 +0000
http://bitbucket.org/pypy/pypy/changeset/67c2646feb72/

Log:    more validation of bc_graph: check that all blocks have exits

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -191,6 +191,8 @@
         return self.get_block_at(self.next_offset)
 
     def enter_next_block(self, block):
+        if not self.curr_block._exits:
+            self.curr_block.set_exits([block])
         self.curr_block = block
         self.blocks.append(block)
         self.needs_new_block = False
@@ -208,12 +210,17 @@
             block = self.curr_block
             graph.pos_index[instr.offset] = block, len(block.operations)
             instr.bc_flow(self)
+        graph._next_pos[instr.offset] = len(code.co_code)
+        self.check_graph()
+        return graph
 
-        graph._next_pos[instr.offset] = len(code.co_code)
+    def check_graph(self):
         for b in self.blocks:
+            if not b._exits:
+                assert any(instr.name in ('RETURN_VALUE', 'RAISE_VARARGS')
+                        for instr in b.operations)
             for x in b._exits:
                 assert x in self.blocks
-        return graph
 
     def build_code(self, code):
         return HostCode._from_code(code)
@@ -275,9 +282,10 @@
             return [self]
         assert 0 < i < len(self.operations)
         tail = self.operations[i:]
-        assert tail
         del self.operations[i:]
         new_block = SimpleBlock(tail)
+        new_block.set_exits(self._exits)
+        self.set_exits([new_block])
         return [self, new_block]
 
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to