[pypy-commit] pypy stm-thread: A failing test.

arigo noreply at buildbot.pypy.org
Sun Jun 10 12:04:34 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread
Changeset: r55538:a8bc5dfa2fa3
Date: 2012-06-10 12:00 +0200
http://bitbucket.org/pypy/pypy/changeset/a8bc5dfa2fa3/

Log:	A failing test.

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,9 @@
 def is_inevitable():
     return we_are_translated() and stmgcintf.StmOperations.is_inevitable()
 
+def become_inevitable():
+    llop.stm_become_inevitable(lltype.Void)
+
 def should_break_transaction():
     return we_are_translated() and (
         stmgcintf.StmOperations.should_break_transaction())
diff --git a/pypy/translator/stm/funcgen.py b/pypy/translator/stm/funcgen.py
--- a/pypy/translator/stm/funcgen.py
+++ b/pypy/translator/stm/funcgen.py
@@ -57,7 +57,10 @@
 
 
 def stm_become_inevitable(funcgen, op):
-    info = op.args[0].value
+    try:
+        info = op.args[0].value
+    except IndexError:
+        info = "rstm.become_inevitable"    # cannot insert it in 'llop'
     string_literal = c_string_constant(info)
     return 'stm_try_inevitable(STM_EXPLAIN1(%s));' % (string_literal,)
 
diff --git a/pypy/translator/stm/test/targetdemo2.py b/pypy/translator/stm/test/targetdemo2.py
--- a/pypy/translator/stm/test/targetdemo2.py
+++ b/pypy/translator/stm/test/targetdemo2.py
@@ -16,6 +16,9 @@
     LENGTH      = 5000
     USE_MEMORY  = False
     anchor      = Node(-1)
+    othernode1  = Node(0)
+    othernode2  = Node(0)
+    othernodes  = [Node(0) for i in range(1000)]
 glob = Global()
 
 def add_at_end_of_chained_list(node, value, threadindex):
@@ -66,6 +69,9 @@
     def run(self):
         try:
             self.value = 0
+            rstm.perform_transaction(ThreadRunner.check_inev,
+                                     ThreadRunner, self)
+            self.value = 0
             self.arg = Arg()
             rstm.perform_transaction(ThreadRunner.check_ptr_equality,
                                      ThreadRunner, self)
@@ -98,6 +104,26 @@
         ll_assert(raw1 != raw2, "ERROR: retry_counter == -1")
         return 0
 
+    def _check_content(self, content):
+        ll_assert(glob.othernode2.value == content, "bogus value after inev")
+    _check_content._dont_inline_ = True
+
+    def _check_inev(self):
+        read_value = glob.othernode1.value
+        rstm.become_inevitable()
+        self._check_content(read_value)
+    _check_inev._dont_inline_ = True
+
+    def check_inev(self, retry_counter):
+        self.value += 1
+        new_value = self.index * 1000000 + self.value
+        self._check_inev()
+        glob.othernode1.value = new_value
+        for n in glob.othernodes:   # lots of unrelated writes in-between
+            n.value = new_value
+        glob.othernode2.value = new_value
+        return int(self.value < glob.LENGTH)
+
 class Arg:
     foobar = 42
 


More information about the pypy-commit mailing list