[pypy-commit] stmgc default: gcpage: private_from_protected

arigo noreply at buildbot.pypy.org
Thu Jun 20 15:59:38 CEST 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r209:1156c468afdd
Date: 2013-06-20 15:59 +0200
http://bitbucket.org/pypy/stmgc/changeset/1156c468afdd/

Log:	gcpage: private_from_protected

diff --git a/c4/gcpage.c b/c4/gcpage.c
--- a/c4/gcpage.c
+++ b/c4/gcpage.c
@@ -199,12 +199,12 @@
         return;    /* already seen */
 
     if (obj->h_revision & 1) {
+        assert(!(obj->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED));
         obj->h_tid &= ~GCFLAG_PUBLIC_TO_PRIVATE;  /* see also fix_outdated() */
     }
-    else {
+    else if (obj->h_tid & GCFLAG_PUBLIC) {
         /* h_revision is a ptr: we have a more recent version */
         gcptr prev_obj = obj;
-        assert(obj->h_tid & GCFLAG_PUBLIC);
 
         if (!(obj->h_revision & 2)) {
             /* go visit the more recent version */
@@ -236,6 +236,19 @@
         *pobj = obj;
         goto restart;
     }
+    else {
+        assert(obj->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED);
+        gcptr B = (gcptr)obj->h_revision;
+        if (!(B->h_tid & GCFLAG_PUBLIC)) {
+            /* a regular private_from_protected object with a backup copy B */
+            assert(B->h_tid & GCFLAG_BACKUP_COPY);
+            B->h_tid |= GCFLAG_VISITED;
+        }
+        else {
+            assert(!(B->h_tid & GCFLAG_BACKUP_COPY));
+            abort();  // XXX
+        }
+    }
     obj->h_tid |= GCFLAG_VISITED;
     gcptrlist_insert(&objects_to_trace, obj);
 }
@@ -335,7 +348,8 @@
            just removing it is very wrong --- we want 'd' to abort.
         */
         revision_t v = obj->h_revision;
-        if (IS_POINTER(v)) {    /* has a more recent revision.  Oups. */
+        if (IS_POINTER(v) && !(obj->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED)) {
+            /* has a more recent revision.  Oups. */
             fprintf(stderr,
                     "ABRT_COLLECT_MAJOR: %p was read but modified already\n",
                     obj);
diff --git a/c4/test/test_gcpage.py b/c4/test/test_gcpage.py
--- a/c4/test/test_gcpage.py
+++ b/c4/test/test_gcpage.py
@@ -295,3 +295,21 @@
     p1 = lib.stm_pop_root()
     assert not lib.in_nursery(p1)
     check_not_free(p1)
+
+def test_private_from_protected_young():
+    p1 = nalloc(HDR)
+    lib.stm_commit_transaction()
+    lib.stm_begin_inevitable_transaction()
+    p1b = lib.stm_write_barrier(p1)
+    assert p1b == p1
+    check_not_free(follow_revision(p1))
+    assert follow_revision(p1).h_tid & GCFLAG_BACKUP_COPY
+    lib.stm_push_root(p1)
+    major_collect()
+    p1 = lib.stm_pop_root()
+    assert not lib.in_nursery(p1)
+    check_not_free(p1)
+    p1b = lib.stm_write_barrier(p1)
+    assert p1b == p1
+    check_not_free(follow_revision(p1))
+    assert follow_revision(p1).h_tid & GCFLAG_BACKUP_COPY


More information about the pypy-commit mailing list