[pypy-commit] pypy translation-cleanup: Replace block.patchframe(frame) with frame.recording(block)

rlamy noreply at buildbot.pypy.org
Fri Aug 10 10:03:29 CEST 2012


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r56676:a899e4aa1e1e
Date: 2012-08-08 16:23 +0100
http://bitbucket.org/pypy/pypy/changeset/a899e4aa1e1e/

Log:	Replace block.patchframe(frame) with frame.recording(block)

diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -31,13 +31,6 @@
         self.framestate = framestate
         self.dead = False
 
-    def patchframe(self, frame):
-        if self.dead:
-            raise StopFlowing
-        frame.setstate(self.framestate)
-        return BlockRecorder(self)
-
-
 class EggBlock(Block):
     # make slots optional, for debugging
     if hasattr(Block, '__slots__'):
@@ -48,21 +41,6 @@
         self.prevblock = prevblock
         self.booloutcome = booloutcome
 
-    def patchframe(self, frame):
-        parentblocks = []
-        block = self
-        while isinstance(block, EggBlock):
-            block = block.prevblock
-            parentblocks.append(block)
-        # parentblocks = [Egg, Egg, ..., Egg, Spam] not including self
-        block.patchframe(frame)
-        recorder = BlockRecorder(self)
-        prevblock = self
-        for block in parentblocks:
-            recorder = Replayer(block, prevblock.booloutcome, recorder)
-            prevblock = block
-        return recorder
-
     def extravars(self, last_exception=None, last_exc_value=None):
         self.last_exception = last_exception
 
@@ -270,7 +248,7 @@
                                 self.w_globals, self)
             frame.last_instr = 0
             try:
-                self.recorder = block.patchframe(frame)
+                self.recorder = frame.recording(block)
             except StopFlowing:
                 continue   # restarting a dead SpamBlock
             try:
@@ -460,6 +438,24 @@
         blocklist, self.last_instr, self.w_locals = state.nonmergeable
         self.set_blocklist(blocklist)
 
+    def recording(self, block):
+        """ Setup recording of the block and return the recorder. """
+        parentblocks = []
+        parent = block
+        while isinstance(parent, EggBlock):
+            parent = parent.prevblock
+            parentblocks.append(parent)
+        # parentblocks = [Egg, Egg, ..., Egg, Spam] not including block
+        if parent.dead:
+            raise StopFlowing
+        self.setstate(parent.framestate)
+        recorder = BlockRecorder(block)
+        prevblock = block
+        for parent in parentblocks:
+            recorder = Replayer(parent, prevblock.booloutcome, recorder)
+            prevblock = parent
+        return recorder
+
     def SETUP_WITH(self, offsettoend, next_instr):
         # A simpler version than the 'real' 2.7 one:
         # directly call manager.__enter__(), don't use special lookup functions


More information about the pypy-commit mailing list