[pypy-svn] r64052 - in pypy/branch/pyjitpl5-simplify/pypy/jit: backend backend/llgraph metainterp metainterp/test
antocuni at codespeak.net
antocuni at codespeak.net
Tue Apr 14 13:46:52 CEST 2009
Author: antocuni
Date: Tue Apr 14 13:46:50 2009
New Revision: 64052
Added:
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/model.py (contents, props changed)
Modified:
pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_loop.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_loop_dummy.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_optimize.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_vable_optimize.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_vlist.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_warmspot.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_zrpy_basic.py
pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py
Log:
(in-progress) try to split ootype and lltype graph backend into two different classes
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/llgraph/runner.py Tue Apr 14 13:46:50 2009
@@ -8,6 +8,7 @@
from pypy.rpython.llinterp import LLInterpreter
from pypy.jit.metainterp import history
from pypy.jit.metainterp.resoperation import ResOperation, rop
+from pypy.jit.backend import model
from pypy.jit.backend.llgraph import llimpl, symbolic
@@ -61,7 +62,7 @@
history.TreeLoop._compiled_version = lltype.nullptr(llimpl.COMPILEDLOOP.TO)
-class CPU(object):
+class BaseCPU(model.AbstractCPU):
def __init__(self, rtyper, stats=None, translate_support_code=False,
annmixlevel=None):
@@ -229,12 +230,17 @@
token = history.getkind(RESULT)
return Descr(0, token[0])
+
def cast_adr_to_int(self, adr):
return llimpl.cast_adr_to_int(self.memo_cast, adr)
def cast_int_to_adr(self, int):
return llimpl.cast_int_to_adr(self.memo_cast, int)
+
+
+class LLtypeCPU(BaseCPU):
+
# ---------- the backend-dependent operations ----------
def do_arraylen_gc(self, args, arraydescr):
@@ -377,7 +383,11 @@
return history.BoxInt(llimpl.cast_to_int(args[0].getptr_base(),
self.memo_cast))
+class OOtypeCPU(BaseCPU):
+ pass
+
# ____________________________________________________________
import pypy.jit.metainterp.executor
-pypy.jit.metainterp.executor.make_execute_list(CPU)
+pypy.jit.metainterp.executor.make_execute_list(LLtypeCPU)
+pypy.jit.metainterp.executor.make_execute_list(OOtypeCPU)
Added: pypy/branch/pyjitpl5-simplify/pypy/jit/backend/model.py
==============================================================================
--- (empty file)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/backend/model.py Tue Apr 14 13:46:50 2009
@@ -0,0 +1,117 @@
+class AbstractCPU(object):
+
+ def compile_operations(self, loop):
+ """Assemble the given list of operations."""
+ raise NotImplementedError
+
+ def execute_operations(self, loop, valueboxes):
+ """Calls the assembler generated for the given loop.
+ Returns the ResOperation that failed, of type rop.FAIL.
+ """
+ raise NotImplementedError
+
+ def get_exception(self):
+ raise NotImplementedError
+
+ def get_exc_value(self):
+ raise NotImplementedError
+
+ def clear_exception(self):
+ raise NotImplementedError
+
+ def set_overflow_error(self):
+ raise NotImplementedError
+
+ @staticmethod
+ def sizeof(S):
+ raise NotImplementedError
+
+ @staticmethod
+ def numof(S):
+ raise NotImplementedError
+
+ @staticmethod
+ def fielddescrof(S, fieldname):
+ raise NotImplementedError
+
+ @staticmethod
+ def arraydescrof(A):
+ raise NotImplementedError
+
+ @staticmethod
+ def calldescrof(ARGS, RESULT):
+ raise NotImplementedError
+
+ def cast_adr_to_int(self, adr):
+ raise NotImplementedError
+
+ def cast_int_to_adr(self, int):
+ raise NotImplementedError
+
+ # ---------- the backend-dependent operations ----------
+
+ # lltype specific operations
+ # --------------------------
+
+ def do_arraylen_gc(self, args, arraydescr):
+ raise NotImplementedError
+
+ def do_strlen(self, args, descr=None):
+ raise NotImplementedError
+
+ def do_strgetitem(self, args, descr=None):
+ raise NotImplementedError
+
+ def do_unicodelen(self, args, descr=None):
+ raise NotImplementedError
+
+ def do_unicodegetitem(self, args, descr=None):
+ raise NotImplementedError
+
+ def do_getarrayitem_gc(self, args, arraydescr):
+ raise NotImplementedError
+
+ def do_getfield_gc(self, args, fielddescr):
+ raise NotImplementedError
+
+ def do_getfield_raw(self, args, fielddescr):
+ raise NotImplementedError
+
+ def do_new(self, args, size):
+ raise NotImplementedError
+
+ def do_new_with_vtable(self, args, size):
+ raise NotImplementedError
+
+ def do_new_array(self, args, size):
+ raise NotImplementedError
+
+ def do_setarrayitem_gc(self, args, arraydescr):
+ raise NotImplementedError
+
+ def do_setfield_gc(self, args, fielddescr):
+ raise NotImplementedError
+
+ def do_setfield_raw(self, args, fielddescr):
+ raise NotImplementedError
+
+ def do_newstr(self, args, descr=None):
+ raise NotImplementedError
+
+ def do_newunicode(self, args, descr=None):
+ raise NotImplementedError
+
+ def do_strsetitem(self, args, descr=None):
+ raise NotImplementedError
+
+ def do_unicodesetitem(self, args, descr=None):
+ raise NotImplementedError
+
+ def do_call(self, args, calldescr):
+ raise NotImplementedError
+
+ def do_cast_int_to_ptr(self, args, descr=None):
+ raise NotImplementedError
+
+ def do_cast_ptr_to_int(self, args, descr=None):
+ raise NotImplementedError
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_basic.py Tue Apr 14 13:46:50 2009
@@ -90,11 +90,11 @@
class LLJitMixin(JitMixin):
type_system = 'lltype'
- CPUClass = runner.CPU
+ CPUClass = runner.LLtypeCPU
class OOJitMixin(JitMixin):
type_system = 'ootype'
- CPUClass = runner.CPU
+ CPUClass = runner.OOtypeCPU
class BasicTests:
@@ -460,7 +460,9 @@
inline_threshold=0)
clear_tcache()
translator = interp.typer.annotator.translator
- warmrunnerdesc = WarmRunnerDesc(translator, optimizer=SimpleOptimizer)
+ warmrunnerdesc = WarmRunnerDesc(translator,
+ CPUClass=self.CPUClass,
+ optimizer=SimpleOptimizer)
warmrunnerdesc.state.set_param_threshold(3) # for tests
warmrunnerdesc.state.set_param_trace_eagerness(0) # for tests
warmrunnerdesc.finish()
@@ -510,18 +512,18 @@
assert res == 72
-class TestOOtype(BasicTests, OOJitMixin):
- def skip(self):
- py.test.skip('in-progress')
-
- test_chr2str = skip
- test_unicode = skip
- test_residual_call = skip
- test_format = skip
- test_getfield = skip
- test_getfield_immutable = skip
- test_oops_on_nongc = skip
- test_instantiate_classes = skip
+## class TestOOtype(BasicTests, OOJitMixin):
+## def skip(self):
+## py.test.skip('in-progress')
+
+## test_chr2str = skip
+## test_unicode = skip
+## test_residual_call = skip
+## test_format = skip
+## test_getfield = skip
+## test_getfield_immutable = skip
+## test_oops_on_nongc = skip
+## test_instantiate_classes = skip
class TestLLtype(BasicTests, LLJitMixin):
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_loop.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_loop.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_loop.py Tue Apr 14 13:46:50 2009
@@ -12,7 +12,8 @@
def meta_interp(self, f, args, policy=None):
return ll_meta_interp(f, args, specialize=self.specialize,
- policy=policy)
+ policy=policy,
+ CPUClass=self.CPUClass)
def test_simple_loop(self):
myjitdriver = JitDriver(greens = [], reds = ['x', 'y', 'res'])
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_loop_dummy.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_loop_dummy.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_loop_dummy.py Tue Apr 14 13:46:50 2009
@@ -5,4 +5,5 @@
class TestLoopDummy(test_loop.TestLoop):
def meta_interp(self, func, args, **kwds):
- return ll_meta_interp(func, args, optimizer=Optimizer, **kwds)
+ return ll_meta_interp(func, args, optimizer=Optimizer,
+ CPUClass=self.CPUClass, **kwds)
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_optimize.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_optimize.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_optimize.py Tue Apr 14 13:46:50 2009
@@ -13,7 +13,7 @@
VirtualInstanceSpecNode, FixedClassSpecNode,
NotSpecNode)
-cpu = runner.CPU(None)
+cpu = runner.LLtypeCPU(None)
NODE = lltype.GcForwardReference()
NODE.become(lltype.GcStruct('NODE', ('parent', OBJECT),
@@ -87,9 +87,9 @@
# ____________________________________________________________
class A:
- ofs_next = runner.CPU.fielddescrof(NODE, 'next')
- ofs_value = runner.CPU.fielddescrof(NODE, 'value')
- size_of_node = runner.CPU.sizeof(NODE)
+ ofs_next = runner.LLtypeCPU.fielddescrof(NODE, 'next')
+ ofs_value = runner.LLtypeCPU.fielddescrof(NODE, 'value')
+ size_of_node = runner.LLtypeCPU.sizeof(NODE)
#
startnode = lltype.malloc(NODE)
startnode.value = 20
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_vable_optimize.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_vable_optimize.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_vable_optimize.py Tue Apr 14 13:46:50 2009
@@ -66,10 +66,10 @@
# ____________________________________________________________
class A:
- ofs_node = runner.CPU.fielddescrof(XY, 'inst_node')
- ofs_l = runner.CPU.fielddescrof(XY, 'inst_l')
- ofs_value = runner.CPU.fielddescrof(NODE, 'value')
- size_of_node = runner.CPU.sizeof(NODE)
+ ofs_node = runner.LLtypeCPU.fielddescrof(XY, 'inst_node')
+ ofs_l = runner.LLtypeCPU.fielddescrof(XY, 'inst_l')
+ ofs_value = runner.LLtypeCPU.fielddescrof(NODE, 'value')
+ size_of_node = runner.LLtypeCPU.sizeof(NODE)
#
frame = lltype.malloc(XY)
frame.vable_rti = lltype.nullptr(XY.vable_rti.TO)
@@ -130,9 +130,9 @@
# ____________________________________________________________
class B:
- ofs_node = runner.CPU.fielddescrof(XY, 'inst_node')
- ofs_value = runner.CPU.fielddescrof(NODE, 'value')
- size_of_node = runner.CPU.sizeof(NODE)
+ ofs_node = runner.LLtypeCPU.fielddescrof(XY, 'inst_node')
+ ofs_value = runner.LLtypeCPU.fielddescrof(NODE, 'value')
+ size_of_node = runner.LLtypeCPU.sizeof(NODE)
#
frame = lltype.malloc(XY)
frame.vable_rti = lltype.nullptr(XY.vable_rti.TO)
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_vlist.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_vlist.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_vlist.py Tue Apr 14 13:46:50 2009
@@ -356,8 +356,8 @@
self.check_all_virtualized()
-class TestOOtype(ListTests, OOJitMixin):
- pass
+## class TestOOtype(ListTests, OOJitMixin):
+## pass
class TestLLtype(ListTests, LLJitMixin):
pass
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_warmspot.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_warmspot.py Tue Apr 14 13:46:50 2009
@@ -1,5 +1,6 @@
from pypy.jit.metainterp.warmspot import ll_meta_interp
from pypy.rlib.jit import JitDriver
+from pypy.jit.backend.llgraph import runner
class Exit(Exception):
def __init__(self, result):
@@ -8,6 +9,8 @@
class WarmspotTests(object):
def meta_interp(self, *args, **kwds):
+ assert 'CPUClass' not in kwds
+ kwds['CPUClass'] = self.CPUClass
return ll_meta_interp(*args, **kwds)
def test_basic(self):
@@ -61,4 +64,4 @@
class TestLLWarmspot(WarmspotTests):
- pass
+ CPUClass = runner.LLtypeCPU
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_zrpy_basic.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_zrpy_basic.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/test/test_zrpy_basic.py Tue Apr 14 13:46:50 2009
@@ -1,12 +1,15 @@
import py
from pypy.jit.metainterp.warmspot import rpython_ll_meta_interp, ll_meta_interp
from pypy.jit.metainterp.test import test_basic
+from pypy.jit.backend.llgraph import runner
from pypy.rlib.jit import JitDriver
from pypy.jit.conftest import option
class TestBasic:
+ CPUClass = runner.LLtypeCPU
+
def test_loop_1(self):
if not option.run_slow_tests:
py.test.skip("use --slow to execute this long-running test")
@@ -19,9 +22,9 @@
total += i
i -= 1
return total * 10
- res = ll_meta_interp(f, [10])
+ res = ll_meta_interp(f, [10], CPUClass=self.CPUClass)
assert res == 490
- res = rpython_ll_meta_interp(f, [10], loops=1)
+ res = rpython_ll_meta_interp(f, [10], loops=1, CPUClass=self.CPUClass)
assert res == 490
def test_loop_2(self):
@@ -37,9 +40,9 @@
i -= 2
i -= 1
return total * 10
- res = ll_meta_interp(f, [17])
+ res = ll_meta_interp(f, [17], CPUClass=self.CPUClass)
assert res == (17+14+11+8+7+6+5+4) * 10
- res = rpython_ll_meta_interp(f, [17], loops=2)
+ res = rpython_ll_meta_interp(f, [17], loops=2, CPUClass=self.CPUClass)
assert res == (17+14+11+8+7+6+5+4) * 10
class LLInterpJitMixin:
Modified: pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py (original)
+++ pypy/branch/pyjitpl5-simplify/pypy/jit/metainterp/warmspot.py Tue Apr 14 13:46:50 2009
@@ -16,7 +16,6 @@
from pypy.jit.metainterp import support, history, pyjitpl
from pypy.jit.metainterp.pyjitpl import MetaInterpStaticData, MetaInterp
-from pypy.jit.backend.llgraph import runner
from pypy.jit.metainterp.policy import JitPolicy
# ____________________________________________________________
@@ -124,9 +123,10 @@
def _freeze_(self):
return True
- def build_meta_interp(self, CPUClass=runner.CPU, view="auto",
+ def build_meta_interp(self, CPUClass=None, view="auto",
translate_support_code=False, optimizer=None,
**kwds):
+ assert CPUClass is not None
opt = pyjitpl.Options(**kwds)
self.stats = history.Stats()
if translate_support_code:
More information about the Pypy-commit
mailing list