[pypy-commit] pypy Opcode-class: Simplify record_block() setup.
rlamy
noreply at buildbot.pypy.org
Sat May 4 02:05:34 CEST 2013
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: Opcode-class
Changeset: r63827:34743f1d56d2
Date: 2013-05-02 04:12 +0100
http://bitbucket.org/pypy/pypy/changeset/34743f1d56d2/
Log: Simplify record_block() setup.
Kill FSFrame.recording() and dispatch its logic to Block methods.
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -55,25 +55,44 @@
pass
class SpamBlock(Block):
- # make slots optional, for debugging
- if hasattr(Block, '__slots__'):
- __slots__ = "dead framestate".split()
-
def __init__(self, framestate):
Block.__init__(self, framestate.getvariables())
self.framestate = framestate
self.dead = False
+ def make_recorder(self):
+ return BlockRecorder(self)
+
class EggBlock(Block):
- # make slots optional, for debugging
- if hasattr(Block, '__slots__'):
- __slots__ = "prevblock booloutcome last_exception".split()
-
def __init__(self, inputargs, prevblock, booloutcome):
Block.__init__(self, inputargs)
self.prevblock = prevblock
self.booloutcome = booloutcome
+ @property
+ def ancestor(self):
+ parent = self.prevblock
+ while isinstance(parent, EggBlock):
+ parent = parent.prevblock
+ return parent
+
+ @property
+ def dead(self):
+ return self.ancestor.dead
+
+ @property
+ def framestate(self):
+ return self.ancestor.framestate
+
+ def make_recorder(self):
+ recorder = BlockRecorder(self)
+ curr = self
+ while isinstance(curr, EggBlock):
+ prev = curr.prevblock
+ recorder = Replayer(prev, curr.booloutcome, recorder)
+ curr = prev
+ return recorder
+
def extravars(self, last_exception=None, last_exc_value=None):
self.last_exception = last_exception
@@ -430,24 +449,6 @@
self.last_instr = state.next_instr
self.blockstack = state.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 record(self, spaceop):
"""Record an operation into the active block"""
recorder = self.recorder
@@ -488,11 +489,13 @@
self.pendingblocks = collections.deque([graph.startblock])
while self.pendingblocks:
block = self.pendingblocks.popleft()
- self.record_block(block)
+ if not block.dead:
+ self.record_block(block)
def record_block(self, block):
+ self.setstate(block.framestate)
+ self.recorder = block.make_recorder()
try:
- self.recorder = self.recording(block)
while True:
self.last_instr = self.handle_bytecode(self.last_instr)
self.recorder.final_state = self.getstate()
More information about the pypy-commit
mailing list