Commits

Antonio Cuni committed b430f6f

(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

  • Participants
  • Parent commits 8f476ab

Comments (0)

Files changed (2)

File pypy/rpython/memory/gc/minimark.py

             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

File pypy/rpython/memory/gc/test/test_direct.py

         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