Author: Remi Meier <[email protected]>
Branch: card-marking
Changeset: r1223:ac2d8c48ced3
Date: 2014-05-20 18:18 +0200
http://bitbucket.org/pypy/stmgc/changeset/ac2d8c48ced3/

Log:    fix clearing of cards in some cases (test_random)

diff --git a/c7/stm/core.c b/c7/stm/core.c
--- a/c7/stm/core.c
+++ b/c7/stm/core.c
@@ -49,7 +49,7 @@
         /* not yet in the list */
         if (STM_PSEGMENT->old_objects_with_cards) {
             /* if we never had a minor collection in this transaction,
-               this list doesn't exist */
+               this list doesn't exist, we rely on modified_old_objs instead */
             LIST_APPEND(STM_PSEGMENT->old_objects_with_cards, obj);
         }
         obj->stm_flags |= GCFLAG_CARDS_SET;
diff --git a/c7/stm/gcpage.c b/c7/stm/gcpage.c
--- a/c7/stm/gcpage.c
+++ b/c7/stm/gcpage.c
@@ -459,7 +459,10 @@
                 ({
                     struct object_s *realobj = (struct object_s *)
                         REAL_ADDRESS(pseg->pub.segment_base, item);
+
                     assert(!(realobj->stm_flags & GCFLAG_WRITE_BARRIER));
+                    OPT_ASSERT(!(realobj->stm_flags & GCFLAG_CARDS_SET));
+
                     realobj->stm_flags |= GCFLAG_WRITE_BARRIER;
                 }));
             list_clear(lst);
@@ -473,6 +476,16 @@
                     _reset_object_cards(&pseg->pub, item);
                 }));
             list_clear(lst);
+        } else {
+            LIST_FOREACH_R(pseg->modified_old_objects, object_t * /*item*/,
+               {
+                   struct object_s *realobj = (struct object_s *)
+                       REAL_ADDRESS(pseg->pub.segment_base, item);
+
+                   if (realobj->stm_flags & GCFLAG_CARDS_SET) {
+                       _reset_object_cards(&pseg->pub, item);
+                   }
+               });
         }
 
         /* Remove from 'large_overflow_objects' all objects that die */
diff --git a/c7/stm/nursery.c b/c7/stm/nursery.c
--- a/c7/stm/nursery.c
+++ b/c7/stm/nursery.c
@@ -195,8 +195,12 @@
     uintptr_t first_card_index = get_write_lock_idx((uintptr_t)obj);
     uintptr_t card_index = 1;
     uintptr_t last_card_index = get_card_index(size - 1);
-    OPT_ASSERT(last_card_index >= card_index);
+
     while (card_index <= last_card_index) {
+        #ifndef NDEBUG
+        if (write_locks[first_card_index + card_index])
+            dprintf(("cleared card %lu on %p\n", card_index, obj));
+        #endif
         write_locks[first_card_index + card_index] = 0;
         card_index++;
     }
@@ -236,8 +240,7 @@
     char *realobj = REAL_ADDRESS(STM_SEGMENT->segment_base, obj);
     stmcb_trace((struct object_s *)realobj, &minor_trace_if_young_cards);
 
-    _reset_object_cards(
-        get_segment(STM_SEGMENT->segment_num), obj);
+    _reset_object_cards(get_segment(STM_SEGMENT->segment_num), obj);
 }
 
 
@@ -257,8 +260,7 @@
 
         obj->stm_flags |= GCFLAG_WRITE_BARRIER;
         if (obj->stm_flags & GCFLAG_CARDS_SET) {
-            _reset_object_cards(
-                get_segment(STM_SEGMENT->segment_num), obj);
+            _reset_object_cards(get_segment(STM_SEGMENT->segment_num), obj);
         }
     } if (obj->stm_flags & GCFLAG_CARDS_SET) {
         _trace_card_object(obj);
@@ -275,6 +277,7 @@
 
         assert(obj->stm_flags & GCFLAG_CARDS_SET);
         _collect_now(obj);
+        assert(!(obj->stm_flags & GCFLAG_CARDS_SET));
     }
 }
 
@@ -287,6 +290,7 @@
         object_t *obj = (object_t *)(obj_sync_now & ~FLAG_SYNC_LARGE);
 
         _collect_now(obj);
+        assert(!(obj->stm_flags & GCFLAG_CARDS_SET));
 
         if (obj_sync_now & FLAG_SYNC_LARGE) {
             /* this was a large object.  We must either synchronize the
@@ -376,6 +380,13 @@
     if (pseg->old_objects_with_cards) {
         LIST_FOREACH_R(pseg->old_objects_with_cards, object_t * /*item*/,
                        _reset_object_cards(&pseg->pub, item));
+    } else {
+        LIST_FOREACH_R(pseg->modified_old_objects, object_t * /*item*/,
+           {
+               if (item->stm_flags & GCFLAG_CARDS_SET) {
+                   _reset_object_cards(&pseg->pub, item);
+               }
+           });
     }
 
     return nursery_used;
diff --git a/c7/test/test_random.py b/c7/test/test_random.py
--- a/c7/test/test_random.py
+++ b/c7/test/test_random.py
@@ -378,7 +378,7 @@
     num = str(global_state.rnd.randrange(1, 100))
     r = global_state.get_new_root_name(True, num)
     thread_state.push_roots(ex)
-    ex.do('%s = stm_allocate_refs(%s)' % (r, num))
+    ex.do('%s = stm_allocate_refs(%s, True)' % (r, num))
     ex.do('# 0x%x' % (int(ffi.cast("uintptr_t", ex.content[r]))))
     thread_state.transaction_state.add_root(r, "ffi.NULL", True)
 
@@ -438,9 +438,9 @@
         thread_state.abort_transaction()
     offset = global_state.get_root_size(r) + " - 1"
     if is_ref:
-        ex.do(raising_call(aborts, "stm_set_ref", r, offset, v))
+        ex.do(raising_call(aborts, "stm_set_ref", r, offset, v, "True"))
         if not aborts:
-            ex.do(raising_call(False, "stm_set_ref", r, "0", v))
+            ex.do(raising_call(False, "stm_set_ref", r, "0", v, "True"))
     else:
         ex.do(raising_call(aborts, "stm_set_char", r, repr(chr(v)), offset))
         if not aborts:
@@ -562,7 +562,7 @@
             global_state.prebuilt_roots.append(r)
 
             r = global_state.get_new_root_name(True, "50")
-            ex.do('%s = stm_allocate_old_refs(50)' % r)
+            ex.do('%s = stm_allocate_old_refs(50, True)' % r)
             global_state.committed_transaction_state.add_root(r, "ffi.NULL", 
False)
             global_state.prebuilt_roots.append(r)
         global_state.committed_transaction_state.write_set = set()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to