[pypy-svn] r64688 - in pypy/branch/pyjitpl5/pypy/jit: backend backend/llgraph backend/llgraph/test backend/minimal backend/minimal/test backend/test metainterp
arigo at codespeak.net
arigo at codespeak.net
Sun Apr 26 14:40:10 CEST 2009
Author: arigo
Date: Sun Apr 26 14:40:09 2009
New Revision: 64688
Modified:
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py
pypy/branch/pyjitpl5/pypy/jit/backend/minimal/runner.py
pypy/branch/pyjitpl5/pypy/jit/backend/minimal/test/test_runner.py
pypy/branch/pyjitpl5/pypy/jit/backend/model.py
pypy/branch/pyjitpl5/pypy/jit/backend/test/runner.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/compile.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
Log:
Simplify the CPU interface a bit.
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/runner.py Sun Apr 26 14:40:09 2009
@@ -83,7 +83,7 @@
if translate_support_code:
self.mixlevelann = annmixlevel
- def compile_operations(self, loop, returnboxes):
+ def compile_operations(self, loop):
"""In a real assembler backend, this should assemble the given
list of operations. Here we just generate a similar CompiledLoop
instance. The code here is RPython, whereas the code in llimpl
@@ -102,13 +102,13 @@
var2index[box] = llimpl.compile_start_obj_var(c)
else:
raise Exception("box is: %r" % (box,))
- self._compile_branch(c, loop.operations, var2index, returnboxes)
+ self._compile_branch(c, loop.operations, var2index)
# We must redirect code jumping to the old loop so that it goes
# to the new loop.
if prev_c:
llimpl.compile_redirect_code(prev_c, c)
- def _compile_branch(self, c, operations, var2index, returnboxes):
+ def _compile_branch(self, c, operations, var2index):
for op in operations:
llimpl.compile_add(c, op.opnum)
if isinstance(op.descr, Descr):
@@ -132,8 +132,7 @@
x))
if op.is_guard():
c2 = llimpl.compile_suboperations(c)
- self._compile_branch(c2, op.suboperations, var2index.copy(),
- returnboxes)
+ self._compile_branch(c2, op.suboperations, var2index.copy())
x = op.result
if x is not None:
if isinstance(x, history.BoxInt):
@@ -151,7 +150,7 @@
llimpl.compile_add_jump_target(c, op.jump_target._compiled_version)
elif op.opnum == rop.FAIL:
llimpl.compile_add_fail(c, len(self.fail_ops))
- self.fail_ops.append((op, returnboxes))
+ self.fail_ops.append(op)
def execute_operations(self, loop, valueboxes):
"""Calls the assembler generated for the given loop.
@@ -180,7 +179,8 @@
# we hit a FAIL operation. Fish for the values
# (in a real backend, this should be done by the FAIL operation
# itself, not here)
- op, returnboxes = self.fail_ops[fail_index]
+ op = self.fail_ops[fail_index]
+ returnboxes = self.metainterp_sd.returnboxes
i_int = 0
i_ptr = 0
i_obj = 0
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/llgraph/test/test_llgraph.py Sun Apr 26 14:40:09 2009
@@ -7,7 +7,7 @@
TreeLoop
from pypy.jit.metainterp.resoperation import ResOperation, rop
from pypy.jit.metainterp.executor import execute
-from pypy.jit.backend.test.runner import BaseBackendTest
+from pypy.jit.backend.test.runner import BaseBackendTest, FakeMetaInterpSd
NODE = lltype.GcForwardReference()
NODE.become(lltype.GcStruct('NODE', ('value', lltype.Signed),
@@ -20,6 +20,7 @@
def setup_class(self):
self.cpu = self.cpu_type(None)
+ self.cpu.set_meta_interp_static_data(FakeMetaInterpSd())
def eval_llinterp(self, runme, *args, **kwds):
expected_class = kwds.pop('expected_class', None)
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/minimal/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/minimal/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/minimal/runner.py Sun Apr 26 14:40:09 2009
@@ -5,10 +5,11 @@
from pypy.jit.metainterp.history import AbstractDescr, Box, BoxInt, BoxPtr
from pypy.jit.metainterp import executor, history
from pypy.jit.metainterp.resoperation import rop, opname
+from pypy.jit.backend.model import AbstractCPU
DEBUG = False
-class CPU(object):
+class CPU(AbstractCPU):
is_oo = False # XXX for now
def __init__(self, rtyper, stats, translate_support_code=False,
@@ -36,8 +37,8 @@
immortal=True)
self._ovf_error_inst = ll_inst
- def compile_operations(self, loop, returnboxes):
- loop._returnboxes = returnboxes
+ def compile_operations(self, loop):
+ pass
def execute_operations(self, loop, valueboxes):
if DEBUG:
@@ -107,7 +108,7 @@
if DEBUG:
print "execute_operations: leaving", loop
- returnboxes = loop._returnboxes
+ returnboxes = self.metainterp_sd.returnboxes
i_int = 0
i_ptr = 0
for i in range(len(op.args)):
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/minimal/test/test_runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/minimal/test/test_runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/minimal/test/test_runner.py Sun Apr 26 14:40:09 2009
@@ -1,6 +1,6 @@
import py
from pypy.jit.backend.minimal.runner import CPU
-from pypy.jit.backend.test.runner import BaseBackendTest
+from pypy.jit.backend.test.runner import BaseBackendTest, FakeMetaInterpSd
class FakeStats(object):
pass
@@ -14,6 +14,7 @@
def setup_class(cls):
cls.cpu = CPU(rtyper=None, stats=FakeStats())
+ cls.cpu.set_meta_interp_static_data(FakeMetaInterpSd())
def _skip(self):
py.test.skip("not supported in non-translated version")
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/model.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/model.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/model.py Sun Apr 26 14:40:09 2009
@@ -1,17 +1,19 @@
class AbstractCPU(object):
- def compile_operations(self, loop, returnboxes):
+ def set_meta_interp_static_data(self, metainterp_sd):
+ self.metainterp_sd = metainterp_sd
+
+ def compile_operations(self, loop):
"""Assemble the given list of operations.
loop is of type history.TreeLoop.
- returnboxes is of type history.ReturnBoxes.
"""
raise NotImplementedError
def execute_operations(self, loop, valueboxes):
"""Calls the assembler generated for the given loop.
Stops when encountering an operation of type rop.FAIL.
- Returns the operation, after having saved the current
- values into the boxes listed by returnboxes.
+ Returns the FAIL operation, after having saved the current
+ values into the boxes listed by 'metainterp_sd.returnboxes'.
"""
raise NotImplementedError
Modified: pypy/branch/pyjitpl5/pypy/jit/backend/test/runner.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/backend/test/runner.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/backend/test/runner.py Sun Apr 26 14:40:09 2009
@@ -17,7 +17,10 @@
('next', lltype.Ptr(S)))
U = lltype.GcStruct('U', ('parent', T),
('next', lltype.Ptr(S)))
-returnboxes = ReturnBoxes()
+
+class FakeMetaInterpSd(object):
+ returnboxes = ReturnBoxes()
+
class Runner(object):
@@ -31,9 +34,9 @@
else:
self.guard_failed = True
if result_type == 'int':
- return returnboxes._returnboxes_int[0]
+ return FakeMetaInterpSd.returnboxes._returnboxes_int[0]
elif result_type == 'ptr':
- return returnboxes._returnboxes_ptr[0]
+ return FakeMetaInterpSd.returnboxes._returnboxes_ptr[0]
def get_compiled_single_operation(self, opnum, result_type, valueboxes,
descr):
@@ -58,7 +61,7 @@
loop = TreeLoop('single op')
loop.operations = operations
loop.inputargs = [box for box in valueboxes if isinstance(box, Box)]
- self.cpu.compile_operations(loop, returnboxes)
+ self.cpu.compile_operations(loop)
return loop
class BaseBackendTest(Runner):
@@ -207,14 +210,15 @@
loop = TreeLoop('name')
loop.operations = ops
loop.inputargs = [v1, v2]
- self.cpu.compile_operations(loop, returnboxes)
+ self.cpu.compile_operations(loop)
for x, y, z in testcases:
op = self.cpu.execute_operations(loop, [BoxInt(x), BoxInt(y)])
if z == boom:
assert op is ops[1].suboperations[-1]
else:
assert op is ops[-1]
- assert returnboxes._returnboxes_int[0].value == z
+ box = FakeMetaInterpSd.returnboxes._returnboxes_int[0]
+ assert box.value == z
# ----------
# the same thing but with the exception path reversed
## v1 = BoxInt(testcases[0][0])
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/compile.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/compile.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/compile.py Sun Apr 26 14:40:09 2009
@@ -111,7 +111,7 @@
return loop
def send_loop_to_backend(metainterp, loop, type):
- metainterp.cpu.compile_operations(loop, metainterp.staticdata.returnboxes)
+ metainterp.cpu.compile_operations(loop)
if not we_are_translated():
if type != "entry bridge":
metainterp.staticdata.stats.compiled_count += 1
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/pyjitpl.py Sun Apr 26 14:40:09 2009
@@ -832,6 +832,7 @@
self.ts = typesystem.oohelper
else:
self.ts = typesystem.llhelper
+ cpu.set_meta_interp_static_data(self)
def _freeze_(self):
return True
More information about the Pypy-commit
mailing list