Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r134:1f6dfc74a907
Date: 2013-06-15 18:04 +0200
http://bitbucket.org/pypy/stmgc/changeset/1f6dfc74a907/

Log:    Test fixes

diff --git a/c4/dbgmem.c b/c4/dbgmem.c
--- a/c4/dbgmem.c
+++ b/c4/dbgmem.c
@@ -67,6 +67,8 @@
 
 void stm_free(void *p, size_t sz)
 {
+    assert(((intptr_t)((char *)p + sz) & (PAGE_SIZE-1)) == 0);
+
     size_t nb_pages = (sz + PAGE_SIZE - 1) / PAGE_SIZE + 1;
     long i, base = ((char *)p - zone_start) / PAGE_SIZE;
     assert(0 <= base && base < (MMAP_TOTAL / PAGE_SIZE));
diff --git a/c4/et.c b/c4/et.c
--- a/c4/et.c
+++ b/c4/et.c
@@ -402,7 +402,7 @@
   assert(!(P->h_tid & GCFLAG_STUB));
   assert(!(P->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED));
 
-  B = stmgc_duplicate(P);
+  B = stmgc_duplicate_old(P);
   B->h_tid |= GCFLAG_BACKUP_COPY;
 
   P->h_tid |= GCFLAG_PRIVATE_FROM_PROTECTED;
@@ -989,7 +989,7 @@
         }
       else
         {
-          //stm_free(B, stmcb_size(B));
+          stm_free(B, stmcb_size(B));
         }
     };
   gcptrlist_clear(&d->private_from_protected);
@@ -1011,8 +1011,8 @@
         {
           assert(!(B->h_tid & GCFLAG_BACKUP_COPY));
           P->h_tid &= ~GCFLAG_PRIVATE_FROM_PROTECTED;
-          P->h_tid |= GCFLAG_PUBLIC;      abort();
-          /* P becomes a public outdated object */
+          P->h_tid |= GCFLAG_PUBLIC;
+          /* P becomes a public (possibly young) outdated object */
         }
       else
         {
diff --git a/c4/nursery.c b/c4/nursery.c
--- a/c4/nursery.c
+++ b/c4/nursery.c
@@ -62,6 +62,15 @@
     return L;
 }
 
+gcptr stmgc_duplicate_old(gcptr P)
+{
+    size_t size = stmcb_size(P);
+    gcptr L = (gcptr)stm_malloc(size);
+    memcpy(L, P, size);
+    L->h_tid |= GCFLAG_OLD;
+    return L;
+}
+
 /************************************************************/
 
 static inline gcptr create_old_object_copy(gcptr obj)
diff --git a/c4/nursery.h b/c4/nursery.h
--- a/c4/nursery.h
+++ b/c4/nursery.h
@@ -20,5 +20,6 @@
 void stmgc_minor_collect(void);
 int stmgc_minor_collect_anything_to_do(struct tx_descriptor *);
 gcptr stmgc_duplicate(gcptr);
+gcptr stmgc_duplicate_old(gcptr);
 
 #endif
diff --git a/c4/test/test_et.py b/c4/test/test_et.py
--- a/c4/test/test_et.py
+++ b/c4/test/test_et.py
@@ -70,7 +70,7 @@
     assert pback and pback != p
     assert pback.h_revision == org_r
     assert pback.h_tid == ((p.h_tid & ~GCFLAG_PRIVATE_FROM_PROTECTED) |
-                           GCFLAG_BACKUP_COPY)
+                           GCFLAG_BACKUP_COPY | GCFLAG_OLD)
     assert lib.rawgetlong(pback, 0) == 78927812
     assert lib.rawgetlong(p, 0) == 927122
     assert classify(p) == "private_from_protected"
@@ -292,6 +292,10 @@
         assert classify(p) == "public"
         assert classify(p1) == "private"
         lib.rawsetlong(p1, 0, 2782172)
+        minor_collect()
+        check_nursery_free(p1)
+        p1 = lib.stm_read_barrier(p)
+        assert p1.h_tid & GCFLAG_OLD
         pback_ = []
 
         def cb(c):
@@ -378,17 +382,21 @@
 def test_abort_stealing_while_modifying():
     test_stealing_while_modifying(aborting=True)
 
-def test_stub_for_refs_from_stolen():
+def test_stub_for_refs_from_stolen(old=False):
     p = palloc_refs(1)
     qlist = []
     def f1(r):
+        q1 = nalloc(HDR + WORD)
+        if old:
+            lib.stm_push_root(q1)
+            minor_collect()
+            q1 = lib.stm_pop_root()
         assert (p.h_tid & GCFLAG_PUBLIC_TO_PRIVATE) == 0
         p1 = lib.stm_write_barrier(p)   # private copy
         assert p1 != p
         assert classify(p) == "public"
         assert classify(p1) == "private"
         assert p.h_tid & GCFLAG_PUBLIC_TO_PRIVATE
-        q1 = nalloc(HDR + WORD)
         qlist.append(q1)
         lib.setlong(q1, 0, -29187)
         lib.setptr(p1, 0, q1)
@@ -412,7 +420,11 @@
         assert q2.h_revision % 4 == 2
         q3 = lib.stm_read_barrier(q2)
         assert q3 != q2
-        assert q3 == qlist[0]
+        if old:
+            assert q3 == qlist[0]
         assert classify(q3) == "public"   # has been stolen
         assert lib.getlong(q3, 0) == -29187
     run_parallel(f1, f2)
+
+def test_stub_for_refs_from_stolen_old():
+    test_stub_for_refs_from_stolen(old=True)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to