[pypy-commit] pypy gc-minimark-pinning: finish support for pinned objects with shadows

fijal noreply at buildbot.pypy.org
Fri Apr 20 19:48:02 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: gc-minimark-pinning
Changeset: r54595:13aecb5e5a44
Date: 2012-04-20 19:44 +0200
http://bitbucket.org/pypy/pypy/changeset/13aecb5e5a44/

Log:	finish support for pinned objects with shadows

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
@@ -1262,6 +1262,12 @@
                 self.old_objects_with_cards_set.append(dest_addr)
                 dest_hdr.tid |= GCFLAG_CARDS_SET
 
+    def record_pinned_object(self, obj, new_dict):
+        obj = obj + self.gcheaderbuilder.size_gc_header
+        shadow = self.nursery_objects_shadows.get(obj)
+        if shadow != NULL:
+            new_dict.setitem(obj, shadow)
+
     # ----------
     # Nursery collection
 
@@ -1318,7 +1324,14 @@
         #
         # Clear this mapping.
         if self.nursery_objects_shadows.length() > 0:
-            self.nursery_objects_shadows.clear()
+            if self.surviving_pinned_objects.non_empty():
+                new_shadows = self.AddressDict()
+                self.surviving_pinned_objects.foreach(self.record_pinned_object,
+                                                      new_shadows)
+                self.nursery_objects_shadows.delete()
+                self.nursery_objects_shadows = new_shadows
+            else:
+                self.nursery_objects_shadows.clear()
         #
         # Walk the list of young raw-malloced objects, and either free
         # them or make them old.
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
@@ -542,9 +542,11 @@
         self.gc.pin(llmemory.cast_ptr_to_adr(s))
         self.gc.minor_collection(1)
         self.gc.unpin(llmemory.cast_ptr_to_adr(s))
-        self.gc.minor_collection(1)
         assert self.gc.nursery_free != self.gc.nursery
         # we still have a pinned object
+        self.gc.minor_collection(1)
+        assert self.gc.nursery_free == self.gc.nursery
+        # we don't have a pinned object any more
 
     def test_writebarrier_before_copy(self):
         from pypy.rpython.memory.gc import minimark


More information about the pypy-commit mailing list