[pypy-commit] pypy translation-cleanup: Move HostCode creation inside the frame.
rlamy
noreply at buildbot.pypy.org
Thu Aug 30 18:38:35 CEST 2012
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: translation-cleanup
Changeset: r57013:d0cb919d2ae5
Date: 2012-08-23 15:56 +0100
http://bitbucket.org/pypy/pypy/changeset/d0cb919d2ae5/
Log: Move HostCode creation inside the frame.
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
@@ -198,11 +198,7 @@
def build_flow(self, func, constargs={}):
space = self.space
- code = HostCode._from_code(space, func.func_code)
- self.code = code
-
- self.frame = frame = FlowSpaceFrame(self.space, code,
- func, constargs)
+ self.frame = frame = FlowSpaceFrame(self.space, func, constargs)
self.joinpoints = {}
self.graph = frame._init_graph(func)
self.pendingblocks = collections.deque([self.graph.startblock])
@@ -214,8 +210,7 @@
frame.frame_finished_execution = False
next_instr = frame.last_instr
while True:
- next_instr = frame.handle_bytecode(code,
- next_instr, self)
+ next_instr = frame.handle_bytecode(next_instr, self)
except ImplicitOperationError, e:
if isinstance(e.w_type, Constant):
@@ -339,7 +334,8 @@
class FlowSpaceFrame(pyframe.CPythonFrame):
- def __init__(self, space, code, func, constargs=None):
+ def __init__(self, space, func, constargs=None):
+ code = HostCode._from_code(space, func.func_code)
self.pycode = code
self.space = space
self.w_globals = Constant(func.func_globals)
@@ -445,9 +441,9 @@
prevblock = parent
return recorder
- def handle_bytecode(self, code, next_instr, ec):
+ def handle_bytecode(self, next_instr, ec):
try:
- next_instr = self.dispatch_bytecode(code, next_instr, ec)
+ next_instr = self.dispatch_bytecode(next_instr, ec)
except OperationThatShouldNotBePropagatedError, e:
raise Exception(
'found an operation that always raises %s: %s' % (
@@ -483,11 +479,11 @@
next_instr = block.handle(self, unroller)
return next_instr
- def dispatch_bytecode(self, code, next_instr, ec):
+ def dispatch_bytecode(self, next_instr, ec):
while True:
self.last_instr = next_instr
ec.bytecode_trace(self)
- next_instr, methodname, oparg = code.read(next_instr)
+ next_instr, methodname, oparg = self.pycode.read(next_instr)
res = getattr(self, methodname)(oparg, next_instr)
if res is not None:
next_instr = res
diff --git a/pypy/objspace/flow/test/test_framestate.py b/pypy/objspace/flow/test/test_framestate.py
--- a/pypy/objspace/flow/test/test_framestate.py
+++ b/pypy/objspace/flow/test/test_framestate.py
@@ -10,14 +10,11 @@
cls.space = FlowObjSpace()
def getframe(self, func):
- space = self.space
try:
func = func.im_func
except AttributeError:
pass
- code = func.func_code
- code = PyCode._from_code(self.space, code)
- frame = FlowSpaceFrame(space, code, func)
+ frame = FlowSpaceFrame(self.space, func)
# hack the frame
frame.locals_stack_w[frame.pycode.co_nlocals-1] = Constant(None)
return frame
More information about the pypy-commit
mailing list