Author: Ronan Lamy <[email protected]>
Branch: framestate
Changeset: r75855:452634b78aa1
Date: 2015-02-13 13:33 +0000
http://bitbucket.org/pypy/pypy/changeset/452634b78aa1/

Log:    follow links from SETUP_ instrs to their targets in
        graph.iterblocks()

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -217,20 +217,13 @@
 
     def analyze_contexts(self, graph):
         start = graph.entry._exits[0]
-        self.pending = [start]
         start.set_blockstack([])
-        done = set()
-        while self.pending:
-            block = self.pending.pop(0)
-            if block in done:
-                continue
+        for block in graph.iterblocks():
             self.blockstack = block.blockstack[:]
             for instr in block:
                 instr.context_effect(self)
             for child in block._exits:
                 child.set_blockstack(self.blockstack)
-                self.pending.append(child)
-            done.add(block)
 
     def analyze_signals(self, graph):
         for block in graph.iterblocks():
@@ -294,10 +287,13 @@
         stack = block._exits[:]
         while stack:
             block = stack.pop()
-            if block not in seen:
-                yield block
-                seen.add(block)
-                stack.extend(block._exits[:])
+            if block in seen:
+                continue
+            yield block
+            seen.add(block)
+            stack.extend(block._exits[:])
+            if block.special_exit:
+                stack.append(block.special_exit)
 
     def all_blocks(self):
         return list(self.iterblocks())
@@ -368,6 +364,7 @@
     def __init__(self, operations, exit=None):
         BytecodeBlock.__init__(self)
         self.operations = operations
+        self.special_exit = None
         if exit:
             self.set_exits([exit])
 
@@ -655,14 +652,15 @@
         self.block = self.make_block(-1)
 
     def bc_flow(self, reader):
-        reader.curr_block.operations.append(self)
+        block = reader.curr_block
+        block.operations.append(self)
         self.target = reader.get_block_at(self.arg)
         self.block.handler = self.target
+        block.special_exit = self.target
         reader.end_block()
 
     def context_effect(self, reader):
         self.target.set_blockstack(reader.blockstack)
-        reader.pending.append(self.target)
         reader.blockstack.append(self.block)
 
     def eval(self, ctx):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to