Author: Armin Rigo <[email protected]>
Branch: stmgc-c7
Changeset: r76021:5c42be959acd
Date: 2015-02-20 19:56 +0100
http://bitbucket.org/pypy/pypy/changeset/5c42be959acd/

Log:    The new rgc.ll_arrayclear() needs a stm fall-back version too

diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py
--- a/rpython/rlib/rgc.py
+++ b/rpython/rlib/rgc.py
@@ -374,6 +374,14 @@
 
     length = len(p)
     ARRAY = lltype.typeOf(p).TO
+    if stm_is_enabled():
+        # do the clearing element by element
+        from rpython.rtyper.lltypesystem import rffi
+        i = 0
+        while i < length:
+            p[i] = rffi.cast(ARRAY.OF, 0)
+            i += 1
+        return
     offset = llmemory.itemoffsetof(ARRAY, 0)
     dest_addr = llmemory.cast_ptr_to_adr(p) + offset
     llmemory.raw_memclear(dest_addr, llmemory.sizeof(ARRAY.OF) * length)
diff --git a/rpython/translator/stm/test/test_ztranslated.py 
b/rpython/translator/stm/test/test_ztranslated.py
--- a/rpython/translator/stm/test/test_ztranslated.py
+++ b/rpython/translator/stm/test/test_ztranslated.py
@@ -636,3 +636,19 @@
         t, cbuilder = self.compile(main)
         data = cbuilder.cmdexec('')
         assert 'ok!\n' in data
+
+    def test_ll_arrayclear(self):
+        A = lltype.GcArray(rffi.SHORT)
+        def main(argv):
+            p = lltype.malloc(A, 11)
+            for i in range(11):
+                p[i] = rffi.cast(rffi.SHORT, -4242)
+            rgc.ll_arrayclear(p)
+            for i in range(11):
+                assert rffi.cast(lltype.Signed, p[i]) == 0
+            print "ok!"
+            return 0
+
+        t, cbuilder = self.compile(main)
+        data = cbuilder.cmdexec('')
+        assert 'ok!\n' in data
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to