[pypy-commit] pypy framestate: Add dummy analyze_signals pass to bc_reader.build_flow()

rlamy noreply at buildbot.pypy.org
Fri Dec 5 17:44:59 CET 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: framestate
Changeset: r74832:3d32a761abce
Date: 2014-12-03 13:50 +0000
http://bitbucket.org/pypy/pypy/changeset/3d32a761abce/

Log:	Add dummy analyze_signals pass to bc_reader.build_flow()

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -214,9 +214,16 @@
             block = self.curr_block
             graph.pos_index[instr.offset] = block, len(block.operations)
             instr.bc_flow(self)
+        self.analyze_signals(graph)
         self.check_graph()
         return graph
 
+    def analyze_signals(self, graph):
+        for block in graph.iterblocks():
+            self.curr_block = block
+            for instr in block:
+                instr.do_signals(self)
+
     def check_graph(self):
         for b in self.blocks:
             if not b._exits:
@@ -263,6 +270,17 @@
             instr = self.read(offset)
             yield instr
 
+    def iterblocks(self):
+        block = self.entry
+        seen = set()
+        stack = block._exits[:]
+        while stack:
+            block = stack.pop()
+            if block not in seen:
+                yield block
+                seen.add(block)
+                stack.extend(block._exits[:])
+
     def all_blocks(self):
         return set(x[0] for x in self.pos_index.values())
 
@@ -338,15 +356,18 @@
         self.arg = arg
         self.offset = offset
 
-    def eval(self, ctx):
-        pass
-
     def bc_flow(self, reader):
         reader.curr_block.operations.append(self)
         if self.has_jump():
             reader.end_block()
             reader.get_block_at(self.arg)
 
+    def do_signals(self, reader):
+        pass
+
+    def eval(self, ctx):
+        pass
+
     def has_jump(self):
         return self.num in opcode.hasjrel or self.num in opcode.hasjabs
 


More information about the pypy-commit mailing list