[pypy-commit] pypy stmgc-c7: import stmgc/6d6832a447c3 (branch card-marking) and fix the call to _stm_write_slowpath_card_extra_base()

arigo noreply at buildbot.pypy.org
Tue Jul 1 11:42:45 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r72303:46d55a933c65
Date: 2014-07-01 11:42 +0200
http://bitbucket.org/pypy/pypy/changeset/46d55a933c65/

Log:	import stmgc/6d6832a447c3 (branch card-marking) and fix the call to
	_stm_write_slowpath_card_extra_base()

diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -28,7 +28,7 @@
 adr_write_slowpath_card_extra = (
     CFlexSymbolic('((long)&_stm_write_slowpath_card_extra)'))
 adr__stm_write_slowpath_card_extra_base = (
-    CFlexSymbolic('((long)_stm_write_slowpath_card_extra_base())'))
+   CFlexSymbolic('(_stm_write_slowpath_card_extra_base()-0x4000000000000000L)'))
 CARD_MARKED = CFlexSymbolic('_STM_CARD_MARKED')
 CARD_SIZE   = CFlexSymbolic('_STM_CARD_SIZE')
 
diff --git a/rpython/translator/stm/src_stm/revision b/rpython/translator/stm/src_stm/revision
--- a/rpython/translator/stm/src_stm/revision
+++ b/rpython/translator/stm/src_stm/revision
@@ -1,1 +1,1 @@
-e1df81263680
+6d6832a447c3
diff --git a/rpython/translator/stm/src_stm/stm/core.c b/rpython/translator/stm/src_stm/stm/core.c
--- a/rpython/translator/stm/src_stm/stm/core.c
+++ b/rpython/translator/stm/src_stm/stm/core.c
@@ -68,6 +68,7 @@
         /* Card marking.  Don't remove GCFLAG_WRITE_BARRIER because we
            need to come back to _stm_write_slowpath_card() for every
            card to mark.  Add GCFLAG_CARDS_SET. */
+        assert(!(obj->stm_flags & GCFLAG_CARDS_SET));
         obj->stm_flags |= GCFLAG_CARDS_SET;
         assert(STM_PSEGMENT->old_objects_with_cards);
         LIST_APPEND(STM_PSEGMENT->old_objects_with_cards, obj);
@@ -245,12 +246,13 @@
     return mark_card;
 }
 
-char *_stm_write_slowpath_card_extra_base(void)
+long _stm_write_slowpath_card_extra_base(void)
 {
     /* for the PyPy JIT: _stm_write_slowpath_card_extra_base[obj >> 4]
        is the byte that must be set to CARD_MARKED.  The logic below
        does the same, but more explicitly. */
-    return (char *)write_locks - WRITELOCK_START + 1;
+    return (((long)write_locks) - WRITELOCK_START + 1)
+        + 0x4000000000000000L;   // <- workaround for a clang bug :-(
 }
 
 void _stm_write_slowpath_card(object_t *obj, uintptr_t index)
@@ -946,6 +948,24 @@
     /* throw away the content of the nursery */
     long bytes_in_nursery = throw_away_nursery(pseg);
 
+    /* modified_old_objects' cards get cleared in
+       reset_modified_from_other_segments. Objs in old_objs_with_cards but not
+       in modified_old_objs are overflow objects and handled here: */
+    if (pseg->large_overflow_objects != NULL) {
+        /* some overflow objects may have cards when aborting, clear them too */
+        LIST_FOREACH_R(pseg->large_overflow_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) {
+                    /* CARDS_SET is enough since other HAS_CARDS objs
+                       are already cleared */
+                    _reset_object_cards(pseg, item, CARD_CLEAR, false);
+                }
+            });
+    }
+
     /* reset all the modified objects (incl. re-adding GCFLAG_WRITE_BARRIER) */
     reset_modified_from_other_segments(segment_num);
     _verify_cards_cleared_in_all_lists(pseg);
diff --git a/rpython/translator/stm/src_stm/stm/nursery.c b/rpython/translator/stm/src_stm/stm/nursery.c
--- a/rpython/translator/stm/src_stm/stm/nursery.c
+++ b/rpython/translator/stm/src_stm/stm/nursery.c
@@ -326,9 +326,10 @@
 
 
 
-static inline void _collect_now(object_t *obj, bool was_definitely_young)
+static inline void _collect_now(object_t *obj)
 {
     assert(!_is_young(obj));
+    assert(!(obj->stm_flags & GCFLAG_CARDS_SET));
 
     dprintf(("_collect_now: %p\n", obj));
 
@@ -340,22 +341,6 @@
         stmcb_trace((struct object_s *)realobj, &minor_trace_if_young);
 
         obj->stm_flags |= GCFLAG_WRITE_BARRIER;
-        if (obj->stm_flags & GCFLAG_CARDS_SET) {
-            /* all objects that had WB cleared need to be fully synchronised
-               on commit, so we have to mark all their cards */
-            struct stm_priv_segment_info_s *pseg = get_priv_segment(
-                STM_SEGMENT->segment_num);
-
-            /* stm_wb-slowpath should never have triggered for young objs */
-            assert(!was_definitely_young);
-
-            if (!IS_OVERFLOW_OBJ(STM_PSEGMENT, obj)) {
-                _reset_object_cards(pseg, obj, CARD_MARKED_OLD, true); /* mark all */
-            } else {
-                /* simply clear overflow */
-                _reset_object_cards(pseg, obj, CARD_CLEAR, false);
-            }
-        }
     }
     /* else traced in collect_cardrefs_to_nursery if necessary */
 }
