Author: Armin Rigo <[email protected]>
Branch: c7-refactor
Changeset: r840:ebb32fe35923
Date: 2014-02-24 17:33 +0100
http://bitbucket.org/pypy/stmgc/changeset/ebb32fe35923/

Log:    in-progress

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -13,12 +13,12 @@
 {
     assert(_running_transaction());
     assert(!_is_in_nursery(obj));
-    dprintf(("write_slowpath %p\n", obj));
 
     /* is this an object from the same transaction, outside the nursery? */
     if ((obj->stm_flags & -GCFLAG_OVERFLOW_NUMBER_bit0) ==
             STM_PSEGMENT->overflow_number) {
 
+        dprintf_test(("write_slowpath %p -> ovf_obj\n", obj));
         obj->stm_flags &= ~GCFLAG_WRITE_BARRIER;
         assert(STM_PSEGMENT->overflow_objects_pointing_to_nursery != NULL);
         LIST_APPEND(STM_PSEGMENT->overflow_objects_pointing_to_nursery, obj);
@@ -43,6 +43,8 @@
                                                    0, lock_num)))
             goto retry;
 
+        dprintf_test(("write_slowpath %p -> mod_old\n", obj));
+
         /* First change to this old object from this transaction.
            Add it to the list 'modified_old_objects'. */
         LIST_APPEND(STM_PSEGMENT->modified_old_objects, obj);
@@ -97,8 +99,10 @@
     /* A common case for write_locks[] that was either 0 or lock_num:
        we need to add the object to 'old_objects_pointing_to_nursery'
        if there is such a list. */
-    if (STM_PSEGMENT->old_objects_pointing_to_nursery != NULL)
+    if (STM_PSEGMENT->old_objects_pointing_to_nursery != NULL) {
+        dprintf_test(("write_slowpath %p -> old_obj_pointing_to_nurs\n", obj));
         LIST_APPEND(STM_PSEGMENT->old_objects_pointing_to_nursery, obj);
+    }
 
     /* add the write-barrier-already-called flag ONLY if we succeeded in
        getting the write-lock */
diff --git a/c7/stm/fprintcolor.h b/c7/stm/fprintcolor.h
--- a/c7/stm/fprintcolor.h
+++ b/c7/stm/fprintcolor.h
@@ -12,14 +12,21 @@
 static int threadcolor_printf(const char *format, ...)
      __attribute__((format (printf, 1, 2)));
 
+#ifdef STM_TESTS
+#  define dprintf_test(args)   dprintf(args)
+#else
+#  define dprintf_test(args)   do { } while(0)
+#endif
+
 
 /* ------------------------------------------------------------ */
 #else
 /* ------------------------------------------------------------ */
 
 
-#define dprintf(args)   do { } while(0)
-#define dprintfcolor()  0
+#define dprintf(args)        do { } while(0)
+#define dprintf_test(args)   do { } while(0)
+#define dprintfcolor()       0
 
 
 /* ------------------------------------------------------------ */
diff --git a/c7/test/test_nursery.py b/c7/test/test_nursery.py
--- a/c7/test/test_nursery.py
+++ b/c7/test/test_nursery.py
@@ -3,41 +3,11 @@
 
 class TestBasic(BaseTest):
 
-    def test_align_nursery_to_256_bytes(self):
+    def test_nursery_large(self):
+        py.test.skip("XXX later")
         self.start_transaction()
-        lp1 = stm_allocate(16)
-        self.commit_transaction()
-        self.start_transaction()
-        lp2 = stm_allocate(16)
-        #
-        u1 = int(ffi.cast("uintptr_t", lp1))
-        u2 = int(ffi.cast("uintptr_t", lp2))
-        assert (u1 & ~255) != (u2 & ~255)
-
-    def test_creation_marker_in_nursery(self):
-        self.start_transaction()
-        lp1 = stm_allocate(16)
-        lp2 = stm_allocate(16)
-        assert stm_creation_marker(lp1) == 0xff
-        assert stm_creation_marker(lp2) == 0xff
-        u1 = int(ffi.cast("uintptr_t", lp1))
-        u2 = int(ffi.cast("uintptr_t", lp2))
-        assert u2 == u1 + 16
-        self.commit_transaction()
-
-        assert stm_creation_marker(lp1) == 0
-        assert stm_creation_marker(lp2) == 0
-
-        self.start_transaction()
-        lp3 = stm_allocate(16)
-        assert stm_creation_marker(lp1) == 0
-        assert stm_creation_marker(lp2) == 0
-        assert stm_creation_marker(lp3) == 0xff
-
-    def test_nursery_medium(self):
-        self.start_transaction()
-        lp1 = stm_allocate(SOME_MEDIUM_SIZE)
-        lp2 = stm_allocate(SOME_MEDIUM_SIZE)
+        lp1 = stm_allocate(SOME_LARGE_SIZE)
+        lp2 = stm_allocate(SOME_LARGE_SIZE)
 
         u1 = int(ffi.cast("uintptr_t", lp1))
         u2 = int(ffi.cast("uintptr_t", lp2))
@@ -51,27 +21,27 @@
         assert stm_creation_marker(lp2) == 0
 
     def test_nursery_full(self):
-        lib._stm_set_nursery_free_count((SOME_MEDIUM_SIZE + 255) & ~255)
+        lib._stm_set_nursery_free_count(2048)
+        self.start_transaction()
         self.push_root_no_gc()
-        self.start_transaction()
-        lp1 = stm_allocate(SOME_MEDIUM_SIZE)
+        lp1 = stm_allocate(2048)    # no collection here
         self.pop_root()
         #
         self.push_root(lp1)
-        lp2 = stm_allocate(SOME_MEDIUM_SIZE)
+        lp2 = stm_allocate(2048)
         lp1b = self.pop_root()
         assert lp1b != lp1      # collection occurred
 
     def test_several_minor_collections(self):
         # make a long, ever-growing linked list of objects, in one transaction
-        lib._stm_set_nursery_free_count(NURSERY_SECTION_SIZE * 2)
+        lib._stm_set_nursery_free_count(2048)
         self.start_transaction()
         lp1 = stm_allocate_refs(1)
         self.push_root(lp1)
         prev = lp1
         prevprev = None
-        FIT = (NURSERY_SECTION_SIZE * 2) / 16 - 1   # without 'lp1' above
-        N = (NURSERY_SECTION_SIZE * 4) / 16 + 41
+        FIT = 2048 / 16 - 1   # without 'lp1' above
+        N = 4096 / 16 + 41
         for i in range(N):
             if prevprev:
                 assert stm_get_ref(prevprev, 0) == prev
@@ -83,15 +53,20 @@
                 prevprev = self.pop_root()
                 assert prevprev != prev
             stm_set_ref(prev, 0, lp3)
+
+            assert modified_old_objects() == []    # only 1 transaction
+            ovf_o = overflow_objects_pointing_to_nursery()
+            old_o = old_objects_pointing_to_nursery()
+            if i < FIT:
+                assert ovf_o is None      # no minor collection so far
+                assert old_o is None      # no minor collection so far
+            else:
+                assert len(ovf_o) == 1
+                assert old_o == []
+
             prevprev = prev
             prev = lp3
 
-            seeme = old_objects_pointing_to_young()
-            if i < FIT:
-                assert len(seeme) == 0    # no minor collection so far
-            else:
-                assert len(seeme) == 1    # the one from the prev minor coll
-
         lp1 = self.pop_root()
         assert modified_objects() == []
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to