Author: Antonio Cuni <[email protected]>
Branch: 
Changeset: r45144:b430f6f33eb6
Date: 2011-06-27 18:19 +0200
http://bitbucket.org/pypy/pypy/changeset/b430f6f33eb6/

Log:    (arigo, antocuni): not-optimal improvement: if we have cards, let
        ll_arraycopy to find the young pointers that are maybe there. This
        should help fixing the bad behaviour of list.append on large lists.
        We could improve it even more by copying the cards by ourselves, but
        we cannot right now because we do not know if they are properly
        aligned

diff --git a/pypy/rpython/memory/gc/minimark.py 
b/pypy/rpython/memory/gc/minimark.py
--- a/pypy/rpython/memory/gc/minimark.py
+++ b/pypy/rpython/memory/gc/minimark.py
@@ -1107,8 +1107,11 @@
             return True
         # ^^^ a fast path of write-barrier
         #
-        if (source_hdr.tid & GCFLAG_NO_YOUNG_PTRS == 0 or
-            source_hdr.tid & GCFLAG_CARDS_SET != 0):
+        if source_hdr.tid & GCFLAG_CARDS_SET != 0:
+            # there might be young objects, let ll_arraycopy find them
+            return False
+        #
+        if source_hdr.tid & GCFLAG_NO_YOUNG_PTRS == 0:
             # there might be in source a pointer to a young object
             self.old_objects_pointing_to_young.append(dest_addr)
             dest_hdr.tid &= ~GCFLAG_NO_YOUNG_PTRS
diff --git a/pypy/rpython/memory/gc/test/test_direct.py 
b/pypy/rpython/memory/gc/test/test_direct.py
--- a/pypy/rpython/memory/gc/test/test_direct.py
+++ b/pypy/rpython/memory/gc/test/test_direct.py
@@ -550,6 +550,16 @@
         res = self.gc.writebarrier_before_copy(addr_src, addr_dst)
         assert res # we optimized it
         assert hdr_dst.tid & minimark.GCFLAG_NO_YOUNG_PTRS == 0 # and we 
copied the flag
+        #
+        # in this case, we have cards, so GCFLAG_NO_YOUNG_PTRS is set (because
+        # cards takes precedence over it)
+        hdr_src.tid |= minimark.GCFLAG_NO_YOUNG_PTRS
+        hdr_dst.tid |= minimark.GCFLAG_NO_YOUNG_PTRS
+        hdr_src.tid |= minimark.GCFLAG_CARDS_SET
+        res = self.gc.writebarrier_before_copy(addr_src, addr_dst)
+        assert not res # there might be young ptrs, let ll_arraycopy to find 
them
+        assert hdr_dst.tid & minimark.GCFLAG_NO_YOUNG_PTRS
+
         
 class TestMiniMarkGCFull(DirectGCTest):
     from pypy.rpython.memory.gc.minimark import MiniMarkGC as GCClass
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to