[pypy-commit] pypy stmgc-c7: Debugging tweaks, and the one issue it found, which was

arigo noreply at buildbot.pypy.org
Mon Mar 31 23:31:47 CEST 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r70363:901b34818a18
Date: 2014-03-31 23:24 +0200
http://bitbucket.org/pypy/pypy/changeset/901b34818a18/

Log:	Debugging tweaks, and the one issue it found, which was
	stm_become_globally_unique_transaction() not resetting
	pypy_stm_nursery_low_fill_mark to 0

diff --git a/rpython/translator/stm/funcgen.py b/rpython/translator/stm/funcgen.py
--- a/rpython/translator/stm/funcgen.py
+++ b/rpython/translator/stm/funcgen.py
@@ -134,8 +134,7 @@
     return 'pypy_stm_become_inevitable(%s);' % (string_literal,)
 
 def stm_become_globally_unique_transaction(funcgen, op):
-    return ('stm_become_globally_unique_transaction(&stm_thread_local,'
-            ' "for the JIT");')
+    return 'pypy_stm_become_globally_unique_transaction();'
 
 def stm_push_root(funcgen, op):
     arg0 = funcgen.expr(op.args[0])
diff --git a/rpython/translator/stm/src_stm/stmgcintf.c b/rpython/translator/stm/src_stm/stmgcintf.c
--- a/rpython/translator/stm/src_stm/stmgcintf.c
+++ b/rpython/translator/stm/src_stm/stmgcintf.c
@@ -94,6 +94,7 @@
 void pypy_stm_start_transaction(stm_jmpbuf_t *jmpbuf_ptr,
                                 volatile long *v_counter)
 {
+    pypy_stm_nursery_low_fill_mark = 1;  /* will be set to a correct value below */
     _stm_start_transaction(&stm_thread_local, jmpbuf_ptr);
 
     /* If v_counter==0, initialize 'pypy_stm_nursery_low_fill_mark'
@@ -181,13 +182,13 @@
             assert(pypy_stm_nursery_low_fill_mark != 0);
             assert(pypy_stm_nursery_low_fill_mark != (uintptr_t) -1);
             stm_commit_transaction();
+            pypy_stm_nursery_low_fill_mark = 0;
             stm_start_inevitable_transaction(&stm_thread_local);
-            pypy_stm_nursery_low_fill_mark = 0;
         }
         else {
-            _stm_become_inevitable("perform_transaction left with atomic");
             assert(pypy_stm_nursery_low_fill_mark == (uintptr_t) -1);
             pypy_stm_nursery_low_fill_mark_saved = 0;
+            _stm_become_inevitable("perform_transaction left with atomic");
         }
     }
     /* double-check */
@@ -205,13 +206,8 @@
     assert(v_old_shadowstack == stm_thread_local.shadowstack);
 }
 
-void _pypy_stm_become_inevitable(const char *msg)
+static void _pypy_stm_inev_state(void)
 {
-    if (msg == NULL) {
-        msg = "return from JITted function";
-    }
-    _stm_become_inevitable(msg);
-
     if (pypy_stm_ready_atomic == 1) {
         pypy_stm_nursery_low_fill_mark = 0;
     }
@@ -220,3 +216,18 @@
         pypy_stm_nursery_low_fill_mark_saved = 0;
     }
 }
+
+void _pypy_stm_become_inevitable(const char *msg)
+{
+    _pypy_stm_inev_state();
+    if (msg == NULL) {
+        msg = "return from JITted function";
+    }
+    _stm_become_inevitable(msg);
+}
+
+void pypy_stm_become_globally_unique_transaction(void)
+{
+    _pypy_stm_inev_state();
+    stm_become_globally_unique_transaction(&stm_thread_local, "for the JIT");
+}
diff --git a/rpython/translator/stm/src_stm/stmgcintf.h b/rpython/translator/stm/src_stm/stmgcintf.h
--- a/rpython/translator/stm/src_stm/stmgcintf.h
+++ b/rpython/translator/stm/src_stm/stmgcintf.h
@@ -24,6 +24,7 @@
 void pypy_stm_unregister_thread_local(void); /* generated into stm_prebuilt.c */
 
 void _pypy_stm_become_inevitable(const char *);
+void pypy_stm_become_globally_unique_transaction(void);
 
 
 static inline void pypy_stm_become_inevitable(const char *msg)
@@ -46,8 +47,8 @@
 static inline void pypy_stm_start_inevitable_if_not_atomic(void) {
     if (pypy_stm_ready_atomic == 1) {
         int e = errno;
+        pypy_stm_nursery_low_fill_mark = 0;
         stm_start_inevitable_transaction(&stm_thread_local);
-        pypy_stm_nursery_low_fill_mark = 0;
         errno = e;
     }
 }


More information about the pypy-commit mailing list