[pypy-commit] pypy stm: Progress.

arigo noreply at buildbot.pypy.org
Tue Sep 27 14:29:29 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r47623:f9b9cf3cebc6
Date: 2011-09-27 14:24 +0200
http://bitbucket.org/pypy/pypy/changeset/f9b9cf3cebc6/

Log:	Progress.

diff --git a/pypy/translator/stm/_rffi_stm.py b/pypy/translator/stm/_rffi_stm.py
--- a/pypy/translator/stm/_rffi_stm.py
+++ b/pypy/translator/stm/_rffi_stm.py
@@ -25,9 +25,9 @@
 begin_transaction = llexternal('stm_begin_transaction_inline',[], lltype.Void)
 commit_transaction = llexternal('stm_commit_transaction', [], lltype.Signed)
 
-read_word = llexternal('stm_read_word', [rffi.VOIDPP], rffi.VOIDP)
-write_word = llexternal('stm_write_word', [rffi.VOIDPP, rffi.VOIDP],
-                        lltype.Void)
+stm_read_word = llexternal('stm_read_word', [rffi.VOIDPP], rffi.VOIDP)
+stm_write_word = llexternal('stm_write_word', [rffi.VOIDPP, rffi.VOIDP],
+                            lltype.Void)
 
 CALLBACK = lltype.Ptr(lltype.FuncType([rffi.VOIDP], rffi.VOIDP))
 perform_transaction = llexternal('stm_perform_transaction',
diff --git a/pypy/translator/stm/test/test_rffi_stm.py b/pypy/translator/stm/test/test_rffi_stm.py
--- a/pypy/translator/stm/test/test_rffi_stm.py
+++ b/pypy/translator/stm/test/test_rffi_stm.py
@@ -29,3 +29,26 @@
                         lltype.nullptr(rffi.VOIDP.TO))
     descriptor_done()
     assert a.x == 420
+
+def test_abort_and_retry_transactionally():
+    A = lltype.Struct('A', ('x', lltype.Signed), ('y', lltype.Signed))
+    a = lltype.malloc(A, immortal=True, flavor='raw')
+    a.x = -611
+    a.y = 0
+    def callback1(x):
+        assert a.x == -611
+        p = lltype.direct_fieldptr(a, 'x')
+        p = rffi.cast(rffi.VOIDPP, p)
+        assert rffi.cast(lltype.Signed, stm_read_word(p)) == -611
+        stm_write_word(p, rffi.cast(rffi.VOIDP, 42 * a.y))
+        assert rffi.cast(lltype.Signed, stm_read_word(p)) == 42 * a.y
+        if a.y < 10:
+            a.y += 1    # non-transactionally
+            abort_and_retry()
+        else:
+            return lltype.nullptr(rffi.VOIDP.TO)
+    descriptor_init()
+    perform_transaction(llhelper(CALLBACK, callback1),
+                        lltype.nullptr(rffi.VOIDP.TO))
+    descriptor_done()
+    assert a.x == 420


More information about the pypy-commit mailing list