[pypy-commit] stmgc default: Move 'd->active = 0' a bit earlier. This should be enough to ensure the new comment.

arigo noreply at buildbot.pypy.org
Wed Sep 11 20:26:12 CEST 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r526:983af03354a5
Date: 2013-09-11 19:52 +0200
http://bitbucket.org/pypy/stmgc/changeset/983af03354a5/

Log:	Move 'd->active = 0' a bit earlier. This should be enough to ensure
	the new comment.

diff --git a/c4/et.c b/c4/et.c
--- a/c4/et.c
+++ b/c4/et.c
@@ -982,6 +982,13 @@
   stm_thread_local_obj = d->old_thread_local_obj;
   d->old_thread_local_obj = NULL;
 
+  // notifies the CPU that we're potentially in a spin loop
+  SpinLoop(SPLP_ABORT);
+
+  /* make the transaction no longer active */
+  d->active = 0;
+  d->atomic = 0;
+
   /* release the lock */
   spinlock_release(d->public_descriptor->collection_lock);
 
@@ -1003,11 +1010,7 @@
   if (num != ABRT_MANUAL && d->max_aborts >= 0 && !d->max_aborts--)
     stm_fatalerror("unexpected abort!\n");
 
-  // notifies the CPU that we're potentially in a spin loop
-  SpinLoop(SPLP_ABORT);
   // jump back to the setjmp_buf (this call does not return)
-  d->active = 0;
-  d->atomic = 0;
   stm_stop_sharedlock();
   longjmp(*d->setjmp_buf, 1);
 }
diff --git a/c4/extra.c b/c4/extra.c
--- a/c4/extra.c
+++ b/c4/extra.c
@@ -48,12 +48,16 @@
 void stm_invoke_callbacks_on_abort(struct tx_descriptor *d)
 {
     wlog_t *item;
+    assert(d->active == 0);
+
     G2L_LOOP_FORWARD(d->callbacks_on_abort, item) {
         void *key = (void *)item->addr;
         void (*callback)(void *) = (void(*)(void *))item->val;
         assert(key != NULL);
         assert(callback != NULL);
 
+        /* The callback may call stm_call_on_abort(key, NULL).
+           It is ignored, because we're no longer active. */
         callback(key);
 
     } G2L_LOOP_END;


More information about the pypy-commit mailing list