[pypy-commit] pypy framestate: Don't tie the FlowContext's notion of position with offsets
rlamy
noreply at buildbot.pypy.org
Tue Nov 25 15:47:27 CET 2014
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: framestate
Changeset: r74716:355495340c68
Date: 2014-11-24 20:49 +0000
http://bitbucket.org/pypy/pypy/changeset/355495340c68/
Log: Don't tie the FlowContext's notion of position with offsets
diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -244,6 +244,12 @@
else:
return block.operations[i].offset
+ def get_position(self, offset):
+ return offset
+
+ def get_offset(self, position):
+ return position
+
def dump(self):
all_blocks = set(x[0] for x in self.pos_index.values())
blocks = sorted(all_blocks, key=lambda b: b.startpos)
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -288,9 +288,9 @@
def dropvaluesuntil(self, finaldepth):
del self.stack[finaldepth:]
- def getstate(self, next_offset):
+ def getstate(self, position):
return FrameState(self.locals_w[:], self.stack[:],
- self.last_exception, self.blockstack[:], next_offset)
+ self.last_exception, self.blockstack[:], position)
def setstate(self, state):
""" Reset the context to the given frame state. """
@@ -347,15 +347,16 @@
def record_block(self, block):
self.setstate(block.framestate)
- next_offset = block.framestate.next_offset
self.recorder = block.make_recorder()
bc_graph = self.pycode.graph
+ next_offset = bc_graph.get_offset(block.framestate.position)
try:
while True:
instr = bc_graph.read(next_offset)
self.last_offset = instr.offset
next_offset = self.handle_bytecode(instr)
- self.recorder.final_state = self.getstate(next_offset)
+ position = bc_graph.get_position(next_offset)
+ self.recorder.final_state = self.getstate(position)
except RaiseImplicit as e:
w_exc = e.w_exc
@@ -393,10 +394,10 @@
self.recorder = None
def mergeblock(self, currentblock, currentstate):
- next_offset = currentstate.next_offset
+ position = currentstate.position
# can 'currentstate' be merged with one of the blocks that
# already exist for this bytecode position?
- candidates = self.joinpoints.setdefault(next_offset, [])
+ candidates = self.joinpoints.setdefault(position, [])
for block in candidates:
newstate = block.framestate.union(currentstate)
if newstate is not None:
diff --git a/rpython/flowspace/framestate.py b/rpython/flowspace/framestate.py
--- a/rpython/flowspace/framestate.py
+++ b/rpython/flowspace/framestate.py
@@ -16,12 +16,12 @@
class FrameState(object):
- def __init__(self, locals_w, stack, last_exception, blocklist, next_offset):
+ def __init__(self, locals_w, stack, last_exception, blocklist, position):
self.locals_w = locals_w
self.stack = stack
self.last_exception = last_exception
self.blocklist = blocklist
- self.next_offset = next_offset
+ self.position = position
self._mergeable = None
@property
@@ -44,7 +44,7 @@
if exc is not None:
exc = FSException(_copy(exc.w_type), _copy(exc.w_value))
return FrameState(map(_copy, self.locals_w), map(_copy, self.stack),
- exc, self.blocklist, self.next_offset)
+ exc, self.blocklist, self.position)
def getvariables(self):
return [w for w in self.mergeable if isinstance(w, Variable)]
@@ -55,7 +55,7 @@
# safety check, don't try to compare states with different
# nonmergeable states
assert self.blocklist == other.blocklist
- assert self.next_offset == other.next_offset
+ assert self.position == other.position
for w1, w2 in zip(self.mergeable, other.mergeable):
if not (w1 == w2 or (isinstance(w1, Variable) and
isinstance(w2, Variable))):
@@ -86,7 +86,7 @@
union(args1[1], args2[1]))
except UnionError:
return None
- return FrameState(locals, stack, exc, self.blocklist, self.next_offset)
+ return FrameState(locals, stack, exc, self.blocklist, self.position)
def getoutputargs(self, targetstate):
"Return the output arguments needed to link self to targetstate."
More information about the pypy-commit
mailing list