[pypy-commit] pypy stm-thread: Tweaks and comments.

arigo noreply at buildbot.pypy.org
Mon May 7 08:13:44 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread
Changeset: r54921:49afc750b63d
Date: 2012-05-07 08:11 +0200
http://bitbucket.org/pypy/pypy/changeset/49afc750b63d/

Log:	Tweaks and comments.

diff --git a/pypy/translator/stm/src_stm/core.c b/pypy/translator/stm/src_stm/core.c
--- a/pypy/translator/stm/src_stm/core.c
+++ b/pypy/translator/stm/src_stm/core.c
@@ -747,26 +747,26 @@
 {
   jmp_buf _jmpbuf;
   long volatile v_counter = 0;
-  long counter, result;
   void *volatile saved_value;
-  struct tx_descriptor *d = thread_descriptor;
-  assert(d->active == 0);
+  assert(thread_descriptor->active == 0);
   saved_value = *(void**)save_and_restore;
   /***/
   setjmp(_jmpbuf);
-  /***/
-  while (1)
+  /* After setjmp(), the local variables v_counter and saved_value
+   * are preserved because they are volatile.  The other variables
+   * are only declared here. */
+  long counter, result;
+  *(void**)save_and_restore = saved_value;
+  counter = v_counter;
+  do
     {
-      *(void**)save_and_restore = saved_value;
+      v_counter = counter + 1;
       begin_transaction(&_jmpbuf);
-      counter = v_counter;
-      v_counter = counter + 1;
       result = callback(arg, counter);
       stm_commit_transaction();
-      if (result != 1)   /* also when it raises an RPython exception */
-        return;
-      v_counter = 0;
+      counter = 0;
     }
+  while (result == 1);  /* also stops if we got an RPython exception */
 }
 
 #undef GETVERSION


More information about the pypy-commit mailing list