@@ -372,12 +357,11 @@
         assert(!_is_young(obj));
 
         if (!(obj->stm_flags & GCFLAG_CARDS_SET)) {
-            /* handled in _collect_now() */
+            /* sometimes we remove the CARDS_SET in the WB slowpath, see core.c */
             continue;
         }
 
-        /* traces cards, clears marked cards or marks them old if
-           necessary */
+        /* traces cards, clears marked cards or marks them old if necessary */
         _trace_card_object(obj);
 
         assert(!(obj->stm_flags & GCFLAG_CARDS_SET));
@@ -393,8 +377,7 @@
         uintptr_t obj_sync_now = list_pop_item(lst);
         object_t *obj = (object_t *)(obj_sync_now & ~FLAG_SYNC_LARGE);
 
-        bool was_definitely_young = (obj_sync_now & FLAG_SYNC_LARGE);
-        _collect_now(obj, was_definitely_young);
+        _collect_now(obj);
         assert(!(obj->stm_flags & GCFLAG_CARDS_SET));
 
         if (obj_sync_now & FLAG_SYNC_LARGE) {
@@ -424,7 +407,7 @@
     dprintf(("collect_modified_old_objects\n"));
     LIST_FOREACH_R(
         STM_PSEGMENT->modified_old_objects, object_t * /*item*/,
-        _collect_now(item, false));
+        _collect_now(item));
 }
 
 static void collect_roots_from_markers(uintptr_t num_old)
@@ -492,25 +475,6 @@
 
     tree_clear(pseg->nursery_objects_shadows);
 
-
-    /* modified_old_objects' cards get cleared in push_modified_to_other_segments
-       or reset_modified_from_other_segments. Objs in old_objs_with_cards but not
-       in modified_old_objs are overflow objects and handled here: */
-    if (pseg->large_overflow_objects != NULL) {
-        /* some overflow objects may have cards when aborting, clear them too */
-        LIST_FOREACH_R(pseg->large_overflow_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) {
-                    /* CARDS_SET is enough since other HAS_CARDS objs
-                       are already cleared */
-                    _reset_object_cards(pseg, item, CARD_CLEAR, false);
-                }
-            });
-    }
-
     return nursery_used;
 #pragma pop_macro("STM_SEGMENT")
 #pragma pop_macro("STM_PSEGMENT")
@@ -552,6 +516,7 @@
     if (!commit && STM_PSEGMENT->large_overflow_objects == NULL)
         STM_PSEGMENT->large_overflow_objects = list_create();
 
+
     /* All the objects we move out of the nursery become "overflow"
        objects.  We use the list 'objects_pointing_to_nursery'
        to hold the ones we didn't trace so far. */
@@ -559,6 +524,11 @@
     if (STM_PSEGMENT->objects_pointing_to_nursery == NULL) {
         STM_PSEGMENT->objects_pointing_to_nursery = list_create();
 
+        /* collect objs with cards, adds to objects_pointing_to_nursery
+           and makes sure there are no objs with cards left in
+           modified_old_objs */
+        collect_cardrefs_to_nursery();
+
         /* See the doc of 'objects_pointing_to_nursery': if it is NULL,
            then it is implicitly understood to be equal to
            'modified_old_objects'.  We could copy modified_old_objects
@@ -568,6 +538,7 @@
         num_old = 0;
     }
     else {
+        collect_cardrefs_to_nursery();
         num_old = STM_PSEGMENT->modified_old_objects_markers_num_old;
     }
 
@@ -575,7 +546,6 @@
 
     collect_roots_in_nursery();
 
-    collect_cardrefs_to_nursery();
     collect_oldrefs_to_nursery();
     assert(list_is_empty(STM_PSEGMENT->old_objects_with_cards));
 
diff --git a/rpython/translator/stm/src_stm/stmgc.h b/rpython/translator/stm/src_stm/stmgc.h
--- a/rpython/translator/stm/src_stm/stmgc.h
+++ b/rpython/translator/stm/src_stm/stmgc.h
@@ -110,7 +110,7 @@
 void _stm_write_slowpath(object_t *);
 void _stm_write_slowpath_card(object_t *, uintptr_t);
 char _stm_write_slowpath_card_extra(object_t *);
-char *_stm_write_slowpath_card_extra_base(void);
+long _stm_write_slowpath_card_extra_base(void);
 #define _STM_CARD_MARKED 100
 object_t *_stm_allocate_slowpath(ssize_t);
 object_t *_stm_allocate_external(ssize_t);


More information about the pypy-commit mailing list