Author: Ronan Lamy <[email protected]>
Branch: framestate
Changeset: r74833:3fbf13809a73
Date: 2014-12-03 17:32 +0000
http://bitbucket.org/pypy/pypy/changeset/3fbf13809a73/

Log:    begin implementing analyze_signals()

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -221,8 +221,12 @@
     def analyze_signals(self, graph):
         for block in graph.iterblocks():
             self.curr_block = block
+            block.init_blockstack()
+            self.blockstack = block.blockstack[:]
             for instr in block:
                 instr.do_signals(self)
+            for exit in block._exits:
+                exit.set_blockstack(self.blockstack)
 
     def check_graph(self):
         for b in self.blocks:
@@ -294,7 +298,7 @@
     def __init__(self):
         self.parents = set()
         self._exits = []
-        self.blockstack = []
+        self.blockstack = None
 
     def __getitem__(self, i):
         return self.operations[i]
@@ -320,6 +324,16 @@
     def startpos(self):
         return self.operations[0].offset
 
+    def init_blockstack(self):
+        if self.blockstack is None:
+            self.blockstack = []
+
+    def set_blockstack(self, blockstack):
+        if self.blockstack is None:
+            self.blockstack = blockstack
+        else:
+            assert self.blockstack == blockstack
+
     def split_at(self, i):
         if i == 0 or i == len(self.operations):
             return [self]
@@ -546,7 +560,9 @@
     def bc_flow(self, reader):
         reader.curr_block.operations.append(self)
         self.target = reader.get_block_at(self.arg)
-        reader.curr_block.blockstack.append(self.make_block(-1))
+
+    def do_signals(self, reader):
+        reader.blockstack.append(self.make_block(-1))
 
     def eval(self, ctx):
         block = self.make_block(ctx.stackdepth)
@@ -590,6 +606,16 @@
         ctx.blockstack.append(block)
         ctx.pushvalue(w_result)
 
+@bc_reader.register_opcode
+class POP_BLOCK(BCInstruction):
+    def do_signals(self, reader):
+        reader.blockstack.pop()
+
+    def eval(self, ctx):
+        block = ctx.blockstack.pop()
+        block.cleanupstack(ctx)  # the block knows how to clean up the value 
stack
+
+
 _unary_ops = [
     ('UNARY_POSITIVE', op.pos),
     ('UNARY_NEGATIVE', op.neg),
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -652,10 +652,6 @@
             signal = self.popvalue()
             raise signal
 
-    def POP_BLOCK(self, oparg):
-        block = self.blockstack.pop()
-        block.cleanupstack(self)  # the block knows how to clean up the value 
stack
-
     def YIELD_VALUE(self, _):
         assert self.pycode.is_generator
         w_result = self.popvalue()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to