[pypy-commit] pypy stmgc-c8-gcc: fix: hint_commit_soon can now malloc and break a transaction itself

Raemi noreply at buildbot.pypy.org
Thu Jul 23 17:14:14 CEST 2015


Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch: stmgc-c8-gcc
Changeset: r78638:75d83967e132
Date: 2015-07-23 17:15 +0200
http://bitbucket.org/pypy/pypy/changeset/75d83967e132/

Log:	fix: hint_commit_soon can now malloc and break a transaction itself

diff --git a/rpython/jit/backend/llsupport/stmrewrite.py b/rpython/jit/backend/llsupport/stmrewrite.py
--- a/rpython/jit/backend/llsupport/stmrewrite.py
+++ b/rpython/jit/backend/llsupport/stmrewrite.py
@@ -24,6 +24,8 @@
             return
         # ----------  transaction breaks  ----------
         if opnum == rop.STM_HINT_COMMIT_SOON:
+            self.emitting_an_operation_that_can_collect()
+            self.next_op_may_be_in_new_transaction()
             self._do_stm_call('stm_hint_commit_soon', [], None)
             return
         # ----------  jump, finish, guard_not_forced_2  ----------
diff --git a/rpython/jit/backend/llsupport/test/test_stmrewrite.py b/rpython/jit/backend/llsupport/test/test_stmrewrite.py
--- a/rpython/jit/backend/llsupport/test/test_stmrewrite.py
+++ b/rpython/jit/backend/llsupport/test/test_stmrewrite.py
@@ -88,9 +88,14 @@
     def check_rewrite(self, frm_operations, to_operations, **namespace):
         inev = ("call(ConstClass(stm_try_inevitable),"
                 " descr=stm_try_inevitable_descr)")
+        hcs  = ("call(ConstClass(stm_hint_commit_soon),"
+                " descr=stm_hint_commit_soon_descr)")
+
         dummyalloc = "p999 = call_malloc_nursery(16)"
         frm_operations = frm_operations.replace('$INEV', inev)
+        frm_operations = frm_operations.replace('$HCS', hcs)
         to_operations  = to_operations .replace('$INEV', inev)
+        to_operations  = to_operations .replace('$HCS', hcs)
         to_operations  = to_operations .replace('$DUMMYALLOC', dummyalloc)
         for name, value in self.gc_ll_descr.__dict__.items():
             if name.endswith('descr') and name[1] == '2' and len(name) == 8:
@@ -705,6 +710,39 @@
             jump()
         """)
 
+    def test_hint_commit_soon(self):
+        T = rffi.CArrayPtr(rffi.TIME_T)
+        calldescr2 = get_call_descr(self.gc_ll_descr, [T], rffi.TIME_T)
+        self.check_rewrite("""
+            [i2, p7, p1]
+            i1 = getfield_gc(p1, descr=tydescr) # noptr
+            setfield_gc(p7, 10, descr=tydescr) #noptr
+            stm_hint_commit_soon()
+            setfield_gc(p7, 20, descr=tydescr) #noptr
+            i3 = getfield_gc(p1, descr=tydescr) # noptr
+            jump(i2, p7, i1)
+        """, """
+            [i2, p7, p1]
+            i1 = getfield_gc(p1, descr=tydescr)
+            stm_read(p1)
+
+            cond_call_gc_wb(p7, descr=wbdescr)
+            setfield_gc(p7, 10, descr=tydescr)
+
+            $HCS
+
+            cond_call_gc_wb(p7, descr=wbdescr)
+            setfield_gc(p7, 20, descr=tydescr)
+
+            i3 = getfield_gc(p1, descr=tydescr) # noptr
+            stm_read(p1)
+
+            $DUMMYALLOC
+            jump(i2, p7, i1)
+        """, calldescr2=calldescr2)
+
+
+
     def test_call_release_gil(self):
         T = rffi.CArrayPtr(rffi.TIME_T)
         calldescr2 = get_call_descr(self.gc_ll_descr, [T], rffi.TIME_T)
diff --git a/rpython/memory/gctransform/stmframework.py b/rpython/memory/gctransform/stmframework.py
--- a/rpython/memory/gctransform/stmframework.py
+++ b/rpython/memory/gctransform/stmframework.py
@@ -231,6 +231,7 @@
 
     # sync with lloperation.py
     gct_stm_become_inevitable                       = _gct_with_roots_pushed
+    gct_stm_hint_commit_soon                        = _gct_with_roots_pushed
     gct_stm_stop_all_other_threads                  = _gct_with_roots_pushed
     gct_stm_transaction_break                       = _gct_with_roots_pushed
     gct_stm_collect                                 = _gct_with_roots_pushed
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
@@ -449,7 +449,10 @@
     # stm_memclearinit(gcref, offset, size) clears the memory in this address space
     'stm_memclearinit': LLOp(),
 
-    'stm_hint_commit_soon':   LLOp(canrun=True),
+    # if it stays that way, should be renamed to something like
+    # try_break_transaction(). (before, it would also work in an
+    # atomic transaction)
+    'stm_hint_commit_soon':   LLOp(canrun=True, canmallocgc=True),
 
     'stm_increment_atomic':   LLOp(),
     'stm_decrement_atomic':   LLOp(),
diff --git a/rpython/translator/stm/breakfinder.py b/rpython/translator/stm/breakfinder.py
--- a/rpython/translator/stm/breakfinder.py
+++ b/rpython/translator/stm/breakfinder.py
@@ -5,6 +5,7 @@
 TRANSACTION_BREAK = set([
     'stm_enter_transactional_zone',
     'stm_leave_transactional_zone',
+    'stm_hint_commit_soon',
     #'jit_assembler_call',
     'stm_enter_callback_call',
     'stm_leave_callback_call',


More information about the pypy-commit mailing list