[pypy-commit] pypy gc-minimark-pinning: rpython fixes and transformed test

fijal noreply at buildbot.pypy.org
Fri Apr 13 18:21:58 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: gc-minimark-pinning
Changeset: r54338:0ac3b06d13d8
Date: 2012-04-13 17:23 +0200
http://bitbucket.org/pypy/pypy/changeset/0ac3b06d13d8/

Log:	rpython fixes and transformed test

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
@@ -247,8 +247,6 @@
         self.nursery_top  = NULL
         self.debug_tiny_nursery = -1
         self.debug_rotating_nurseries = None
-        self.surviving_pinned_objects = NULL
-        self.nursery_barriers = NULL
         #
         # The ArenaCollection() handles the nonmovable objects allocation.
         if ArenaCollectionClass is None:
@@ -452,7 +450,7 @@
 
     def debug_rotate_nursery(self):
         if self.debug_rotating_nurseries is not None:
-            ll_assert(self.nursery_barriers.empty(), "non empty nursery barriers with rotating nursery")
+            ll_assert(not self.nursery_barriers.non_empty(), "non empty nursery barriers with rotating nursery")
             debug_start("gc-debug")
             oldnurs = self.nursery
             llarena.arena_protect(oldnurs, self._nursery_memory_size(), True)
@@ -1339,7 +1337,6 @@
             nursery_barriers.append(next)
         llarena.arena_reset(prev, self.nursery_top - prev, 2)
         self.surviving_pinned_objects.delete()
-        self.surviving_pinned_objects = NULL
         self.nursery_barriers = nursery_barriers
         self.debug_rotate_nursery()
         self.nursery_free = self.nursery
diff --git a/pypy/rpython/memory/test/test_transformed_gc.py b/pypy/rpython/memory/test/test_transformed_gc.py
--- a/pypy/rpython/memory/test/test_transformed_gc.py
+++ b/pypy/rpython/memory/test/test_transformed_gc.py
@@ -43,6 +43,7 @@
     gcpolicy = None
     GC_CAN_MOVE = False
     GC_CAN_MALLOC_NONMOVABLE = True
+    GC_CAN_ALWAYS_PIN = False
     taggedpointers = False
 
     def setup_class(cls):
@@ -726,6 +727,28 @@
         res = fn([])
         assert res == ord('y')
 
+    def define_pinning(cls):
+        def f(i, j):
+            s = str(i)
+            if not rgc.can_move(s):
+                return 13
+            sum = 0
+            with rgc.pinned_object(s):
+                sum += int(rgc.can_move(s))
+            sum += 10 * int(rgc.can_move(s))
+            return sum
+        return f
+
+    def test_pinning(self):
+        res = self.runner("pinning")([10, 0])
+        if not self.GC_CAN_MOVE:
+            assert res == 13
+        elif self.GC_CAN_ALWAYS_PIN:
+            assert res == 10
+        else:
+            assert res == 11 or res == 13 # sometimes fresh objs can't move
+
+
 class GenericMovingGCTests(GenericGCTests):
     GC_CAN_MOVE = True
     GC_CAN_MALLOC_NONMOVABLE = False
@@ -1273,6 +1296,7 @@
 class TestMiniMarkGC(TestHybridGC):
     gcname = "minimark"
     GC_CAN_TEST_ID = True
+    GC_CAN_ALWAYS_PIN = True
 
     class gcpolicy(gc.FrameworkGcPolicy):
         class transformerclass(framework.FrameworkGCTransformer):


More information about the pypy-commit mailing list