[pypy-svn] r61923 - in pypy/branch/pyjitpl5/pypy/jit/metainterp: . test
fijal at codespeak.net
fijal at codespeak.net
Sun Feb 15 12:22:09 CET 2009
Author: fijal
Date: Sun Feb 15 12:22:09 2009
New Revision: 61923
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tlc.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtual.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vlist.py
Log:
Initialize virtual list. A bit suboptimal, but makes test_tlc pass
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/optimize.py Sun Feb 15 12:22:09 2009
@@ -151,6 +151,7 @@
d.update(self.origfields)
else:
d = other.curfields
+ d = other.curfields
lst = d.items()
lst.sort()
for ofs, node in lst:
@@ -296,6 +297,8 @@
instnode = InstanceNode(box, escaped=False)
self.nodes[box] = instnode
self.first_escaping_op = False
+ # XXX we don't support lists with variable length
+ assert isinstance(op.args[1], ConstInt)
instnode.known_length = op.args[1].getint()
# XXX following guard_builtin will set the
# correct class, otherwise it's a mess
@@ -603,7 +606,11 @@
assert isinstance(instnode.cls.source, ListDescr)
if not instnode.escaped:
instnode.virtual = True
- assert isinstance(instnode.cls.source, ListDescr)
+ for i in range(instnode.known_length):
+ instnode.curfields[i] = InstanceNode(op.args[2],
+ const=True)
+ for ofs, item in instnode.origfields.items():
+ self.nodes[item.source] = instnode.curfields[ofs]
continue
elif opname == 'setfield_gc':
instnode = self.nodes[op.args[0]]
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tlc.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tlc.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_tlc.py Sun Feb 15 12:22:09 2009
@@ -44,7 +44,6 @@
assert res == 42
def test_accumulator(self):
- py.test.skip("bugs")
path = py.path.local(tlc.__file__).dirpath('accumulator.tlc.src')
code = path.read()
res = self.exec_code(code, 20)
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtual.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtual.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_virtual.py Sun Feb 15 12:22:09 2009
@@ -168,12 +168,6 @@
res = self.meta_interp(f, [20])
assert res == 9
- #def test_virtual_and_only_setfield(self):
- # myjitdriver = JitDriver(greens = [], reds = ['n', 'i'])
-
- # def f(n):
-
-
##class TestOOtype(VirtualTests, OOJitMixin):
## _new = staticmethod(ootype.new)
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vlist.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vlist.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_vlist.py Sun Feb 15 12:22:09 2009
@@ -60,6 +60,24 @@
# one setitem should be gone by now
self.check_loops(newlist=1, setitem=1, getitem=1)
+ def test_vlist_with_default_read(self):
+ jitdriver = JitDriver(greens = [], reds = ['n'])
+ def f(n):
+ l = [1] * 20
+ while n > 0:
+ jitdriver.can_enter_jit(n=n)
+ jitdriver.jit_merge_point(n=n)
+ l = [0] * 20
+ x = l[3]
+ if n < 3:
+ return x
+ n -= 1
+ return l[0]
+
+ res = self.meta_interp(f, [10])
+ assert res == f(10)
+
+
def test_append_pop(self):
py.test.skip("XXX")
def f(n):
More information about the Pypy-commit
mailing list