[pypy-svn] r70946 - in pypy/branch/gc-huge-list/pypy/rpython/memory/gc: . test

fijal at codespeak.net fijal at codespeak.net
Thu Jan 28 13:47:58 CET 2010


Author: fijal
Date: Thu Jan 28 13:47:58 2010
New Revision: 70946

Modified:
   pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py
   pypy/branch/gc-huge-list/pypy/rpython/memory/gc/test/test_direct.py
Log:
A test and a bunch of fixes


Modified: pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py	(original)
+++ pypy/branch/gc-huge-list/pypy/rpython/memory/gc/hybrid.py	Thu Jan 28 13:47:58 2010
@@ -676,19 +676,20 @@
             i += 1
 
     def mark_cards(self, addr, start, length):
+        size_gc_header = self.gcheaderbuilder.size_gc_header
         hdr = self.header(addr)
         hdr.tid |= GCFLAG_CARDMARK_SET
         typeid = self.get_type_id(addr)
         itemsize = self.varsize_item_sizes(typeid)
         offset = self.varsize_offset_to_variable_part(typeid) + itemsize * start
-        # XXX check details
         first_card = raw_malloc_usage(offset) / self.card_size
         offset += itemsize * length
         last_card = raw_malloc_usage(offset) / self.card_size
         i = first_card >> 3
-        while i < last_card >> 3:
-            card_adr = addr_struct - size_gc_header + llarena.negative_byte_index(i)
+        while i <= last_card >> 3:
+            card_adr = addr - size_gc_header + llarena.negative_byte_index(i)
             card_adr.char[0] = chr(0xff)
+            i += 1
 
     def _writebarrier_before_copy(self, source_addr, dest_addr, source_start,
                                   dest_start, length):
@@ -702,7 +703,7 @@
                 self.mark_cards(dest_addr, dest_start, length)
                 return
         if source_hdr.tid & GCFLAG_CARDMARK_SET:
-            if dest_hdr.tid & GCFLAG_CARDMARK_SET:
+            if dest_hdr.tid & GCFLAG_CARDMARKS:
                 # large -> large, copy cardmarks.
                 # XXX for now just set all cards within range
                 # that's why we need source_start, possibly

Modified: pypy/branch/gc-huge-list/pypy/rpython/memory/gc/test/test_direct.py
==============================================================================
--- pypy/branch/gc-huge-list/pypy/rpython/memory/gc/test/test_direct.py	(original)
+++ pypy/branch/gc-huge-list/pypy/rpython/memory/gc/test/test_direct.py	Thu Jan 28 13:47:58 2010
@@ -451,6 +451,41 @@
         gc.clean_marked_cards(addr)
         assert objs == [addrp, addrp]
 
+    def test_arraycopy_cardmarking_1(self):
+        from pypy.rpython.lltypesystem import llarena
+        from pypy.rpython.memory.gc.hybrid import GCFLAG_CARDMARKS, \
+             GCFLAG_CARDMARK_SET
+
+        gc = self.gc
+        size_gc_header = gc.gcheaderbuilder.size_gc_header
+        typeid = self.get_type_id(VAR)
+        addr1 = llmemory.cast_ptr_to_adr(gc.malloc_varsize_slowpath(typeid, 48))
+        obj = llmemory.cast_adr_to_ptr(addr1, lltype.Ptr(VAR))
+        self.stackroots.append(obj)
+        addr2 = llmemory.cast_ptr_to_adr(gc.malloc_varsize_slowpath(typeid, 48))
+        # should be precisely 16 cards needed (48/3) + 1 one for length
+        obj2 = llmemory.cast_adr_to_ptr(addr2, lltype.Ptr(VAR))
+        self.stackroots.append(obj2)
+        p = self.malloc(S)
+        addrp = llmemory.cast_ptr_to_adr(p)
+        self.writearray(obj, 0, p)
+        assert gc.header(addr1).tid & GCFLAG_CARDMARK_SET
+        assert gc.header(addr2).tid & GCFLAG_CARDMARK_SET == 0
+        gc.writebarrier_before_copy(addr1, addr2, 0, 0, 48)
+        for i in range(3):
+            addr = addr2 - size_gc_header + llarena.negative_byte_index(i)
+            assert addr.char[0] == '\xff', i
+
+        objs = []
+        def callback(obj, arg):
+            # obj is the address inside 'addr',
+            # so we need to read that array item
+            objs.append(obj.address[0])
+
+        obj2[0] = p
+        gc.foreach_marked_card(addr2, callback, None)
+        assert objs == [addrp]
+        
 class TestMarkCompactGC(DirectGCTest):
     from pypy.rpython.memory.gc.markcompact import MarkCompactGC as GCClass
 



More information about the Pypy-commit mailing list