[pypy-svn] r65405 - pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test
antocuni at codespeak.net
antocuni at codespeak.net
Mon May 25 10:34:19 CEST 2009
Author: antocuni
Date: Mon May 25 10:34:18 2009
New Revision: 65405
Modified:
pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/oparser.py
pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_oparser.py
pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py
Log:
start to port test_optimize2.py to ootype
Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/oparser.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/oparser.py (original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/oparser.py Mon May 25 10:34:18 2009
@@ -4,9 +4,10 @@
"""
from pypy.jit.metainterp.history import TreeLoop, BoxInt, BoxPtr, ConstInt,\
- ConstAddr
+ ConstAddr, ConstObj
from pypy.jit.metainterp.resoperation import rop, ResOperation
from pypy.rpython.lltypesystem import lltype, llmemory
+from pypy.rpython.ootypesystem import ootype
_cache = {}
@@ -14,11 +15,12 @@
pass
class OpParser(object):
- def __init__(self, descr, cpu, namespace):
+ def __init__(self, descr, cpu, namespace, type_system):
self.descr = descr
self.vars = {}
self.cpu = cpu
self.consts = namespace
+ self.type_system = type_system
def box_for_var(self, elem):
try:
@@ -50,10 +52,13 @@
try:
return ConstInt(int(arg))
except ValueError:
- if arg.startswith('ConstAddr('):
- name = arg[len('ConstAddr('):-1]
- return ConstAddr(llmemory.cast_ptr_to_adr(self.consts[name]),
- self.cpu)
+ if arg.startswith('ConstClass('):
+ name = arg[len('ConstClass('):-1]
+ if self.type_system == 'lltype':
+ return ConstAddr(llmemory.cast_ptr_to_adr(self.consts[name]),
+ self.cpu)
+ else:
+ return ConstObj(ootype.cast_to_object(self.consts[name]))
return self.vars[arg]
def parse_op(self, line):
@@ -162,5 +167,5 @@
inpargs = self.parse_header_line(line[1:-1])
return base_indent, inpargs
-def parse(descr, cpu=None, namespace={}):
- return OpParser(descr, cpu, namespace).parse()
+def parse(descr, cpu=None, namespace={}, type_system='lltype'):
+ return OpParser(descr, cpu, namespace, type_system).parse()
Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_oparser.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_oparser.py (original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_oparser.py Mon May 25 10:34:18 2009
@@ -22,7 +22,7 @@
def test_const_ptr_subops():
x = """
[p0]
- guard_class(p0, ConstAddr(vtable))
+ guard_class(p0, ConstClass(vtable))
fail()
"""
S = lltype.Struct('S')
Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py (original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/metainterp/test/test_optimize2.py Mon May 25 10:34:18 2009
@@ -42,6 +42,7 @@
return True
class LLtypeMixin(object):
+ type_system = 'lltype'
node_vtable = lltype.malloc(OBJECT_VTABLE, immortal=True)
node_vtable_adr = llmemory.cast_ptr_to_adr(node_vtable)
@@ -72,6 +73,8 @@
namespace = locals()
class OOtypeMixin(object):
+ type_system = 'ootype'
+
cpu = runner.OOtypeCPU(None)
NODE = ootype.Instance('NODE', ootype.ROOT, {})
@@ -85,13 +88,32 @@
nodebox = BoxObj(ootype.cast_to_object(node))
nodedescr = cpu.fielddescrof(NODE, 'value')
+ TP = ootype.Array(ootype.Signed)
+
+ XY = ootype.Instance('XY', ootype.ROOT,
+ {'inst_field': ootype.Signed,
+ 'inst_other_field': ootype.Signed,
+ 'inst_list': TP},
+ _hints = {'virtualizable2': True,
+ 'virtuals': ('field','list')})
+
+ field_desc = cpu.fielddescrof(XY, 'inst_field')
+ array_descr = cpu.arraydescrof(TP)
+ list_desc = cpu.fielddescrof(XY, 'inst_list')
+ other_field_desc = cpu.fielddescrof(XY, 'inst_other_field')
+ vdesc = VirtualizableDesc(cpu, XY, XY)
+
namespace = locals()
class BaseTestOptimize2(object):
+ def parse(self, s):
+ return parse(s, self.cpu, self.namespace,
+ type_system=self.type_system)
+
def optimize(self, lst, optimizations_enabled=[]):
if not isinstance(lst, TreeLoop):
- loop = parse(lst, self.cpu, self.namespace)
+ loop = self.parse(lst)
else:
loop = lst
optimize_loop(None, [], loop, self.cpu,
@@ -99,8 +121,7 @@
return loop.operations
def assert_equal(self, optimized, expected):
- equaloplists(optimized,
- parse(expected, self.cpu, self.namespace).operations)
+ equaloplists(optimized, self.parse(expected).operations)
def test_basic_constant_folding(self):
pre_op = """
@@ -113,14 +134,14 @@
def test_remove_guard_class(self):
pre_op = """
[p0]
- guard_class(p0, ConstAddr(node_vtable))
+ guard_class(p0, ConstClass(node_vtable))
fail()
- guard_class(p0, ConstAddr(node_vtable))
+ guard_class(p0, ConstClass(node_vtable))
fail()
"""
expected = """
[p0]
- guard_class(p0, ConstAddr(node_vtable))
+ guard_class(p0, ConstClass(node_vtable))
fail()
"""
self.assert_equal(self.optimize(pre_op,
@@ -290,5 +311,11 @@
pass
class TestOOtype(OOtypeMixin, BaseTestOptimize2):
- def setup_class(cls):
- py.test.skip("XXX Fix me")
+
+ def skip(self):
+ py.test.skip('in-progress')
+
+ test_basic_virtualizable = skip
+ test_virtualizable_setfield_rebuild_ops = skip
+ test_virtualized_list_on_virtualizable = skip
+ test_virtualized_list_on_virtualizable_2 = skip
More information about the Pypy-commit
mailing list