Commits

Armin Rigo committed d6678ac

Tweaks: rstm.longest_abort_info() turns the transaction inevitable, so we need a different way to inspect it first

  • Participants
  • Parent commits 12d9ba7
  • Branches stmgc-c7

Comments (0)

Files changed (4)

File lib_pypy/atomic.py

     _fullfilenames = {}
 
     def print_abort_info(mintime=0.0):
-        a, b, c, d = _thread.longest_abort_info()
-        if b <= mintime:
+        info = _thread.longest_abort_info(mintime)
+        if info is None:
             return
         print >> sys.stderr, "Conflict",
+        a, b, c, d = info
         try:
             reason = _timing_reasons[a]
         except IndexError:

File pypy/module/__pypy__/interp_atomic.py

 from pypy.interpreter.error import OperationError
+from pypy.interpreter.gateway import unwrap_spec
 from pypy.module.thread.error import wrap_thread_error
 from rpython.rtyper.lltypesystem import rffi
 
     else:
         return space.wrap(1)
 
-def longest_abort_info(space):
+@unwrap_spec(mintime=float)
+def longest_abort_info(space, mintime=0.0):
     if space.config.translation.stm:
-        from rpython.rlib.rstm import longest_abort_info
-        a, b, c, d = longest_abort_info()
+        from rpython.rlib import rstm
+        if rstm.longest_marker_time() <= mintime:
+            return space.w_None
+        a, b, c, d = rstm.longest_abort_info()
         return space.newtuple([space.wrap(a), space.wrap(b),
                                space.wrap(c), space.wrap(d)])
     else:

File rpython/rlib/rstm.py

 def pop_marker():
     llop.stm_pop_marker(lltype.Void)
 
+@dont_look_inside    # XXX allow looking inside this function
+def longest_marker_time():
+    return llop.stm_longest_marker_time(lltype.Float)
+
 @dont_look_inside
 def longest_abort_info():
     state = llop.stm_longest_marker_state(lltype.Signed)

File rpython/translator/stm/test/test_ztranslated.py

             setxy(globf, retry_counter)
             if retry_counter < 3:
                 rstm.abort_and_retry()
+            print rstm.longest_marker_time()
             print rstm.longest_abort_info()
             rstm.reset_longest_abort_info()
             print rstm.longest_abort_info()
         data = cbuilder.cmdexec('a b')
         #
         # 6 == STM_TIME_RUN_ABORTED_OTHER
-        import re; r = re.compile(r'\(6, 0.00\d+, , \)\n\(0, 0.00+, , \)\n$')
+        import re; r = re.compile(r'0.00\d+\n\(6, 0.00\d+, , \)\n\(0, 0.00+, , \)\n$')
         assert r.match(data)
 
     def test_weakref(self):