[pypy-svn] r69852 - in pypy/branch/listcopyop/pypy/rpython: lltypesystem memory/test

fijal at codespeak.net fijal at codespeak.net
Wed Dec 2 18:00:24 CET 2009


Author: fijal
Date: Wed Dec  2 18:00:23 2009
New Revision: 69852

Modified:
   pypy/branch/listcopyop/pypy/rpython/lltypesystem/lloperation.py
   pypy/branch/listcopyop/pypy/rpython/lltypesystem/opimpl.py
   pypy/branch/listcopyop/pypy/rpython/memory/test/test_gc.py
Log:
Add a copy list operation. Right now it does not do anything special at all


Modified: pypy/branch/listcopyop/pypy/rpython/lltypesystem/lloperation.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/lltypesystem/lloperation.py	(original)
+++ pypy/branch/listcopyop/pypy/rpython/lltypesystem/lloperation.py	Wed Dec  2 18:00:23 2009
@@ -358,6 +358,7 @@
     'resize_buffer':        LLOp(canraise=(MemoryError,), canunwindgc=True),
     'finish_building_buffer' : LLOp(canraise=(MemoryError,), canunwindgc=True),
     'zero_gc_pointers_inside': LLOp(),
+    'listcopy':             LLOp(canrun=True),
     'free':                 LLOp(),
     'getfield':             LLOp(sideeffects=False, canrun=True),
     'getarrayitem':         LLOp(sideeffects=False, canrun=True),

Modified: pypy/branch/listcopyop/pypy/rpython/lltypesystem/opimpl.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/lltypesystem/opimpl.py	(original)
+++ pypy/branch/listcopyop/pypy/rpython/lltypesystem/opimpl.py	Wed Dec  2 18:00:23 2009
@@ -394,6 +394,10 @@
     checkadr(addr2)
     return addr1 - addr2
 
+def op_listcopy(source, dest, source_start, dest_start, length):
+    for i in range(length):
+        dest[i + dest_start] = source[i + source_start]
+
 def op_getfield(p, name):
     checkptr(p)
     TYPE = lltype.typeOf(p).TO

Modified: pypy/branch/listcopyop/pypy/rpython/memory/test/test_gc.py
==============================================================================
--- pypy/branch/listcopyop/pypy/rpython/memory/test/test_gc.py	(original)
+++ pypy/branch/listcopyop/pypy/rpython/memory/test/test_gc.py	Wed Dec  2 18:00:23 2009
@@ -551,6 +551,19 @@
         res = self.interpret(fn, [-1000], taggedpointers=True)
         assert res == 111
 
+    def test_listcopy(self):
+        TP = lltype.GcArray(lltype.Signed)
+        def fn():
+            l = lltype.malloc(TP, 100)
+            for i in range(100):
+                l[i] = 1
+            l2 = lltype.malloc(TP, 50)
+            llop.listcopy(lltype.Void, l, l2, 50, 0, 50)
+            for i in range(50):
+                assert l2[i] == 1
+
+        self.interpret(fn, [])
+
 
 from pypy.rlib.objectmodel import UnboxedValue
 



More information about the Pypy-commit mailing list