[pypy-commit] pypy stmgc-c4: non-gc arrays mustn't get a barrier (getarraysize)

Raemi noreply at buildbot.pypy.org
Sun Nov 10 12:06:41 CET 2013


Author: Remi Meier <remi.meier at gmail.com>
Branch: stmgc-c4
Changeset: r67926:eb21e739cefa
Date: 2013-11-10 12:05 +0100
http://bitbucket.org/pypy/pypy/changeset/eb21e739cefa/

Log:	non-gc arrays mustn't get a barrier (getarraysize)

diff --git a/rpython/translator/stm/test/test_writebarrier.py b/rpython/translator/stm/test/test_writebarrier.py
--- a/rpython/translator/stm/test/test_writebarrier.py
+++ b/rpython/translator/stm/test/test_writebarrier.py
@@ -28,6 +28,27 @@
         assert len(self.writemode) == 0
         assert self.barriers == ['I2R']
 
+    def test_array_size(self):
+        array_gc = lltype.GcArray(('z', lltype.Signed))
+        array_nongc = lltype.Array(('z', lltype.Signed))
+        Q = lltype.GcStruct('Q',
+                            ('gc', lltype.Ptr(array_gc)),
+                            ('raw', lltype.Ptr(array_nongc)))
+        q = lltype.malloc(Q, immortal=True)
+        q.gc = lltype.malloc(array_gc, n=3, flavor='gc', immortal=True)
+        q.raw = lltype.malloc(array_nongc, n=5, flavor='raw', immortal=True)
+        def f1(n):
+            if n == 1:
+                return len(q.gc)
+            else:
+                return len(q.raw)
+        res = self.interpret(f1, [1])
+        assert self.barriers == ['I2R', 'a2i']
+        res = self.interpret(f1, [0])
+        assert self.barriers == ['I2R']
+        
+        
+
     def test_simple_read_2(self):
         X = lltype.GcStruct('X', ('foo', lltype.Signed))
         x2 = lltype.malloc(X, immortal=True)
diff --git a/rpython/translator/stm/writebarrier.py b/rpython/translator/stm/writebarrier.py
--- a/rpython/translator/stm/writebarrier.py
+++ b/rpython/translator/stm/writebarrier.py
@@ -85,7 +85,8 @@
                 # field even on a stub
                 pass
 
-            elif op.opname in ('getarraysize', 'getinteriorarraysize'):
+            elif (op.opname in ('getarraysize', 'getinteriorarraysize') and
+                  is_gc_ptr(op.args[0].concretetype)):
                 # XXX: or (is_getter and is_immutable(op))):
                 # we can't leave getarraysize or the immutable getfields
                 # fully unmodified: we need at least immut_read_barrier


More information about the pypy-commit mailing list