[pypy-commit] stmgc c8-marker: progress

arigo noreply at buildbot.pypy.org
Sun Mar 8 18:58:35 CET 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: c8-marker
Changeset: r1698:75ffbf6c36cb
Date: 2015-03-08 18:59 +0100
http://bitbucket.org/pypy/stmgc/changeset/75ffbf6c36cb/

Log:	progress

diff --git a/c8/stm/core.c b/c8/stm/core.c
--- a/c8/stm/core.c
+++ b/c8/stm/core.c
@@ -369,6 +369,8 @@
                     struct stm_undo_s *undo = cl->written;
                     struct stm_undo_s *end = cl->written + cl->written_count;
                     for (; undo < end; undo++) {
+                        if (undo->type == TYPE_POSITION_MARKER)
+                            continue;
                         if (_stm_was_read(undo->object)) {
                             /* first reset all modified objects from the backup
                                copies as soon as the first conflict is detected;
@@ -1031,6 +1033,8 @@
     struct stm_undo_s *end = (struct stm_undo_s *)(list->items + list->count);
 
     for (; undo < end; undo++) {
+        if (undo->type == TYPE_POSITION_MARKER)
+            continue;
         object_t *obj = undo->object;
         obj->stm_flags &= ~GCFLAG_WB_EXECUTED;
     }
@@ -1044,6 +1048,8 @@
     struct stm_undo_s *end = (struct stm_undo_s *)(list->items + list->count);
 
     for (; undo < end; undo++) {
+        if (undo->type == TYPE_POSITION_MARKER)
+            continue;
         object_t *obj = undo->object;
         obj->stm_flags |= GCFLAG_WB_EXECUTED;
     }
@@ -1163,6 +1169,8 @@
     struct stm_undo_s *undo = (struct stm_undo_s *)list->items;
     struct stm_undo_s *end = (struct stm_undo_s *)(list->items + list->count);
     for (; undo < end; undo++) {
+        if (undo->type == TYPE_POSITION_MARKER)
+            continue;
         object_t *obj = undo->object;
         struct object_s *dst = (struct object_s*)REAL_ADDRESS(segbase, obj);
         assert(dst->stm_flags & GCFLAG_WRITE_BARRIER);
diff --git a/c8/stm/nursery.c b/c8/stm/nursery.c
--- a/c8/stm/nursery.c
+++ b/c8/stm/nursery.c
@@ -185,6 +185,8 @@
     struct stm_undo_s *end = (struct stm_undo_s *)(list->items + list->count);
 
     for (; undo < end; undo++) {
+        if (undo->type == TYPE_POSITION_MARKER)
+            continue;
         _cards_cleared_in_object(pseg, undo->object, false);
     }
     LIST_FOREACH_R(
diff --git a/c8/test/support.py b/c8/test/support.py
--- a/c8/test/support.py
+++ b/c8/test/support.py
@@ -163,6 +163,10 @@
 int stm_set_timing_log(const char *profiling_file_name, int fork_mode,
                        stm_expand_marker_fn expand_marker);
 
+void stm_push_marker(stm_thread_local_t *, uintptr_t, object_t *);
+void stm_update_marker_num(stm_thread_local_t *, uintptr_t);
+void stm_pop_marker(stm_thread_local_t *);
+
 long _stm_count_modified_old_objects(void);
 long _stm_count_objects_pointing_to_nursery(void);
 long _stm_count_old_objects_with_cards_set(void);
@@ -185,7 +189,6 @@
 void stm_enable_light_finalizer(object_t *);
 
 void (*stmcb_finalizer)(object_t *);
-
 """)
 
 
@@ -412,6 +415,21 @@
     }
 }
 
+void stm_push_marker(stm_thread_local_t *tl, uintptr_t onum, object_t *ob)
+{
+    STM_PUSH_MARKER(*tl, onum, ob);
+}
+
+void stm_update_marker_num(stm_thread_local_t *tl, uintptr_t onum)
+{
+    STM_UPDATE_MARKER_NUM(*tl, onum);
+}
+
+void stm_pop_marker(stm_thread_local_t *tl)
+{
+    STM_POP_MARKER(*tl);
+}
+
 long current_segment_num(void)
 {
     return STM_SEGMENT->segment_num;
diff --git a/c8/test/test_marker.py b/c8/test/test_marker.py
--- a/c8/test/test_marker.py
+++ b/c8/test/test_marker.py
@@ -7,16 +7,11 @@
     def recording(self, *kinds):
         seen = []
         @ffi.callback("stmcb_timing_event_fn")
-        def timing_event(tl, event, markers):
+        def timing_event(tl, event, marker):
             if len(kinds) > 0 and event not in kinds:
                 return
-            if markers:
-                expanded = []
-                for i in range(2):
-                    expanded.append((markers[i].tl,
-                                     markers[i].segment_base,
-                                     markers[i].odd_number,
-                                     markers[i].object))
+            if marker:
+                expanded = (marker.odd_number, marker.object)
             else:
                 expanded = None
             seen.append((tl, event, expanded))
@@ -24,13 +19,11 @@
         self.timing_event_keepalive = timing_event
         self.seen = seen
 
-    def check_recording(self, i1, o1, i2, o2, extra=None):
+    def check_recording(self, i1, o1, extra=None):
         seen = self.seen
-        tl, event, markers = seen[0]
+        tl, event, marker = seen[0]
         assert tl == self.tls[1]
-        segbase = lib._stm_get_segment_base
-        assert markers[0] == (self.tls[1], segbase(2), i1, o1)
-        assert markers[1] == (self.tls[0], segbase(1), i2, o2)
+        assert marker == (i1, o1)
         if extra is None:
             assert len(seen) == 1
         else:
@@ -47,9 +40,7 @@
         assert int(ffi.cast("uintptr_t", x)) == 29
 
     def test_abort_marker_no_shadowstack(self):
-        self.recording(lib.STM_CONTENTION_WRITE_WRITE,
-                       lib.STM_WAIT_CONTENTION,
-                       lib.STM_ABORTING_OTHER_CONTENTION)
+        self.recording(lib.STM_CONTENTION_WRITE_READ)
         p = stm_allocate_old(16)
         #
         self.start_transaction()
@@ -57,9 +48,13 @@
         #
         self.switch(1)
         self.start_transaction()
-        py.test.raises(Conflict, stm_set_char, p, 'B')
+        stm_set_char(p, 'B')
         #
-        self.check_recording(0, ffi.NULL, 0, ffi.NULL)
+        self.switch(0)
+        self.commit_transaction()
+        #
+        py.test.raises(Conflict, self.switch, 1)
+        self.check_recording(0, ffi.NULL)
 
     def test_macros(self):
         self.start_transaction()
@@ -96,8 +91,9 @@
         py.test.raises(EmptyStack, self.pop_root)
 
     def test_double_abort_markers_cb_write_write(self):
-        self.recording(lib.STM_CONTENTION_WRITE_WRITE)
+        self.recording(lib.STM_CONTENTION_WRITE_READ)
         p = stm_allocate_old(16)
+        p2 = stm_allocate_old(16)
         #
         self.start_transaction()
         self.push_root(ffi.cast("object_t *", 19))
@@ -107,15 +103,21 @@
         self.pop_root()
         self.push_root(ffi.cast("object_t *", 17))
         self.push_root(ffi.cast("object_t *", ffi.NULL))
+        stm_set_char(p, 'B')
+        stm_set_char(p2, 'C')
         stm_minor_collect()
         #
         self.switch(1)
         self.start_transaction()
         self.push_root(ffi.cast("object_t *", 21))
         self.push_root(ffi.cast("object_t *", ffi.NULL))
-        py.test.raises(Conflict, stm_set_char, p, 'B')
+        stm_set_char(p, 'B')
         #
-        self.check_recording(21, ffi.NULL, 19, ffi.NULL)
+        self.switch(0)
+        self.commit_transaction()
+        #
+        py.test.raises(Conflict, self.switch, 1)
+        self.check_recording(19, ffi.NULL)
 
     def test_double_abort_markers_cb_inevitable(self):
         self.recording(lib.STM_CONTENTION_INEVITABLE)


More information about the pypy-commit mailing list