[pypy-svn] r22185 - in pypy/dist/pypy/jit: . test

arigo at codespeak.net arigo at codespeak.net
Sat Jan 14 23:38:21 CET 2006


Author: arigo
Date: Sat Jan 14 23:38:19 2006
New Revision: 22185

Modified:
   pypy/dist/pypy/jit/llabstractinterp.py
   pypy/dist/pypy/jit/test/test_vlist.py
   pypy/dist/pypy/jit/vlist.py
Log:
Virtual lists start to work.


Modified: pypy/dist/pypy/jit/llabstractinterp.py
==============================================================================
--- pypy/dist/pypy/jit/llabstractinterp.py	(original)
+++ pypy/dist/pypy/jit/llabstractinterp.py	Sat Jan 14 23:38:19 2006
@@ -667,6 +667,8 @@
                     raise RestartCompleting
                 a = LLAbstractValue(c)
                 a.concrete = True
+        if hints.get('nonvirtual'):
+            a.forcevarorconst(self)   # for testing only
         return a
 
     def op_direct_call(self, op, *args_a):

Modified: pypy/dist/pypy/jit/test/test_vlist.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_vlist.py	(original)
+++ pypy/dist/pypy/jit/test/test_vlist.py	Sat Jan 14 23:38:19 2006
@@ -36,10 +36,30 @@
     return graph2, summary(interp)
 
 
-def test_newlist():
-    py.test.skip("in-progress")
+def test_fixed_newlistfill_force():
+    def fn(n):
+        lst = [5] * n
+        hint(lst, nonvirtual=True)
+    graph2, insns = run(fn, [12])
+    assert insns == {'direct_call': 13}
+
+def test_newlistfill_force():
     def fn(n):
         lst = [5] * n
-        return len(lst)
+        if n < 0:
+            lst.append(6)
+        hint(lst, nonvirtual=True)
+    graph2, insns = run(fn, [12])
+    assert insns == {'direct_call': 13}
+
+def test_newlist_force():
+    py.test.skip("in-progress")
+    def fn(n):
+        lst = []
+        lst.append(n)
+        lst.append(5)
+        lst.append(12)
+        lst.pop()
+        hint(lst, nonvirtual=True)
     graph2, insns = run(fn, [12])
-    assert insns == {}
+    assert insns == {'direct_call': 3}

Modified: pypy/dist/pypy/jit/vlist.py
==============================================================================
--- pypy/dist/pypy/jit/vlist.py	(original)
+++ pypy/dist/pypy/jit/vlist.py	Sat Jan 14 23:38:19 2006
@@ -1,4 +1,5 @@
 from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.rtyper import LowLevelOpList
 from pypy.jit.llvalue import LLAbstractValue, newvar, const, ll_dummy_value
 from pypy.jit.llcontainer import LLAbstractContainer
 
@@ -38,14 +39,13 @@
         return LLVirtualList(self.T, items_a)
 
     def build_runtime_container(self, builder):
-        cno = const(len(self.items_a))
-        v_result = builder.gendirectcall(self.T.ll_newlist, cno)
-        cdum = const(rlist.dum_nocheck, lltype.Void)
-        for i, a in enumerate(self.items_a):
-            ci = const(i)
-            v_item = a.forcevarorconst(builder)
-            builder.gendirectcall(rlist.ll_setitem_nonneg,
-                                  cdum, v_result, ci, v_item)
+        items_v = [a.forcevarorconst(builder) for a in self.items_a]
+        llop = LowLevelOpList(None)
+        v_result = self.T.list_builder(llop, items_v)
+        print 'list_builder:'
+        for op in llop:
+            print '\t', op
+            builder.residual_operations.append(op)
         return v_result
 
     # ____________________________________________________________
@@ -73,11 +73,11 @@
         return self.items_a.pop(c_index.value)
 
 
-def oop_newlist(op, a_numitems):
+def oop_newlist(op, a_numitems, a_item=ll_dummy_value):
     c_numitems = a_numitems.maybe_get_constant()
     if c_numitems is None:
         raise NotImplementedError
     LIST = op.result.concretetype.TO
-    items_a = [ll_dummy_value] * c_numitems.value
+    items_a = [a_item] * c_numitems.value
     virtuallist = LLVirtualList(LIST, items_a)
     return LLAbstractValue(content=virtuallist)



More information about the Pypy-commit mailing list