Author: Remi Meier <remi.me...@inf.ethz.ch>
Branch: stmgc-c7
Changeset: r71397:d86fc4a4ae43
Date: 2014-05-08 14:13 +0200
http://bitbucket.org/pypy/pypy/changeset/d86fc4a4ae43/

Log:    add app-level hint_commit_soon for experimentation

diff --git a/lib_pypy/atomic.py b/lib_pypy/atomic.py
--- a/lib_pypy/atomic.py
+++ b/lib_pypy/atomic.py
@@ -5,7 +5,7 @@
 
 try:
     from __pypy__ import thread as _thread
-    from __pypy__.thread import atomic, getsegmentlimit
+    from __pypy__.thread import atomic, getsegmentlimit, hint_commit_soon
 except ImportError:
     # Not a STM-enabled PyPy.  We can still provide a version of 'atomic'
     # that is good enough for our purposes.  With this limited version,
@@ -19,6 +19,9 @@
     def print_abort_info(mintime=0.0):
         pass
 
+    def hint_commit_soon():
+        pass
+
 else:
     import re, sys, linecache
 
diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -41,6 +41,7 @@
         'longest_abort_info':      'interp_atomic.longest_abort_info',
         'reset_longest_abort_info':'interp_atomic.reset_longest_abort_info',
         'getsegmentlimit':         'interp_atomic.getsegmentlimit',
+        'hint_commit_soon':        'interp_atomic.hint_commit_soon',
         'error': 'space.fromcache(pypy.module.thread.error.Cache).w_error',
     }
     def activate(self, space):
diff --git a/pypy/module/__pypy__/interp_atomic.py 
b/pypy/module/__pypy__/interp_atomic.py
--- a/pypy/module/__pypy__/interp_atomic.py
+++ b/pypy/module/__pypy__/interp_atomic.py
@@ -76,3 +76,9 @@
     if space.config.translation.stm:
         from rpython.rlib.rstm import reset_longest_abort_info
         reset_longest_abort_info()
+
+
+def hint_commit_soon(space):
+    if space.config.translation.stm:
+        from rpython.rlib.rstm import hint_commit_soon
+        hint_commit_soon()
diff --git a/rpython/rlib/rstm.py b/rpython/rlib/rstm.py
--- a/rpython/rlib/rstm.py
+++ b/rpython/rlib/rstm.py
@@ -50,6 +50,12 @@
                                                  if_there_is_no_other)
 
 @dont_look_inside
+def hint_commit_soon():
+    """As the name says, just a hint. Maybe calling it
+    several times in a row is more persuasive"""
+    llop.stm_hint_commit_soon(lltype.Void)
+
+@dont_look_inside
 def become_inevitable():
     llop.stm_become_inevitable(lltype.Void)
 
diff --git a/rpython/rtyper/lltypesystem/lloperation.py 
b/rpython/rtyper/lltypesystem/lloperation.py
--- a/rpython/rtyper/lltypesystem/lloperation.py
+++ b/rpython/rtyper/lltypesystem/lloperation.py
@@ -438,6 +438,8 @@
     'stm_should_break_transaction':       LLOp(sideeffects=False),
     'stm_set_transaction_length':         LLOp(),
 
+    'stm_hint_commit_soon':   LLOp(),
+
     'stm_threadlocalref_get': LLOp(sideeffects=False),
     'stm_threadlocalref_set': LLOp(canmallocgc=True), # may allocate new array,
                                                       # see threadlocalref.py
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
@@ -43,6 +43,9 @@
         #    self.obj.prebuilt_hash
 
 
+def stm_hint_commit_soon(funcgen, op):
+    return 'stmcb_commit_soon();'
+
 def stm_register_thread_local(funcgen, op):
     return 'pypy_stm_register_thread_local();'
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to