[pypy-commit] stmgc marker: Find out how to reuse the logic.

arigo noreply at buildbot.pypy.org
Mon Apr 28 18:04:55 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: marker
Changeset: r1189:6b462cb2ba16
Date: 2014-04-28 18:04 +0200
http://bitbucket.org/pypy/stmgc/changeset/6b462cb2ba16/

Log:	Find out how to reuse the logic.

diff --git a/c7/stm/contention.c b/c7/stm/contention.c
--- a/c7/stm/contention.c
+++ b/c7/stm/contention.c
@@ -187,7 +187,7 @@
 
         dprintf(("abort in contention\n"));
         STM_SEGMENT->nursery_end = abort_category;
-        marker_contention_abort_self(abort_category, other_segment_num, obj);
+        marker_contention(abort_category, false, other_segment_num, obj);
         abort_with_mutex();
     }
 
@@ -195,10 +195,7 @@
         /* We have to signal the other thread to abort, and wait until
            it does. */
         contmgr.other_pseg->pub.nursery_end = abort_category;
-        if (kind == WRITE_WRITE_CONTENTION) {
-            //marker_fetch_obj_write(contmgr.other_pseg->pub.segment_num,
-            //                       obj, contmgr.other_pseg->...);
-        }
+        marker_contention(abort_category, true, other_segment_num, obj);
 
         int sp = contmgr.other_pseg->safe_point;
         switch (sp) {
diff --git a/c7/stm/marker.c b/c7/stm/marker.c
--- a/c7/stm/marker.c
+++ b/c7/stm/marker.c
@@ -134,9 +134,8 @@
     marker[1] = 0;
 }
 
-static void marker_contention_abort_self(int category,
-                                         uint8_t other_segment_num,
-                                         object_t *obj)
+static void marker_contention(int category, bool abort_other,
+                              uint8_t other_segment_num, object_t *obj)
 {
     uintptr_t self_marker[2];
     uintptr_t other_marker[2];
@@ -148,25 +147,30 @@
     char *my_segment_base = STM_SEGMENT->segment_base;
     char *other_segment_base = get_segment_base(other_segment_num);
 
-    /* I'm aborting.  Collect the location for myself.  It's usually
-       the current location, except in a write-read abort, in which
-       case it's the older location of the write. */
+    acquire_marker_lock(other_segment_base);
+
+    /* Collect the location for myself.  It's usually the current
+       location, except in a write-read abort, in which case it's the
+       older location of the write. */
     if (category == STM_TIME_RUN_ABORTED_WRITE_READ)
         marker_fetch_obj_write(my_pseg->pub.segment_num, obj, self_marker);
     else
         marker_fetch(my_pseg->pub.running_thread, self_marker);
 
-    marker_expand(self_marker, my_segment_base, my_pseg->marker_self);
+    /* Expand this location into either my_pseg->marker_self or
+       other_pseg->marker_other, depending on who aborts. */
+    marker_expand(self_marker, my_segment_base,
+                  abort_other ? other_pseg->marker_other
+                              : my_pseg->marker_self);
 
     /* For some categories, we can also collect the relevant information
        for the other segment. */
-    acquire_marker_lock(other_segment_base);
-
     switch (category) {
     case STM_TIME_RUN_ABORTED_WRITE_WRITE:
         marker_fetch_obj_write(other_segment_num, obj, other_marker);
         break;
     case STM_TIME_RUN_ABORTED_INEVITABLE:
+        assert(abort_other == false);
         other_marker[0] = other_pseg->marker_inev[0];
         other_marker[1] = other_pseg->marker_inev[1];
         break;
@@ -176,7 +180,16 @@
         break;
     }
 
-    marker_expand(other_marker, other_segment_base, my_pseg->marker_other);
+    marker_expand(other_marker, other_segment_base,
+                  abort_other ? other_pseg->marker_self
+                              : my_pseg->marker_other);
+
+    if (abort_other && other_pseg->marker_self[0] == 0) {
+        if (category == STM_TIME_RUN_ABORTED_WRITE_READ)
+            strcpy(other_pseg->marker_self, "<read at unknown location>");
+        else
+            strcpy(other_pseg->marker_self, "<no location information>");
+    }
 
     release_marker_lock(other_segment_base);
 }
diff --git a/c7/stm/marker.h b/c7/stm/marker.h
--- a/c7/stm/marker.h
+++ b/c7/stm/marker.h
@@ -8,6 +8,5 @@
                         struct stm_priv_segment_info_s *pseg,
                         enum stm_time_e attribute_to, double time);
 
-static void marker_contention_abort_self(int category,
-                                         uint8_t other_segment_num,
-                                         object_t *obj);
+static void marker_contention(int category, bool abort_other,
+                              uint8_t other_segment_num, object_t *obj);


More information about the pypy-commit mailing list