Author: Remi Meier <meier...@student.ethz.ch>
Branch: copy-over-original
Changeset: r392:ea61566d33cd
Date: 2013-07-11 12:12 +0200
http://bitbucket.org/pypy/stmgc/changeset/ea61566d33cd/

Log:    free objects that are copied over prebuilts in the same major
        collection

diff --git a/c4/gcpage.c b/c4/gcpage.c
--- a/c4/gcpage.c
+++ b/c4/gcpage.c
@@ -223,6 +223,7 @@
             id_copy->h_tid &= ~GCFLAG_PUBLIC_TO_PRIVATE;
             /* see fix_outdated() */
             id_copy->h_tid |= GCFLAG_VISITED;
+            assert(id_copy->h_tid & GCFLAG_OLD);
 
             /* XXX: may not always need tracing? */
             if (!(id_copy->h_tid & GCFLAG_STUB))
@@ -249,6 +250,7 @@
         if (!(obj->h_tid & GCFLAG_VISITED)) {
             obj->h_tid &= ~GCFLAG_PUBLIC_TO_PRIVATE;  /* see fix_outdated() */
             obj->h_tid |= GCFLAG_VISITED;
+            assert(obj->h_tid & GCFLAG_OLD);
             gcptrlist_insert(&objects_to_trace, obj);
 
             keep_original_alive(obj);
@@ -272,6 +274,7 @@
             obj = (gcptr)(obj->h_revision - 2);
             if (!(obj->h_tid & GCFLAG_PUBLIC)) {
                 prev_obj->h_tid |= GCFLAG_VISITED;
+                assert(prev_obj->h_tid & GCFLAG_OLD);
                 keep_original_alive(prev_obj);
 
                 assert(*pobj == prev_obj);
@@ -315,6 +318,9 @@
         
         obj->h_tid |= GCFLAG_VISITED;
         B->h_tid |= GCFLAG_VISITED;
+        assert(obj->h_tid & GCFLAG_OLD);
+        assert(B->h_tid & GCFLAG_OLD);
+
         assert(!(obj->h_tid & GCFLAG_STUB));
         assert(!(B->h_tid & GCFLAG_STUB));
         gcptrlist_insert2(&objects_to_trace, obj, B);
@@ -337,6 +343,7 @@
     if (!(obj->h_tid & GCFLAG_VISITED)) {
         obj->h_tid &= ~GCFLAG_PUBLIC_TO_PRIVATE;  /* see fix_outdated() */
         obj->h_tid |= GCFLAG_VISITED;
+        assert(obj->h_tid & GCFLAG_OLD);
         gcptrlist_insert(&objects_to_trace, obj);
 
         if (IS_POINTER(obj->h_revision)) {
@@ -379,20 +386,14 @@
             if (IS_POINTER((revision_t)next) /* needs to be an object */
                 && (next->h_revision & 1) /* needs to be a head rev */
                 && !(obj->h_tid & GCFLAG_PUBLIC_TO_PRIVATE)) {
-                
-                /* XXX: WHY never hit? */
-                assert(!(next->h_tid & GCFLAG_PUBLIC_TO_PRIVATE));
-                
+
+                /* next may have had PUBLIC_TO_PRIVATE, but that was
+                   cleared in the preceeding visit() */
                 assert(next->h_tid & GCFLAG_OLD); /* not moved already */
                 assert(next->h_original == (revision_t)obj);
                 assert(next->h_tid & GCFLAG_PUBLIC); /* no priv/prot!
                                 otherwise we'd need to fix more lists
                                 like old_objects_to_trace */
-                assert(!(next->h_tid & GCFLAG_STUB));
-                assert(!(obj->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED));
-                assert(!(next->h_tid & GCFLAG_PRIVATE_FROM_PROTECTED));
-                assert(!(obj->h_tid & GCFLAG_BACKUP_COPY));
-                assert(!(next->h_tid & GCFLAG_BACKUP_COPY));
                 
                 /* copy next over obj but preserve possibly existing
                    pre-hash value and tid (prebuilt-flag) */
@@ -420,8 +421,7 @@
                    for inevitable transactions and others ignore
                    it during tracing. Otherwise, inev transactions
                    will think 'next' is outdated. */
-                next->h_tid &= ~GCFLAG_OLD;
-
+                next->h_tid &= ~(GCFLAG_OLD | GCFLAG_VISITED);
             }
             /* obj does not need tracing if it can't
                be reached from somewhere else */
@@ -571,6 +571,11 @@
             items[i] = items[--d->private_from_protected.size];
         }
     }
+    
+    /* In old_objects_to_trace there can be a now invalid object 
+       NO: never happens because only priv/prot objects can still
+       be in old_objects_to_trace after the forced minor_collection.
+       And we do not copy such objects over prebuilts. */
 
     /* If we're aborting this transaction anyway, we don't need to do
      * more here.
@@ -756,6 +761,7 @@
         gcptr p = item->addr;
         if (p->h_tid & GCFLAG_VISITED) {
             p->h_tid &= ~GCFLAG_VISITED;
+            assert(p->h_tid & GCFLAG_OLD);
         }
         else {
             G2L_LOOP_DELETE(item);
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
@@ -323,9 +323,6 @@
     check_prebuilt(p1)
     assert lib.stm_hash(p1) == 99
     check_free_old(p2)
-    check_not_free(p3)
-    # XXX: takes another major collection to free p3
-    major_collect()
     check_free_old(p3)
 
 def test_prebuilt_version_to_protected():
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to