[pypy-commit] pypy default: Tweak ll_arraycopy() to fix again the issue of the missing arraydescr

arigo noreply at buildbot.pypy.org
Sun Oct 28 18:46:12 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r58540:a18331247b12
Date: 2012-10-28 18:45 +0100
http://bitbucket.org/pypy/pypy/changeset/a18331247b12/

Log:	Tweak ll_arraycopy() to fix again the issue of the missing
	arraydescr among the calldescr.get_extra_info().

diff --git a/pypy/rlib/objectmodel.py b/pypy/rlib/objectmodel.py
--- a/pypy/rlib/objectmodel.py
+++ b/pypy/rlib/objectmodel.py
@@ -188,7 +188,7 @@
         src = py.code.Source("""
             def %(name)s(%(arglist)s):
                 if not we_are_translated():
-                    typecheck(%(arglist)s)
+                    typecheck(%(arglist)s)    # pypy.rlib.objectmodel
                 return %(name)s_original(%(arglist)s)
         """ % dict(name=f.func_name, arglist=arglist))
         #
diff --git a/pypy/rlib/rgc.py b/pypy/rlib/rgc.py
--- a/pypy/rlib/rgc.py
+++ b/pypy/rlib/rgc.py
@@ -145,8 +145,11 @@
     from pypy.rlib.objectmodel import keepalive_until_here
 
     # XXX: Hack to ensure that we get a proper effectinfo.write_descrs_arrays
-    if NonConstant(False):
-        dest[dest_start] = source[source_start]
+    # and also, maybe, speed up very small cases
+    if length <= 1:
+        if length == 1:
+            dest[dest_start] = source[source_start]
+        return
 
     # supports non-overlapping copies only
     if not we_are_translated():
diff --git a/pypy/rlib/test/test_rgc.py b/pypy/rlib/test/test_rgc.py
--- a/pypy/rlib/test/test_rgc.py
+++ b/pypy/rlib/test/test_rgc.py
@@ -134,6 +134,23 @@
 
     assert check.called
 
+def test_ll_arraycopy_small():
+    TYPE = lltype.GcArray(lltype.Signed)
+    for length in range(5):
+        a1 = lltype.malloc(TYPE, 10)
+        a2 = lltype.malloc(TYPE, 6)
+        org1 = range(20, 30)
+        org2 = range(50, 56)
+        for i in range(len(a1)): a1[i] = org1[i]
+        for i in range(len(a2)): a2[i] = org2[i]
+        rgc.ll_arraycopy(a1, a2, 4, 2, length)
+        for i in range(10):
+            assert a1[i] == org1[i]
+        for i in range(6):
+            if 2 <= i < 2 + length:
+                assert a2[i] == a1[i+2]
+            else:
+                assert a2[i] == org2[i]
 
 
 def test_ll_shrink_array_1():


More information about the pypy-commit mailing list