Author: Armin Rigo <[email protected]>
Branch: stm-thread
Changeset: r54946:d06604c88157
Date: 2012-05-07 20:18 +0200
http://bitbucket.org/pypy/pypy/changeset/d06604c88157/

Log:    Tweaks.

diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -318,7 +318,7 @@
             if jit.we_are_jitted():
                 return next_instr
 
-            if rstm.is_inevitable():
+            if rstm.should_break_transaction():
                 return next_instr
 
     @jit.unroll_safe
diff --git a/pypy/rlib/rstm.py b/pypy/rlib/rstm.py
--- a/pypy/rlib/rstm.py
+++ b/pypy/rlib/rstm.py
@@ -13,6 +13,10 @@
 def is_inevitable():
     return we_are_translated() and stmgcintf.StmOperations.is_inevitable()
 
+def should_break_transaction():
+    return we_are_translated() and (
+        stmgcintf.StmOperations.should_break_transaction())
+
 def increment_atomic():
     stmgcintf.StmOperations.add_atomic(+1)
 
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
@@ -740,12 +740,18 @@
 
 void stm_add_atomic(long delta)
 {
-    stm_atomic += delta;
+  stm_atomic += delta;
 }
 
 long stm_get_atomic(void)
 {
-    return stm_atomic;
+  return stm_atomic;
+}
+
+long stm_should_break_transaction(void)
+{
+  struct tx_descriptor *d = thread_descriptor;
+  return !stm_atomic && is_inevitable(d);
 }
 
 void stm_perform_transaction(long(*callback)(void*, long), void *arg,
@@ -755,7 +761,7 @@
   long volatile v_counter = 0;
   void *volatile saved_value;
   long volatile v_atomic = stm_atomic;
-  assert(thread_descriptor->active == 0);
+  assert((!thread_descriptor->active) == (!stm_atomic));
   saved_value = *(void**)save_and_restore;
   /***/
   setjmp(_jmpbuf);
@@ -777,6 +783,9 @@
       counter = 0;
     }
   while (result == 1);  /* also stops if we got an RPython exception */
+
+  if (stm_atomic && thread_descriptor->setjmp_buf == &_jmpbuf)
+    stm_try_inevitable(STM_EXPLAIN1("perform_transaction left with atomic"));
 }
 
 #undef GETVERSION
diff --git a/pypy/translator/stm/stmgcintf.py b/pypy/translator/stm/stmgcintf.py
--- a/pypy/translator/stm/stmgcintf.py
+++ b/pypy/translator/stm/stmgcintf.py
@@ -48,6 +48,8 @@
     # C part of the implementation of the pypy.rlib.rstm module
     in_transaction = smexternal('stm_in_transaction', [], lltype.Signed)
     is_inevitable = smexternal('stm_is_inevitable', [], lltype.Signed)
+    should_break_transaction = smexternal('stm_should_break_transaction',
+                                          [], lltype.Signed)
     add_atomic = smexternal('stm_add_atomic', [lltype.Signed], lltype.Void)
     get_atomic = smexternal('stm_get_atomic', [], lltype.Signed)
     descriptor_init = smexternal('stm_descriptor_init', [], lltype.Signed)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to